# 'common' role updates my app RPM and prevents a handler to execute later on

**URL:** <https://forum.ansible.com/t/common-role-updates-my-app-rpm-and-prevents-a-handler-to-execute-later-on/14685>\
**Category:** Ansible Project\
**Created:** [March 3, 2014, 4:02pm UTC](https://forum.ansible.com/t/common-role-updates-my-app-rpm-and-prevents-a-handler-to-execute-later-on/14685 "2014-03-03T16:02:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Azul](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Azul](https://forum.ansible.com/u/Azul)\
**Post date:** [March 3, 2014, 4:02pm UTC](https://forum.ansible.com/t/common-role-updates-my-app-rpm-and-prevents-a-handler-to-execute-later-on/14685/1 "2014-03-03T16:02:42Z")

</div>

In my role “common” I have:

- name: yum install OS updates  
shell: yum update -y

and then in my “application” role I have:

- name: install app1  
yum: name=app1 state=present  
notify:
- restart app1

This app1 is built in house and deployed to a local yum repo managed by jenkins, so every time I run the “common” role it gets updated to the latest version. As a result when the ‘application’ role runs my ‘app1’ no longer needs to be updated so my restart app1 handler never gets executed.

Any ideas how to ‘fix this’ ?  
Today I am simply restarting app1 every time I run ansible on this host which is not ideal.

---

<div class="post-metadata">

**Author:** ![Ernest0x](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@Ernest0x](https://forum.ansible.com/u/Ernest0x)\
**Post date:** [March 3, 2014, 4:09pm UTC](https://forum.ansible.com/t/common-role-updates-my-app-rpm-and-prevents-a-handler-to-execute-later-on/14685/2 "2014-03-03T16:09:29Z")

</div>

Exclude your app from 'yum update' like this: 'yum -x app1 -y update'

---

<div class="post-metadata">

**Author:** ![Azul](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Azul](https://forum.ansible.com/u/Azul)\
**Post date:** [March 3, 2014, 4:18pm UTC](https://forum.ansible.com/t/common-role-updates-my-app-rpm-and-prevents-a-handler-to-execute-later-on/14685/3 "2014-03-03T16:18:50Z")

</div>

that’s an approach,  
however that ‘-x list’ is likely to grow really quickly as it will require every service list which I restart after an update.

---

<div class="post-metadata">

**Author:** ![Ernest0x](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@Ernest0x](https://forum.ansible.com/u/Ernest0x)\
**Post date:** [March 3, 2014, 4:42pm UTC](https://forum.ansible.com/t/common-role-updates-my-app-rpm-and-prevents-a-handler-to-execute-later-on/14685/4 "2014-03-03T16:42:26Z")

</div>

You can always define and maintain a list variable with the excluded packages. Then, you may make your task look like this: Or create /etc/yum.conf from a template with an equivalent ‘exclude={{ excluded\_packages|join(’ ‘) }}’ line in its [main] section.

---

<div class="post-metadata">

**Author:** ![Johan\_Warlander](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Johan\_Warlander](https://forum.ansible.com/u/Johan_Warlander)\
**Post date:** [March 6, 2014, 9:47am UTC](https://forum.ansible.com/t/common-role-updates-my-app-rpm-and-prevents-a-handler-to-execute-later-on/14685/5 "2014-03-06T09:47:52Z")

</div>

I’d normally have the RPM do the work of restarting after installation (upgrade), at least if it’s always to be done, and is a safe thing. Given your role above, that seems to be true… If so, you would only need the “common” role.

Now, if you need to reconfigure stuff after installing the application, then you would of course put that in a separate role, and notify after changing the config so the app will get restarted.

---

<div class="post-metadata">

**Author:** ![Azul](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Azul](https://forum.ansible.com/u/Azul)\
**Post date:** [March 6, 2014, 6:16pm UTC](https://forum.ansible.com/t/common-role-updates-my-app-rpm-and-prevents-a-handler-to-execute-later-on/14685/6 "2014-03-06T18:16:39Z")

</div>

yes, that’s what I am looking into now.

I deploy the configuration for the app through a different task, which doesn’t change very often.  
caking the RPM-initscripts to restart the app looks like the cleanest way forward.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [March 6, 2014, 8:09pm UTC](https://forum.ansible.com/t/common-role-updates-my-app-rpm-and-prevents-a-handler-to-execute-later-on/14685/7 "2014-03-06T20:09:06Z")

</div>

Are your in-house app RPMs in a custom yum repo? Because you could very easily exclude that and do your system upgrade by using the yum module rather than shell:

yum: state=latest name=\* disablerepo=custom\_repo\_here

---

<div class="post-metadata">

**Author:** ![Azul](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Azul](https://forum.ansible.com/u/Azul)\
**Post date:** [March 6, 2014, 9:41pm UTC](https://forum.ansible.com/t/common-role-updates-my-app-rpm-and-prevents-a-handler-to-execute-later-on/14685/8 "2014-03-06T21:41:14Z")

</div>

ooooooOOOOOOooooo that’s quite handy
