Hi;
I read through the docs on loops and am not seeing what I'm looking for.
Basically, loops allow a task to run across a set. From the docs:
- name: add several users
user:
name: "{{ item }}"
state: present
groups: "wheel"
loop:
- testuser1
- testuser2
That would create users testuser1 and testuser2. I'm looking for a way to
iterate a set of tasks over a set of groups. For example, my inventory has
groups like:
$ grep '^\[' hosts
[admins]
[ms1s]
[ms2s]
[ms3s]
[ms4s]
[others]
I currently have separate plays to reboot the hosts in each group, then
wait 10 min before the next one kicks off:
- name: reboot admins
hosts: admins
gather_facts: no
remote_user: root
tasks:
- name: reboot admins
reboot:
reboot_timeout: 300
tags: rebootadm
- name: sleep 10m
pause:
minute: 10
tags: wait10
- name: reboot ms1s
hosts: ms1s
gather_facts: no
remote_user: root
tasks:
- name: reboot ms1s
reboot:
reboot_timeout: 300
tags: rebootm1
- name: sleep 10m
pause:
minute: 10
tags: wait10
What I'd like to do is have that play set up to loop over the groups above
- something like loop at the play level rather than the task level:
- name: reboot admins
hosts: {{ item }}
gather_facts: no
remote_user: root
loop:
- admins
- ms1s
- ms2s
tasks:
- name: reboot admins
reboot:
reboot_timeout: 300
tags: rebootadm
- name: sleep 10m
pause:
minute: 10
tags: wait10
Anyone know of a way to do that?
Thanks
Doug O'Leary
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ae438988-9590-4044-b80c-41d7efa311c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.