Hi,
One last request; what's the best way to get the users confirmation before
continuing further with the playbook? I'd like to be able to say, "host1
has 6 updates available.
- KB: Update for Windows Server 2012 R2 (KB3013769)
- KB: Update for Windows Server 2012 R2 (KB3102429)
- KB: Update for Windows Server 2012 R2 (KB3013816)
- KB: Update for Windows Server 2012 R2 (KB3084905)
- KB: 2017-11 Preview of Monthly Quality Rollup for Windows Server 2012 R2
for x64-based Systems (KB4050946)
- KB: Windows Malicious Software Removal Tool for Windows 8, 8.1, 10 and
Windows Server 2012, 2012 R2, 2016 x64 Edition - November 2017 (KB890830)
"Do you wish to install all updates(y/n)?". If the user presses y, the
playbook will continue and complete the install + reboot. If the user
presses n, the playbook will exit.
I've tried prompts, var_prompts etc; none of which achieve what i'm looking
for.
Any advice?
Thank you
On Monday, December 4, 2017 at 11:07:00 AM UTC+11, area0 wrote:
>
> Thanks Kai - i managed to get exactly what i wanted by using the following
> environment variable;
>
> ANSIBLE_STDOUT_CALLBACK=debug
>
> Here's the final debug/msg configuration of the playbook;
>
> - debug:
> msg: |
> {{ inventory_hostname }} has {{
> available_updates.found_update_count }} updates available.
> {% for key, value in available_updates.updates.iteritems() %}
> - KB: {{ value.title }}
> {% endfor %}
>
>
> Now when i run the playbook, i get the following output;
>
> ok: [host1] => {}
>
> MSG:
>
> host1 has 6 updates available.
> - KB: Update for Windows Server 2012 R2 (KB3013769)
> - KB: Update for Windows Server 2012 R2 (KB3102429)
> - KB: Update for Windows Server 2012 R2 (KB3013816)
> - KB: Update for Windows Server 2012 R2 (KB3084905)
> - KB: 2017-11 Preview of Monthly Quality Rollup for Windows Server 2012 R2
> for x64-based Systems (KB4050946)
> - KB: Windows Malicious Software Removal Tool for Windows 8, 8.1, 10 and
> Windows Server 2012, 2012 R2, 2016 x64 Edition - November 2017 (KB890830)
>
> Thanks for all your help
>
> On Monday, December 4, 2017 at 10:25:58 AM UTC+11, Kai Stian Olstad wrote:
>>
>> On 03.12.2017 23:49, area0 wrote:
>> > Thanks Kai. The output is working fine, it's more about the formatting.
>> > For
>> > example, with the following debug code, i receive the following;
>>
>> Ansible is not a reporting tool so it has limit supported for nice
>> output on the screen.
>> You can put it in a file with the template module.
>>
>>
>> > - debug:
>> > msg: "{{ inventory_hostname }} has {{
>> > available_updates.found_update_count }} updates available.
>> > {% for key, value in
>> > available_updates.updates.iteritems() %}
>> > - KB: {{ value.title }}
>> > {% endfor %}"
>>
>> The first ting to do is losing the quotes and add a pipe, the pipe is
>> essential.
>>
>> - debug:
>> msg: |
>> {{ inventory_hostname }} has {{
>> available_updates.found_update_count }} updates available.
>> {% for key, value in available_updates.updates.iteritems() %}
>> - KB: {{ value.title }}
>> {% endfor %}"
>>
>>
>> > ok: [host1] => {
>> > "msg": "host1 has 6 updates available. - KB: Update for Windows
>> > Server
>> > 2012 R2 (KB3013769) - KB: Update for Windows Server 2012 R2
>> > (KB3102429) -
>> > KB: Update for Windows Server 2012 R2 (KB3013816) - KB: Update for
>> > Windows
>> > Server 2012 R2 (KB3084905) - KB: 2017-11 Preview of Monthly Quality
>> > Rollup
>> > for Windows Server 2012 R2 for x64-based Systems (KB4050946) - KB:
>> > Windows
>> > Malicious Software Removal Tool for Windows 8, 8.1, 10 and Windows
>> > Server
>> > 2012, 2012 R2, 2016 x64 Edition - November 2017 (KB890830) "
>> > }
>> >
>> > What i'd like, is for the output to be formatted as below;
>> >
>> > ok: [host1] => {
>> > "msg": "host1 has 6 updates available.
>> > - KB: Update for Windows Server 2012 R2 (KB3013769)
>> > - KB: Update for Windows Server 2012 R2 (KB3102429)
>> > - KB: Update for Windows Server 2012 R2 (KB3013816)
>> > - KB: Update for Windows Server 2012 R2 (KB3084905)
>> > - KB: 2017-11 Preview of Monthly Quality Rollup for Windows Server
>> > 2012 R2 for x64-based Systems (KB4050946)
>> > - KB: Windows Malicious Software Removal Tool for Windows 8, 8.1,
>> > 10
>> > and Windows Server 2012, 2012 R2, 2016 x64 Edition - November 2017
>> > (KB890830) "
>> > }
>> >
>> > Is this possible?
>>
>> To get an other output than the default one, you'll need to change the
>> stdout callback plugin[1].
>>
>> If you use the debug, it output nice human readable text that you are
>> looking for, but it will be more verbose.
>> You could check out and test the other to see if them give you the
>> output you want or you could write your own.
>>
>>
>> [1]
>> https://docs.ansible.com/ansible/devel/plugins/callback.html#plugin-list
>>
>> --
>> Kai Stian Olstad
>>
>
--
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/0247201b-f517-43c6-aa1c-6fb7036625d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.