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

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.

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

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.

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.

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.

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.

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

ooooooOOOOOOooooo that’s quite handy