cancel
Showing results for 
Search instead for 
Did you mean: 
Ken_McDonald
Mission Specialist
Mission Specialist
  • 8,893 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
Fran_Garcia
Starfighter Starfighter
Starfighter
  • 6,306 Views

You have the "in-system" documentation provided by the `ansible-doc` RPM.

 

EG: /usr/share/doc/ansible-doc/rst/user_guide/

 

You have your HTML versions too, if you find that useful...

0 Kudos
matteoclc
Flight Engineer
Flight Engineer
  • 6,303 Views

That's not completely true.

It seems that since ansible-doc inclusion in ansible package the rst and html documentation in not installed anymore.

I was looking for the same answer some days ago and this is all that i found, but if you have better answer...you are welcome :)

 

--
Matteo Calcagnini
0 Kudos
Ken_McDonald
Mission Specialist
Mission Specialist
  • 6,294 Views

I'm asking about generic play keywords like
changed_when
with_file
with_sequence
when
handlers
notify
ignore_errors
failed_when

My question might be trivial but I'm trying to understand how complete the "in-system" documentation is. Seems we get keyword/option docs for the ansible.cfg and modules but not for the paybook keywords themselves
https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html

paul_
Cadet
Cadet
  • 5,522 Views

I found my way here searching for an answer to this question whilst studying for the EX294 exam.

I know this thread is a year old but I thought I would update with the answer so it might help someone else.

$ ansible-doc --type keyword --list

paul_
Cadet
Cadet
  • 5,511 Views

A quick follow up:

I see now that this option is in RHEL 8.6 & ansible-core-2.12 but appears to not be in RHEL 8.4 and ansible-2.9.  So still a problem for the current exam which uses RHEL 8.4.

drlavery
Mission Specialist
Mission Specialist
  • 5,416 Views

I guess you could use:

ansible-doc [module name] | grep EXAMPLES -n50

this should give you a playbook example, 

But to get a list of modules that you can use, there is nearly 3000 modules...(just under I beleive) https://docs.ansible.com/ansible/2.9/modules/list_of_all_modules.html so best to use the basic ones first:

user, service, yum (apt,dnf,gem,pip,package), firewalld, reboot, file, copy, lineinfile, get-url, nmcli and uri.

Happy exploring...

0 Kudos
abregman
Mission Specialist
Mission Specialist
  • 5,387 Views

I honestly don't know if it captures everything but I definitely see most of them when running the following:

grep -R -i -E "\s+_\w+ \=" /usr/lib/python3.10/site-packages/ansible/playbook/* -o | sed 's/\s_//g' | tr -d = | uniq

0 Kudos
abregman
Mission Specialist
Mission Specialist
  • 5,382 Views

And "better":

grep -R -i -E "\s+_\w+ \=" /usr/lib/python$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')/site-packages/ansible/playbook/* -o | sed 's/\s_//g' | tr -d = | uniq

Rajanikanty
Mission Specialist
Mission Specialist
  • 5,361 Views

ansible-doc -t module my_module_name

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