1

I'm trying to run a ansible task but I keep getting an error.

This is the play I want to run:

- name: use of handlers
  hosts: all
  tasks:
    - name: install packages
      yum:
        name: httpd
        state: latest
        notify: restart package
  handlers:
    - name: restart package
      service:
        name: httpd
        state: restarted

But this is the error that ansible gives me:

fatal: [serverb.local]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (ansible.legacy.dnf) module: notify. Supported parameters include: allowerasing, allow_downgrade, name (pkg), enablerepo, disable_excludes, conf_file, list, disable_plugin, installroot, enable_plugin, disable_gpg_check, download_dir, update_cache (expire-cache), releasever, state, nobest, bugfix, install_weak_deps, update_only, autoremove, exclude, download_only, cacheonly, security, lock_timeout, skip_broken, disablerepo, validate_certs, install_repoquery."}

1 Answer 1

3

The indentation is wrong. Correct syntax is

     - name: install packages
       yum:
         name: httpd
         state: latest
       notify: restart package

The error says it:

"Unsupported parameters for (ansible.legacy.dnf) module: notify.

notify is not a parameter of the module dnf or yum. It is a playbook keyword that can be applied to a block or a task. In the above case, it must be indented as a task keyword. See Notifying handlers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.