[ansible-project] Re: Parsing for win_updates reboot hint

2015-10-02 Thread J Hawkesworth
the when: doesn't really default to true. Instead when: just needs to 'see' a true or a false. It doesn't care if that is from finding a value of true or false by looking up what is stored in a variable or by running something that returns a true or false. adding the '== true' makes the when:

[ansible-project] Re: Parsing for win_updates reboot hint

2015-10-01 Thread Dimitri Yioulos
Thank you so much for the explanation. I understand it, but am curious as to why "reboot required", without == true or == false, will reboot the server if true is, in fact, returned, and not reboot if false is returned. Does "when" default to true if no argument is explicitly provided? On We

[ansible-project] Re: Parsing for win_updates reboot hint

2015-09-30 Thread J Hawkesworth
Breaking it down a bit reboot_hint is the name of the variable you have chosen to store the registered output in. Inside reboot_hint is the output from the module. The module results are put into a key value structure with a key of results. This is probably done to keep the structured modul

[ansible-project] Re: Parsing for win_updates reboot hint

2015-09-30 Thread Dimitri Yioulos
Jon, Both of your suggestions work; thanks! For my edification, why do either work when "reboot_required": true, and not "reboot_required": false, or why don't they simply resolve against "reboot_required" (without true or false)? Dimitri On Wednesday, September 30, 2015 at 9:38:33 AM UTC-4,

[ansible-project] Re: Parsing for win_updates reboot hint

2015-09-30 Thread J Hawkesworth
I suggest you add a debug on the registered variable and/or run ansible-playbook with -v this will show you the contents of the registered variable. It will be some JSON. Sometimes its useful to paste the JSON into http://jsonlint.com/ so you can see a pretty printed version of the JSON. then

[ansible-project] Re: Parsing for win_updates reboot hint

2015-09-30 Thread Dimitri Yioulos
The above doesn't work. If I run as-is, then I get the following error: when: reboot_hint.stdout.find('"reboot_required": true') != -1 ^ This one looks easy to fix. There seems to be an extra unquoted colon in the line and this is confusing

[ansible-project] Re: Parsing for win_updates reboot hint

2015-09-30 Thread Dimitri Yioulos
Thanks, Jon. This should work?: - name: win update win_updates: category: ['SecurityUpdates','CriticalUpdates','Updates','Tools','DefinitionUpdates','UpdateRollups'] register: reboot_hint - name: reboot server raw: 'cmd /c shutdown /r /t 0' when: reboot_hi

[ansible-project] Re: Parsing for win_updates reboot hint

2015-09-30 Thread J Hawkesworth
You need to use 'register' to capture the results into a variable: http://docs.ansible.com/ansible/playbooks_variables.html#registered-variables Then you can call another module to do the reboot followed by a 'when', probably something like when: result_var.reboot_required worth having a loo