Pause after each iteration in a loop

25 views
Skip to first unread message

rambius

unread,
Jul 27, 2017, 12:59:27 PM7/27/17
to Ansible Project
Hello,

Assume we have the following in an inventory

[win_services]
host1 services='["service1", "service2", "service3", "service4"]'
host2 services='["service5", "service6", "service7", "service8"]'
host3 services='["service9", "service10", "service11", "service12", "service13"]'
host4 services='["service14", "service15", "service16", "service17", "service18"]'
host5 services='["service19", "service20", "service21", "service22"]'
host6 services='["service23", "service24", "service25", "service26"]'

Then using win_nssm we start the above services in the following way

---
- name: start services
  hosts: win_services
  - name: install and start services
    win_nssm:
      name: "{{ item }}"
      application: "{{ APP_DIRECTORY }}\\app.exe"
      app_parameters: 
        "-RUN_AS": "CONSOLE"
      start_mode: manual
      stdout_file: "{{ LOG_DIRECTORY }}\\{{ item }}_stdout.log"
      stderr_file: "{{ LOG_DIRECTORY }}\\{{ item }}_stderr.log"
      state: started
    with_items:
- "{{ services }}"

We want to pause a certain amount of seconds, say 90, after each service is started. How can we do this?

I tried to implement it with handlers, and pause in the handler, but that did not succeed.

Thank you very much in advance!

Regards
rambius

Kai Stian Olstad

unread,
Jul 27, 2017, 1:29:54 PM7/27/17
to ansible...@googlegroups.com
On 27. juli 2017 18:59, rambius wrote:
> host6 services='["service23", "service24", "service25", "service26"]'
>
> Then using win_nssm we start the above services in the following way
>
> ---
> - name: start services
> hosts: win_services
> - name: install and start services
> win_nssm:
> name: "{{ item }}"
> application: "{{ APP_DIRECTORY }}\\app.exe"
> app_parameters:
> "-RUN_AS": "CONSOLE"
> start_mode: manual
> stdout_file: "{{ LOG_DIRECTORY }}\\{{ item }}_stdout.log"
> stderr_file: "{{ LOG_DIRECTORY }}\\{{ item }}_stderr.log"
> state: started
> with_items:
> - "{{ services }}"
>
> We want to pause a certain amount of seconds, say 90, after each service is
> started. How can we do this?
>
> I tried to implement it with handlers, and pause in the handler, but that
> did not succeed.

Put the win_nssm and the pause task in a file and use
- include: file.yml
with_items: "{{ services }}"


--
Kai Stian Olstad

rambius

unread,
Jul 27, 2017, 2:05:13 PM7/27/17
to Ansible Project, ansible-pr...@olstad.com


четвъртък, 27 юли 2017 г., 13:29:54 UTC-4, Kai Stian Olstad написа:
Put the win_nssm and the pause task in a file and use
- include: file.yml
   with_items: "{{ services }}"

Thank you. I am trying that.

Regards
rambius
Reply all
Reply to author
Forward
0 new messages