LinuxCommandLibrary

ansible-doc

Display Ansible module and plugin documentation

TLDR

List available action plugins (modules)

$ ansible-doc [[-l|--list]]
copy

List available plugins of a specific type
$ ansible-doc [[-t|--type]] [become|cache|callback|cliconf|connection|...] [[-l|--list]]
copy

Show information about a specific action plugin (module)
$ ansible-doc [plugin_name]
copy

Show information about a plugin with a specific type
$ ansible-doc [[-t|--type]] [become|cache|callback|cliconf|connection|...] [plugin_name]
copy

Show the playbook snippet for action plugin (modules)
$ ansible-doc [[-s|--snippet]] [plugin_name]
copy

Show information about an action plugin (module) as JSON
$ ansible-doc [[-j|--json]] [plugin_name]
copy

SYNOPSIS

ansible-doc [-l] [-s] [-t ] [module_or_plugin_name ...]
ansible-doc --version
ansible-doc --help

PARAMETERS

-l, --list
    Lists all available Ansible modules and plugins that can be documented.

-s, --snippet
    Displays a short usage snippet for the specified module or plugin, showing common parameters.

-t , --type
    Specifies the type of plugin to document. Common types include module (default), lookup, filter, connection, and inventory.

-v, --verbose
    Enables verbose output, which can provide more detailed information during execution.

--version
    Shows the program's version number and exits.

--help
    Displays a help message for the ansible-doc command and exits.

DESCRIPTION

ansible-doc is a command-line utility used to display documentation for Ansible modules, plugins, and lookups. It provides detailed information including module parameters, examples, return values, and common usage patterns. This tool is invaluable for Ansible users and developers to quickly understand how to use various components without needing internet access or searching external documentation. It retrieves the documentation directly from the installed Ansible libraries, ensuring accuracy for your specific Ansible version. Users can either query specific module or plugin names or list all available modules to explore Ansible's vast capabilities. It significantly aids in playbook development and debugging by providing immediate access to critical module specifications.

CAVEATS

ansible-doc relies on an installed Ansible environment, meaning it will not function without a proper Ansible installation. The documentation it provides is specific to the version of Ansible currently installed on your system; it may not reflect the latest or oldest versions available online. Furthermore, it focuses exclusively on modules and plugins, and does not provide documentation for general Ansible concepts, playbook syntax, or best practices.

<B>EXAMPLES OF USAGE</B>

To view documentation for a specific module, such as the yum module, you would run:
ansible-doc yum

To see a brief snippet for the shell module's common parameters:
ansible-doc -s shell

To list all available modules:
ansible-doc -l

To view documentation for a lookup plugin, such as file:
ansible-doc -t lookup file

<B>OFFLINE ACCESSIBILITY</B>

One of the key benefits of ansible-doc is its ability to provide comprehensive module and plugin documentation without requiring an active internet connection. This makes it an ideal tool for use in isolated or air-gapped environments where external documentation resources are not readily available.

HISTORY

ansible-doc has been a fundamental part of the Ansible project since its early stages. It was introduced to provide an on-demand, offline documentation source for the ever-growing collection of Ansible modules. As Ansible evolved, ansible-doc adapted to support new plugin types (like lookups, filters, and inventory plugins) and underwent continuous improvements in its output formatting and search capabilities. Its core purpose of being an accessible, quick reference for module and plugin usage remains unchanged, making it an indispensable tool for Ansible users.

SEE ALSO

Copied to clipboard