notifier is not working

17 views
Skip to first unread message

jithendra myla

unread,
Jan 19, 2017, 6:22:02 PM1/19/17
to Ansible Project
notifier is not working even though i mention everything correctly, Please help

[ansible@centos1 ansible_playbooks]$ cat install_plays.yml
--- # install software on multiple hosts
- hosts: apacheweb
  remote_user: ansible
  connection: ssh
  become: yes
  become_method: sudo
  gather_facts: yes
  vars_files:
  - values.property
  tasks:
  - name: install apache
    yum: name={{ apache }} state={{ stat }}
  - name: copy the httpd.conf
    template: src=httpd.conf dest=/etc/httpd/conf
    notify:
    - restart apache1
  handlers:
  - name: restart apache1
    service: name=httpd state=restarted enabled=yes

- hosts: appserver
  remote_user: ansible
  connection: ssh
  gather_facts: yes
  become: yes
  become_method: sudo
  vars_files:
  - values.property
  tasks:
  - name: Install telnet
    yum: name={{ package }} state={{ stat }}
 
- hosts: debian
  remote_user: ansible
  connection: ssh
  become: yes
  become_method: sudo
  gather_facts: yes
  vars_files:
  - values.property
  tasks:
  - name: Install lynx
    apt: name={{ package1 }} state={{ stat }}

- hosts: localhost
  remote_user: ansible
  connection: ssh
  gather_facts: yes
  become: yes
  become_method: sudo
  vars_files:
  - values.property
  tasks:
  - name: Install telnet
    yum: name={{ package }} state={{ stat }}


[ansible@centos1 ansible_playbooks]$ cat values.property
apache: httpd
package: telnet
package1: lynx
stat: latest
port: 8000
[ansible@centos1 ansible_playbooks]$


[ansible@centos1 ansible_playbooks]$ ansible-playbook install_plays.yml --extra-vars "stat=present"

PLAY [apacheweb] ***************************************************************

TASK [setup] *******************************************************************
ok: [centos2.ohari.com]

TASK [install apache] **********************************************************
changed: [centos2.ohari.com]

TASK [copy the httpd.conf] *****************************************************
ok: [centos2.ohari.com]

PLAY [appserver] ***************************************************************

TASK [setup] *******************************************************************
ok: [centos3.ohari.com]

TASK [Install telnet] **********************************************************
changed: [centos3.ohari.com]

PLAY [debian] ******************************************************************

TASK [setup] *******************************************************************
ok: [ubuntu2.ohari.com]

TASK [Install lynx] ************************************************************
changed: [ubuntu2.ohari.com]

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [Install telnet] **********************************************************
changed: [localhost]

PLAY RECAP *********************************************************************
centos2.ohari.com          : ok=3    changed=1    unreachable=0    failed=0  
centos3.ohari.com          : ok=2    changed=1    unreachable=0    failed=0  
localhost                  : ok=2    changed=1    unreachable=0    failed=0  
ubuntu2.ohari.com          : ok=2    changed=1    unreachable=0    failed=0  

[ansible@centos1 ansible_playbooks]$



Brian Coca

unread,
Jan 19, 2017, 7:34:40 PM1/19/17
to ansible...@googlegroups.com
It works as expected, the "copy of httpd" returns OK, not changed, the "install of apache" is changed, but does not have a notify.

A task must have a notify AND return changed status to invoke a handler.


----------
Brian Coca

jithendra myla

unread,
Jan 24, 2017, 10:38:42 AM1/24/17
to Ansible Project
Thank you Brain
Reply all
Reply to author
Forward
0 new messages