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/9fb0040f-e4c2-40a2-9fa2-20e8553c9171%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to