Hammer fails to execute an Ansible playbook with "ERROR! 'name' is a required field for include_role." but the playbook works using Satellite GUI
Environment
Satellite 6
Issue
Invoking an Ansible job using hammer playbook fails with error message ERROR! 'name' is a required field for include_role. Example command:
hammer job-invocation create --search-query 'name ^ (host.example.com)' --job-template "Ansible - Run playbook" --inputs playbook="$(cat playbook.yml)"
The same playbook works fine when launching the job using Satellite GUI.
Resolution
Instead of hammer parameter --inputs use --input-files
hammer job-invocation create --search-query "name ^ (host.example.com)" --job-template "Ansible - Run playbook" --input-files playbook=playbook.yml
For more KB articles/solutions related to Red Hat Satellite 6.x hammer Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x hammer-related Issues
Root Cause
hammer --input parameter doesn't always parse correctly YAML strings. Using --input-files, YAML file is forwarded untouched to Ansible.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.