# When yum succeeds, boot?

**URL:** <https://forum.ansible.com/t/when-yum-succeeds-boot/31065>\
**Category:** Ansible Project\
**Created:** [August 18, 2019, 8:45am UTC](https://forum.ansible.com/t/when-yum-succeeds-boot/31065 "2019-08-18T08:45:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Eggleston](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Eggleston](https://forum.ansible.com/u/Mike_Eggleston)\
**Post date:** [August 18, 2019, 8:45am UTC](https://forum.ansible.com/t/when-yum-succeeds-boot/31065/1 "2019-08-18T08:45:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [August 18, 2019, 9:47am UTC](https://forum.ansible.com/t/when-yum-succeeds-boot/31065/2 "2019-08-18T09:47:17Z")

</div>

1) If you want to reboot on any change just notify a handler

&nbsp;&nbsp;&nbsp;&nbsp;- yum:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.

&nbsp;&nbsp;&nbsp;&nbsp;- yum:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: yum\_result

&nbsp;&nbsp;&nbsp;&nbsp;- command: shutdown -r  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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](https://stackoverflow.com/questions/49272469/how-to-access-information-in-ansible-yum-list-result)

Cheers,

&nbsp;&nbsp;-vlado

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 19, 2019, 4:44am UTC](https://forum.ansible.com/t/when-yum-succeeds-boot/31065/3 "2019-08-19T04:44:20Z")

</div>

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.

Example:  
[https://luktom.net/en/e1497-how-to-update-centos-rhel-using-ansible](https://luktom.net/en/e1497-how-to-update-centos-rhel-using-ansible)

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

Dick

---

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [August 22, 2019, 12:52pm UTC](https://forum.ansible.com/t/when-yum-succeeds-boot/31065/4 "2019-08-22T12:52:48Z")

</div>

Vladimir Botka,

I certifie , You are the best Vladimir !! 🙂

Very the best 🙂

Regards,
