Hi, Brian.

Yes, I understand about the playbook running one or more plays.  What I 
didn't understand (and this is another of my embarrassing mistakes) is that 
I shouldn't have identified any servers or groups when running the 
playbook, as in "ansible-playbook -l serversA playbook.yml" but, rather, 
run it thusly, "ansible-playbook playbook.yml".  That, of course, let's 
Ansible apply the plays to the servers or groups that are specified in the 
plays.  Arrgh.  Hope I'm not using up all of my goodwill on the list.

Dimitri

On Thursday, October 1, 2015 at 3:18:38 PM UTC-4, Dimitri Yioulos wrote:
>
> I'm creating a playbook to update, then reboot, a group of windows servers 
> (serversA).  Prior to reboot, however, I have to stop a couple of services 
> on another group of windows servers (serversB).  This is what I'd like to 
> happen when I run "ansible-playbook -l serversA playbook.yml":
>
> where playbook.yml:
>
> - hosts: *serversA*
>   gather_facts: false
>   tasks:
>     - name: win update
>       win_updates:
>         category: 
> ['SecurityUpdates','CriticalUpdates','Updates','Tools','DefinitionUpdates','UpdateRollups']
>       register: reboot_hint
>
> - hosts: *serversB*
>   gather_facts: false
>   tasks:
>     - name: check for XYZ service
>       raw: sc query XYZ
>       register: xyz_hint
>       failed_when: xyz_hint.rc not in [0,1060]
>     - name: stop XYZ and ABC services                   <-- if XYZ service 
> is installed, so is ABC
>       win_service: name={{ item }} state=stopped
>       with_items: ["XYZ", "ABC"]
>       when: xyz_hint.rc == 0
>
> - hosts: *serversA*
>   gather_facts: false
>   tasks:
>     - name: reboot server
>       raw: 'cmd /c shutdown /r /t 0'
>       when: reboot_hint.reboot_required == true
>
> Can I do this in a single playbook?  If not (or if this is set up 
> incorrectly, and I'm sure it is), then how?
>
> Thanks!
>

-- 
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/20deb8c5-086b-47fc-8a3a-6fda3296797e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to