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

76 views
Skip to first unread message

Azul Inho

unread,
Mar 3, 2014, 11:02:42 AM3/3/14
to ansible...@googlegroups.com


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.


Petros Moisiadis

unread,
Mar 3, 2014, 11:09:29 AM3/3/14
to ansible...@googlegroups.com
> --
> 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 post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/47f7a6df-7d9c-423f-9d24-d72c20450084%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

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

Azul

unread,
Mar 3, 2014, 11:18:50 AM3/3/14
to ansible...@googlegroups.com
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 received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/sY63qib6f9c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

Petros Moisiadis

unread,
Mar 3, 2014, 11:42:26 AM3/3/14
to ansible...@googlegroups.com

For more options, visit https://groups.google.com/groups/opt_out.

You can always define and maintain a list variable with the excluded packages.

Then, you may make your task look like this:
- name: yum install OS updates
  shell: yum -x {{ excluded_packages|join('-x ') }} -y update


Or create /etc/yum.conf from a template with an equivalent 'exclude={{ excluded_packages|join(' ') }}' line in its [main] section.

Johan Wärlander

unread,
Mar 6, 2014, 4:47:52 AM3/6/14
to ansible...@googlegroups.com
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.

Azul Inho

unread,
Mar 6, 2014, 1:16:39 PM3/6/14
to ansible...@googlegroups.com
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.

James Cammarata

unread,
Mar 6, 2014, 3:09:06 PM3/6/14
to ansible...@googlegroups.com
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


--
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 post to this group, send email to ansible...@googlegroups.com.

Azul

unread,
Mar 6, 2014, 4:41:14 PM3/6/14
to ansible...@googlegroups.com
ooooooOOOOOOooooo that's quite handy


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/sY63qib6f9c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages