Unsupported parameters for (debug) module:

Hi everyone , I am pretty new to Ansible and new learner.
I have an issue with one of my playbook. here is my playbook yml file:

1 —
2 - name: “React with Change Example”
3 hosts: webservers
4 serial: 1
5
6 tasks:
7
8 - name: “Install nginx”
9 debug:
10 msg: “Install nginx on : {{ inventory_hostname }}”
11
12 - name: “Upgrade nginx”
13 debug:
14 msg: “Upgrade nginx on : {{ inventory_hostname }}”
15
16 - name: “Configure nignx”
17 debug:
18 msg: “Start {{ inventory_hostname }}”
19 notify: restart nginx
20 # changed_when: True
21
22 - name: “Verify nginx”
23 debug:
24 msg: “Verify: {{ inventory_hostname }}”
25
26 handlers:
27 - name: restart nginx
28 debug:
29 msg: “CALLED HANDLER FOR RESTART”

after I run the playbook I face this issue ,

TASK [Verify nginx] **************************************************************************************************
task path: /home/andrew/ansible/change.yml:22
The full traceback is:
NoneType: None
fatal: [server1]: FAILED! =>
msg: ‘Unsupported parameters for (debug) module: handlers. Supported parameters include: msg, var, verbosity.’

any one have same experience issue?

@halavehzadeh

msg: ‘Unsupported parameters for (debug) module: handlers. Supported parameters include: msg, var, verbosity.’

Perhaps this is indentation issue in your playbook. Indentation in YAML file is very important because it represents the structure of the data.
I guess the excessive indentation of handlers on line 26 causes it to be treated as a parameter to debug on line 23.

The text you pasted is a bit broken and it is difficult to see actual indentation for each lines to identify the lines that should be modified, so could you please provide the contents of the complete YAML file in one of the following ways?

  • Fornat pasted text with the code block
    • image
  • Paste screenshot of your YAML file
  • Upload actual YAML file
---
  - name: "React with Change Example"
    hosts: webservers
    serial: 1

    tasks:

     - name: "Install nginx"
       debug:
        msg: "Install nginx on : {{ inventory_hostname }}"

     - name: "Upgrade nginx"
       debug:
        msg: "Upgrade nginx on : {{ inventory_hostname }}"

     - name: "Configure nignx"
       debug:
        msg: "Start {{ inventory_hostname }}"
       notify: restart nginx
#       changed_when: True

     - name: "Verify nginx"
       debug:
        msg: "Verify: {{ inventory_hostname }}"

        handlers:
          - name: restart nginx
            debug:
              msg: "CALLED HANDLER FOR RESTART"
2 Likes

@halavehzadeh
Thanks for updating, handlers should be the same level as tasks. Also, to increase indentation, two or four spaces are recommended instead of one, to make playbooks easy to read. I usualy use two spaces.

Example:

---
- name: "React with Change Example"
  hosts: localhost
  serial: 1

  tasks:

    - name: "Install nginx"
      debug:
        msg: "Install nginx on : {{ inventory_hostname }}"

    - name: "Upgrade nginx"
      debug:
        msg: "Upgrade nginx on : {{ inventory_hostname }}"

    - name: "Configure nignx"
      debug:
        msg: "Start {{ inventory_hostname }}"
      notify: restart nginx
      #changed_when: True

    - name: "Verify nginx"
      debug:
        msg: "Verify: {{ inventory_hostname }}"

  handlers:
    - name: restart nginx
      debug:
        msg: "CALLED HANDLER FOR RESTART"
1 Like

Thanks it is worked for me with no error . :blush:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.