Bootstrap FreeKB - Ansible - ansible-doc inventory
Ansible - ansible-doc inventory

Updated:   |  Ansible articles

By default, the ansible-doc command will use module as the type, thus the -t or --type option followed by inventory must be used to display documentation on inventory.

The -l or --list option can be used to display the dynamic inventory plugins that can be used. Refer to Ansible - Getting Started with the Dynamic Inventory Plugin for more details on dynamic inventory.

ansible-doc --type inventory --list

advanced_host_list Parses a 'host list' with ranges
constructed        Uses Jinja2 to construct vars and groups based on existing inventory.
host_list          Parses a 'host list' string
ini                Uses an Ansible INI file as inventory source.
openstack          OpenStack inventory source
script             Executes an inventory script that returns JSON
virtualbox         virtualbox inventory source
yaml               Uses a specifically YAML file as inventory source.

 

Let's say you want to learn about "host_list". The -s or --snippet option can be used.

ansible-doc --type inventory --snippet host_list

> HOST_LIST    (/usr/local/lib/python3.6/site-packages/ansible/plugins/inventory/host_list.py)

        Parses a host list string as a comma separated values of hosts This plugin only applies to inventory strings that are not paths and contain a
        comma.

  * This module is maintained by The Ansible Community
        METADATA:
          status:
          - preview
          supported_by: community


EXAMPLES:

# define 2 hosts in command line
    # ansible -i '10.10.2.6, 10.10.2.4' -m ping all

    # DNS resolvable names
    # ansible -i 'host1.example.com, host2' -m user -a 'name=me state=absent' all

    # just use localhost
    # ansible-playbook -i 'localhost,' play.yml -c local

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter db59f5 in the box below so that we can be sure you are a human.