This is my lamp/tasks/main.yaml file (lamp is the role name)
- import_task: httpd.yaml
- import_task: php.yaml
- notify: restart httpd
this is my lamp/handlers/main.yaml file
- name: restart httpd
service:
name: httpd
state: restarted
enabled: yes
my main playbook file is:
- hosts: server1
remote_user: root
roles:
- lamp
While executing playbook iam getting following error:
ERROR! no action detected in task. This often indicates a misspelled module
name, or incorrect module path.
The error appears to have been in '/playbooks/lamp/tasks/main.yaml': line 1,
column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- import_task: httpd.yaml
^ here
The error appears to have been in '/playbooks/lamp/tasks/main.yaml': line 1,
column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- import_task: httpd.yaml
^ here
exception type: <class 'ansible.errors.AnsibleParserError'>
exception: no action detected in task. This often indicates a misspelled
module name, or incorrect module path.
The error appears to have been in '/playbooks/lamp/tasks/main.yaml': line 1,
column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- import_task: httpd.yaml
^ here
Iam using ansible 7.4 on centos7.Without handler it is working file.But while using handler it is not working.I recently started learing ansible.Pls help me to find a solution.Iam not understanding why handler is not supporting..?
Best Answer
The error in question is because
import_task
is incorrect syntax, useimport_tasks
(plural) instead.But handlers can be attached to / notified from tasks, and
import_tasks
is not a task itself, so it will not do what you expect. You should notify handler from individual tasks that should trigger service restart (like configuration changes).