# Need help with Ansible Notify module: Handlers are not invoked even if template target file changes

**URL:** <https://forum.ansible.com/t/need-help-with-ansible-notify-module-handlers-are-not-invoked-even-if-template-target-file-changes/21437>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [May 13, 2016, 9:34pm UTC](https://forum.ansible.com/t/need-help-with-ansible-notify-module-handlers-are-not-invoked-even-if-template-target-file-changes/21437 "2016-05-13T21:34:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srikanth\_Vavilapalli](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@Srikanth\_Vavilapalli](https://forum.ansible.com/u/Srikanth_Vavilapalli)\
**Post date:** [May 13, 2016, 9:34pm UTC](https://forum.ansible.com/t/need-help-with-ansible-notify-module-handlers-are-not-invoked-even-if-template-target-file-changes/21437/1 "2016-05-13T21:34:37Z")

</div>

Hi

I am using ansible-playbook version 1.8.2.

I have the following task in my ansible playbook that needs to invoke a set of handlers whenever the config file changes:

- name: ceilometer proxy config

template: src=ceilometer\_proxy\_config.j2 dest=/usr/local/share/monitoring-channel-1\_ceilometer\_proxy\_config mode=0777

notify:

- restart monitoring-channel

I am observing that the actual file on the target machine changes, but ansible reports the whole operation as “changed: false” as shown below so that notify handlers are not getting invoked.

\<10.0.0.3\> EXEC ssh -C -tt -q -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/root/.ansible/cp/ansible-ssh-%h-%p-%r” -o StrictHostKeyChecking=no -o IdentityFile="/opt/xos/synchronizers/m

onitoring\_channel/sys/MonitoringChannel\_1.key" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubu

ntu -o ConnectTimeout=10 10.0.0.3 /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=cdmmgwzmnomzpfikxmbzpqyxcoiiwlsy] password: " -u root /bin/sh -c '”’"'echo SUDO-SUCCESS-cdmmgwzmnomzpfik

