cancel
Showing results for 
Search instead for 
Did you mean: 
Ken_McDonald
Mission Specialist
Mission Specialist
  • 8,172 Views

List of all playbook keywords from command line like ansible-doc for modules?

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?

Labels (1)
Tags (1)
16 Replies
abregman
Mission Specialist
Mission Specialist
  • 2,312 Views

That will list the keywords for a specific module, not the keywords supported within a playbook

0 Kudos
ipalagin
Flight Engineer Flight Engineer
Flight Engineer
  • 2,300 Views

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

 

0 Kudos
Trevor
Starfighter Starfighter
Starfighter
  • 2,286 Views

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!!!

 

 

 

Trevor "Red Hat Evangelist" Chandler
0 Kudos
abregman
Mission Specialist
Mission Specialist
  • 2,284 Views

Thank you, sir

0 Kudos
Khamid
Flight Engineer Flight Engineer
Flight Engineer
  • 2,253 Views

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 

ipalagin
Flight Engineer Flight Engineer
Flight Engineer
  • 2,250 Views

Thank you Khamid ,

Great, it does work in Ansible 2.13.2!

But not in Ansible 2.9 I'm using   Anyway, it's time to upgrade!

0 Kudos
jstanesic
Mission Specialist
Mission Specialist
  • 2,213 Views

@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?

0 Kudos
Join the discussion
You must log in to join this conversation.