Hi,
We have a bunch of services, defined as a list of {{ app.name }} and {{ app.version }} variables. We template our upstart files so ansible knows if a new version is being deployed or not (the file only changes if the version number increments). What I’d like to do is only bounce the services whose versions have changed. Here’s what we have at present:
-
name: create upstart configs
template: src=upstart.conf
dest=/etc/init/{{ item.name }}.conf
sudo: yes
with_items: apps
register: app_upstart_config -
name: stop
with_items: apps
when: app_upstart_config.changed
shell: stop {{ item.name }}
sudo: yes
ignore_errors: yes -
name: start
with_items: apps
when: app_upstart_config.changed
shell: start {{ item.name }}
sudo: yes
What this seems to be doing at present is bouncing all the apps if any of them change. If none of them change it doesn’t bounce them, so it’s nearly there! I suspect that with_items is interacting with register in an unanticipated way. Any help would be gratefully appreciated!
Thanks,
-Darren