xmbzpqyxcoiiwlsy; rc=flag; [-r “/usr/local/share/monitoring-channel-1\_ceilometer\_proxy\_config”] || rc=2; [-f “/usr/local/share/monitoring-channel-1\_ceilometer\_proxy\_config”] || rc=1; [ -d "/usr/l

ocal/share/monitoring-channel-1\_ceilometer\_proxy\_config" ] && rc=3; python -V 2\>/dev/null || rc=4; [x"$rc" != “xflag”] && echo “${rc} /usr/local/share/monitoring-channel-1\_ceilometer\_proxy\_config”

&& exit 0; (python -c ‘"’“'”‘"’“'”‘"’“'import hashlib; print(hashlib.sha1(open(”/usr/local/share/monitoring-channel-1\_ceilometer\_proxy\_config", “rb”).read()).hexdigest())‘"’“'”‘"’“'”‘"’"’ 2\>/dev/null

) || (python -c ‘"’“'”‘"’“'”‘"’“'import sha; print(sha.sha(open(”/usr/local/share/monitoring-channel-1\_ceilometer\_proxy\_config", “rb”).read()).hexdigest())‘"’“'”‘"’“'”‘"’"’ 2\>/dev/null) || (echo "0 /

usr/local/share/monitoring-channel-1\_ceilometer\_proxy\_config")‘"’"‘’

\<10.0.0.3\> EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/root/.ansible/cp/ansible-ssh-%h-%p-%r” -o StrictHostKeyChecking=no -o IdentityFile="/opt/xos/synchronizers/monit

oring\_channel/sys/MonitoringChannel\_1.key" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu

-o ConnectTimeout=10 10.0.0.3 /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=vclkghiatnbspgrortpgrtspkuxxaxya] password: " -u root /bin/sh -c '”’"'echo SUDO-SUCCESS-vclkghiatnbspgrortpg

rtspkuxxaxya; LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python ; rm -rf /home/ubuntu/.ansible/tmp/ansible-tmp-1462993325.34-125201446134255/ \>/dev/null 2\>&1’“'”‘’

ok: [10.0.0.3] =\> {“changed”: false, “gid”: 0, “group”: “root”, “mode”: “0777”, “owner”: “root”, “path”: “/usr/local/share/monitoring-channel-1\_ceilometer\_proxy\_config”, “size”: 389, “state”: “file”,

“uid”: 0}

Not sure why the “changed” flag is false even though the file content is changing on the target machine. For ex:

Before file change, the following is the timestamp of the file:

ubuntu@mysite-ceilometer-1:~$ ls -alrt /usr/local/share/

total 28

-rwxrwxrwx 1 root root 389 May 11 18:52 monitoring-channel-1\_ceilometer\_proxy\_config

drwxr-xr-x 6 root root 4096 May 11 18:52 .

And after change of the file:

ubuntu@mysite-ceilometer-1:~$ ls -alrt /usr/local/share/

total 28

-rwxrwxrwx 1 root root 422 May 11 19:11 monitoring-channel-1\_ceilometer\_proxy\_config

drwxr-xr-x 6 root root 4096 May 11 19:11 .

I have even compared the hash of files using the same commands (hashlib.sha1, sha.sha) before and after change which is indeed different.

Could any one help me with this issue and how I can troubleshoot what is going wrong here? Plz let me know if you need more details.

Thanks

Srikanth

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [May 14, 2016, 8:16am UTC](https://forum.ansible.com/t/need-help-with-ansible-notify-module-handlers-are-not-invoked-even-if-template-target-file-changes/21437/2 "2016-05-14T08:16:12Z")

</div>

Go to your target host, move the file to  
monitoring-channel-1\_ceilometer\_proxy\_config.TEST and rerun your  
playbook. As the file does not exist before, it should return changed.

Compare the two files. Is there any difference?

I was thinking maybe the only difference is a {{ ansible\_managed }}  
inside the file that is being changed. If this is the only difference,  
ansible might report the file as unchanged, even if the timestamp is  
changed inside the file. Just a wild guess.

Johannes

---

<div class="post-metadata">

**Author:** ![Srikanth\_Vavilapalli](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@Srikanth\_Vavilapalli](https://forum.ansible.com/u/Srikanth_Vavilapalli)\
**Post date:** [May 16, 2016, 3:35pm UTC](https://forum.ansible.com/t/need-help-with-ansible-notify-module-handlers-are-not-invoked-even-if-template-target-file-changes/21437/3 "2016-05-16T15:35:19Z")

</div>

Hi

Thanks for your response. I will try this and let you know.

From the file content wise, I have verified it before if the file is really changing or not and it was changing… The file looked like the following before change:

# This file autogenerated by monitoring-channel observer

# It contains a list of attributes to be used by ceilometer proxy web server

# syntax: key=value

[default]  
auth\_url=[http://130.127.133.58:5000/v2.0](http://130.127.133.58:5000/v2.0)  
admin\_user=admin  
admin\_tenant=admin  
admin\_password=d1am0nd  
ceilometer\_pub\_sub\_url=[http://130.127.133.58:4455/](http://130.127.133.58:4455/)

[allowed\_tenants]  
57fc48675c384d4ca547a59e9d44b053  
default\_admin\_tenant

And after change, it is (There is one new entry getting added in to the file as highlighted in RED below):

# This file autogenerated by monitoring-channel observer

# It contains a list of attributes to be used by ceilometer proxy web server

# syntax: key=value

[default]  
auth\_url=[http://130.127.133.58:5000/v2.0](http://130.127.133.58:5000/v2.0)  
admin\_user=admin  
admin\_tenant=admin  
admin\_password=d1am0nd  
ceilometer\_pub\_sub\_url=[http://130.127.133.58:4455/](http://130.127.133.58:4455/)

[allowed\_tenants]  
57fc48675c384d4ca547a59e9d44b053  
**36df52d6b22e4b29b87ed7ab9bb78d64**  
default\_admin\_tenant

Thanks  
Srikanth
