Ah, and now I remember - I couldn't get the win_updates module to work.
When I update Windows servers, I want the install all available updates
(e.g. critical and important), with the exception of optional. I've
created a play to look like this:
---
- hosts: windows
gather_facts: true
tasks:
- name: win update
win_updates:
category: security
The play runs, but no updates are applied. Also, I have no idea how to
apply multiple types of updates. I've posted previously about this, but
it's still unresolved. That's why I went for using raw.
Dimitri
On Tuesday, September 1, 2015 at 12:22:23 PM UTC-4, Dimitri Yioulos wrote:
>
> Hi, all.
>
> I've been struggling with trying to get Ansible working for Windows
> automation. Perhaps I'm asking too much, but here's what I'm after - I
> want to update a group of servers, stop a particular service on a few of
> those server, then reboot the entire group. Updating and rebooting are the
> easy parts. My challenge is in identifying the servers that have the
> particular service running, and stopping that service if it's running. The
> command that I'd use at the Windows cli would be this: sc query
> ListManager | find "RUNNING" or
> sc query ListManager | find "STATE", which return "STATE : 4 RUNNING". I
> can extend that a bit, like so: sc query ListManager | find "RUNNING" >nul
> 2>&1 && echo running, which obviously returns "running".
>
> Here's my play, so far:
>
> ---
>
> - hosts: all
> gather_facts: false
>
> tasks:
> - name: update server
> raw: 'cmd /c wuauclt.exe /resetauthorization /detectnow /updatenow'
> - name: check for Lyris service
> raw: sc query ListManager | find "RUNNING" >nul 2>&1 && echo running
> # when: "'LM' not in inventory_hostname"
> register: lyris_hint
> always_run: yes
> tags:
> - lyristest
>
> - debug: var=lyris_hint.stdout_lines
>
> I was hoping that the debug line would output "running" so that I could
> use output from the raw as the basis for stopping the service with:
>
> - win_service:
> name: ListManager
> state: stopped
>
> - win_service:
> name: LyrisAlert
> state: stopped
>
> and, finally, reboot the systems with:
>
> - name: reboot server
> raw: 'cmd /c shutdown /r /t 0'
>
> Can anyone help me with the service detection/stop part of this?
>
> Thanks.
>
> Dimitri
>
--
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/27df8551-3d1c-471d-87c6-50c9d9373692%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.