When yum succeeds, boot?

16 views
Skip to first unread message

Mike Eggleston

unread,
Aug 18, 2019, 4:45:38 AM8/18/19
to ansible...@googlegroups.com
I am working on a playbook that uses yum. When yum does an update of all installed packages I want to do a conditional shutdown -r. What condition do I check from the yum task succeeding?

Mike

Vladimir Botka

unread,
Aug 18, 2019, 5:47:27 AM8/18/19
to Mike Eggleston, ansible...@googlegroups.com
1) If you want to reboot on any change just notify a handler

- yum:
...
notify: reboot

Note: "update_cache" makes "yum" report "changed" even when no package have
been changed (installed/upgraded/downgraded); hence "update_cache" in a
separate task.

2) If you want to reboot on a particular combination of changes register
"yum_result" and make your choice.

- yum:
...
register: yum_result

- command: shutdown -r
when: <condition based on yum_result>

Note: See details in
How to access information in ansible yum list result?
https://stackoverflow.com/questions/49272469/how-to-access-information-in-ansible-yum-list-result

Cheers,

-vlado

Dick Visser

unread,
Aug 19, 2019, 12:44:44 AM8/19/19
to ansible...@googlegroups.com
Not all package updates require a reboot. 
You can make this more robust by installing yum-utils, run /sbin/needs-restarting, and decide based on what that returns.

On Debian based distros you’d check for the presence of /var/run/reboot-required. 

Dick 

On Sun, 18 Aug 2019 at 10:45, Mike Eggleston <mikee...@gmail.com> wrote:
I am working on a playbook that uses yum. When yum does an update of all installed packages I want to do a conditional shutdown -r. What condition do I check from the yum task succeeding?

Mike

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/47122EE6-9169-4E29-9AF9-B6C10697DEAA%40gmail.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Karther

unread,
Aug 22, 2019, 8:52:48 AM8/22/19
to Ansible Project
Vladimir Botka,

I certifie ,  You are the best Vladimir !! :)

Very the best :)

Regards,
Reply all
Reply to author
Forward
0 new messages