Other than web documentation, is there a command line way to access a list of all the available general playbook keywords similar to what the 'ansible-doc' command does for modules & their options, and how 'ansible-config dump' does it for ansible.cfg options?
That will list the keywords for a specific module, not the keywords supported within a playbook
1. I had the same question, mostly to save precious time while passing Ansible related Red Hat certification exams. But it looks like ansible-doc can only help with modules ("ansible-doc file") and plugins (ansible-doc -t lookup password). Beyond that, there is no command line help for Jinja2 filters - it can be found in Jinja2 documentation only, not even in the Ansible documentation.
However, ansible-lint package (automation-hub repo) contains /usr/lib/python3.6/site-packages/ansiblelint/utils.py - this Python file has all the keywords and can be helpful. For example, what do we have for "tasks"? Or, what keywords "block" has? Open utils.py with "less" and search - you'll find the hints!
2. "ansible-config dump" gets data from /usr/lib/python3.6/site-packages/ansible/config/base.yml
That solution provided on Thursday, by abregman, definitely provides some (if not
all) of the keywords used in a playbook:
grep -R -i -E "\s+_\w+ \=" /usr/lib/python3.10/site-packages/ansible/playbook/* -o | sed 's/\s_//g' | tr -d = | uniq
Very elegantly done abregman!!!
Thank you, sir
ansible-doc -t keyword -l > this gives list of available keywords in aplay level. Then you can get documentation for each one.
Example: ansible-doc -t keyword failed_when
Thank you Khamid ,
Great, it does work in Ansible 2.13.2!
But not in Ansible 2.9 I'm using
@Ken_McDonalddid you find a solution to your question? What is your reasoning for using only in-system documentation except for getting around in the exam?
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.