TransWikia.com

ansible register on template is not working

Server Fault Asked by Boaz on August 6, 2020

I’m trying to restart nginx in my ansible playbook if I changed the configuration. The configuration copy is done via template.

- name: update nginx.conf
  template: src=../templates/nginx_global_conf.conf.j2 dest=/etc/nginx/nginx.conf
  sudo: yes
  register: nginx_conf
- name: restart nginx if needed
  shell: service nginx restart
  when: nginx_conf.changed

Even if I’m getting:

TASK: [webapp | update nginx.conf] ********************************************
changed: [IPADDRESS]

I ALWAYS get:

TASK: [webapp | restart nginx if needed] **************************************
skipping: [IPADDRESS]

Tried also instead of shell:

action: service name=nginx state=restarted enabled=yes

It is not the problem. The register that isn’t signalling is…

One Answer

OK. Apparently I had the same nginx_conf in a different yml I included. Keeping the question here because there are quite some good tips. Thanks to all the helpers

Answered by Boaz on August 6, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP