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 [options] [name]

PARAMETERS

-h, --help
    Show this help message and exit

-l, --list
    List all available modules/plugins of the specified type

-M, --module-path PATH
    Colon-separated paths to module library directories

-s, --snippet
    Show playbook snippet with parameter type hints

-t TYPE, --type TYPE
    Specify type: module (default), cache, callback, connection, lookup, shell, strategy, vars

-v
    Verbose mode (use -vvv for more detail)

-V, --version
    Show program's version number and exit

DESCRIPTION

ansible-doc is a command-line utility in the Ansible automation platform that provides detailed documentation for modules, plugins, and other Ansible components directly from the terminal. It enables users to quickly reference syntax, parameters, return values, examples, and notes without needing internet access or external documentation sites, making it invaluable for playbook development, troubleshooting, and offline environments.

By default, running ansible-doc without arguments lists all available modules installed in Ansible's module path. Specifying a module name, like ansible-doc setup, displays its full documentation in a formatted view. The tool supports various item types (e.g., modules, connection plugins, callbacks) via the -t option, allowing comprehensive coverage of Ansible's ecosystem.

Key features include snippet mode (-s) for generating ready-to-use playbook parameter blocks and listing mode (-l) for inventorying available items. It respects Ansible's configuration, such as module paths set via ANSIBLE_LIBRARY or --module-path, ensuring documentation reflects the local environment. This tool streamlines Ansible workflows by embedding help at the point of use, reducing context-switching and enhancing productivity for sysadmins and DevOps professionals.

CAVEATS

Documentation reflects locally installed Ansible components; incomplete if custom modules/plugins are not in the module path. Requires Ansible collection/module metadata files.

EXAMPLES

ansible-doc -l
List all modules.

ansible-doc setup
Full docs for 'setup' module.

ansible-doc -s apt
Snippet for 'apt' module parameters.

ansible-doc -t connection paramiko_ssh
Docs for connection plugin.

HISTORY

Introduced with Ansible 0.9 in 2012 by Michael DeHaan as part of core CLI tools; evolved with Ansible 2.x/ansible-core to support collections, plugins, and typed documentation.

SEE ALSO

ansible(1), ansible-playbook(1), ansible-config(1)

Copied to clipboard