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 it should be fairly straightforward to work out what you need in the
when:
I *think*
when: reboot_hint.results.reboot_required
might be enough or possibly
when: reboot_hint.results.reboot_required == true
Hope this helps.
Jon
On Wednesday, September 30, 2015 at 6:53:35 PM UTC+1, Dimitri Yioulos wrote:
>
> 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 the parser. It was only expecting to find one free
> colon. The solution is just add some quotes around the colon, or quote the
> entire line after the first colon.
>
> I have to parse for "reboot_required": true, since if no reboot is
> required, output is "reboot_required": false. Neither quoting the second
> colon nor the entire line after the first colon work. How do I correct for
> this?
>
>
> On Wednesday, September 30, 2015 at 9:38:33 AM UTC-4, Dimitri Yioulos
> wrote:
>>
>> Hello, all.
>>
>> With help from the list, I have windows updates working via the rewritten
>> win_updates module found here
>> <https://github.com/ansible/ansible-modules-extras/pull/854>. I'm now
>> looking for a way to creat a reboot hint based on the return output.
>> Here's what that output partially looks like when I run the module (using
>> -v):
>>
>> changed: [sawintest02] => {"changed": true, "failed_update_count": 0,
>> "found_update_count": 23, "installed_update_count": 23, "reboot_required":
>> true, "updates": {"04f04253-f803-43b8-8b37-6841c614dd9f": {"id":
>> "04f04253-f803-43b8-8b37-6841c614dd9f", "installed": true, "kb":
>> ["3084135"], "title": "Security Update for Windows Server 2012 R2
>> (KB3084135)"}, ~
>>
>> How would I parse this output to create a hint so that a reboot will be
>> done if "reboot_required": true, and nothing be done if "reboot_required":
>> false,
>>
>> I'm a terrible programmer, so your help is greatly appreciated.
>>
>> 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/d290315d-0862-42d5-8c73-912c733551ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.