Not able to restart HTTPD using notify in roles

Hello,

 I am facing issue with notify module while i am trying to restat httpd service using roles.
Below are the details:
Directory:
├── webservers
│ ├── defaults
│ ├── files
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ ├── tasks
│ │ └── main.yml
│ ├── templates
│ └── variables
│ └── main.yml
└── webservers.yml

Code:
[test@namico1 roles]$ cat webservers/handlers/main.yml 
- name: restart HTTPD
service: name=httpd state=restarted
[test@namico1 roles]$ cat webservers/tasks/main.yml
- name: Install Apache WebServer
yum: pkg=httpd state=installed
notify: restart HTTPD

Output:
[test@namico1 roles]$ ansible-playbook webservers.yml 
PLAY [RedHat] **************************************************************************************************************************************************************************
TASK [webservers : Install Apache WebServer] *******************************************************************************************************************************************
ok: [namico2.mylabserver.com]
ok: [namico3.mylabserver.com]
ok: [namico6.mylabserver.com]
ok: [namico1.mylabserver.com]
PLAY RECAP *****************************************************************************************************************************************************************************
namico1.mylabserver.com : ok=1 changed=0 unreachable=0 failed=0
namico2.mylabserver.com : ok=1 changed=0 unreachable=0 failed=0
namico3.mylabserver.com : ok=1 changed=0 unreachable=0 failed=0
namico6.mylabserver.com : ok=1 changed=0 unreachable=0 failed=0

Hosts File:
[test@namico1 roles]$ cat /etc/ansible/hosts 
[local]
localhost
[RedHat]
namico1.mylabserver.com
namico2.mylabserver.com
namico6.mylabserver.com
namico3.mylabserver.com

Httpd status:
[test@namico1 roles]$ systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)

Can you please help me with this.

Regards,
Namico.
  • post-author-pic
    Stosh O
    09-21-2018

    Hi Namico,

    It appears that httpd is already installed on your target nodes based on the playbook output (no reported changes).  Recall, a handler is only triggered when a change is made.

Looking For Team Training?

Learn More