ansible-inventory(1)

πŸ’… ansible-inventory(1) β€” the girlies' guide to peeking at your inventory

okay so bestie, welcome to ansible-inventory, part of the system administration commands squad. this little icon shows you Ansible inventory information, and by default it gives you the inventory script JSON format. no cap, it's giving "let me see what Ansible actually thinks you configured" ✨


✨ SYNOPSIS ✨

usage: ansible-inventory [-h] [--version] [-v] [-i INVENTORY] [-l SUBSET]
       [--flush-cache] [--vault-id VAULT_IDS] [-J |
       --vault-password-file VAULT_PASSWORD_FILES] [--playbook-dir BASEDIR]
       [-e EXTRA_VARS] [--list] [--host HOST] [--graph] [-y] [--toml] [--vars]
       [--export] [--output OUTPUT_FILE] [group]

πŸ¦‹ DESCRIPTION πŸ¦‹

it's literally used to display or dump the configured inventory exactly as Ansible sees it. that's the whole vibe. 🫢


πŸŽ€ COMMON OPTIONS πŸŽ€

  • group β€” the name of a group in the inventory, relevant when using --graph. she's the positional argument, she's main character energy πŸ‘‘
  • --export β€” when you're doing --list, represent the inventory in a way that's optimized for export, not as an accurate representation of how Ansible has actually processed it. so like, pretty for shipping, not for truth-telling πŸ™ˆ
  • --flush-cache β€” clear the fact cache for every host in inventory. bye bye cached facts πŸ’€
  • --graph β€” create an inventory graph! if you're supplying a pattern it must be a valid group name. it will ignore limit. periodt.
  • --host 'HOST' β€” output specific host info, works as an inventory script. it will ignore limit. very "just this one host bestie" πŸ“
  • --list β€” output all hosts info, works as an inventory script. the full cast list 🌈
  • --output 'OUTPUT_FILE' β€” when you're doing --list, send the inventory to a file instead of to the screen. lowkey tidy of you πŸ’…
  • --playbook-dir 'BASEDIR' β€” since this tool does not use playbooks, use this as a substitute playbook directory. this sets the relative path for many features including roles/, group_vars/, etc. it's giving "pretend playbook lives here" 🧚
  • --toml β€” use TOML format instead of the default JSON. ignored for --graph. she only shows up when she's invited ✨
  • --vars β€” add vars to the graph display, ignored unless used with --graph. no graph, no vars, that's the rule πŸŽ€
  • --vault-id β€” the vault identity to use. this argument may be specified multiple times. stack 'em πŸ’œ
  • --vault-password-file, --vault-pass-file β€” vault password file. that's it, that's the tweet πŸ”
  • --version β€” show program's version number, config file location, configured module search path, module location, executable location, and then exit. the full selfie dump πŸ“Έ
  • -J, --ask-vault-password, --ask-vault-pass β€” ask for the vault password. she will prompt you, bestie πŸ™ˆ
  • -e, --extra-vars β€” set additional variables as key=value or YAML/JSON, and if it's a filename, prepend with @. this argument may be specified multiple times. go off, add all the vars πŸ”₯
  • -h, --help β€” show this help message and exit. the classic escape hatch πŸ’–
  • -i, --inventory, --inventory-file β€” specify inventory host path or comma separated host list. this argument may be specified multiple times. yup, multiple times, she said what she said πŸ‘‘
  • -l 'SUBSET', --limit 'SUBSET' β€” further limit selected hosts to an additional pattern. narrowing it down, very selective of you ⭐
  • -v, --verbose β€” causes Ansible to print more debug messages. adding multiple -v will increase the verbosity, the builtin plugins currently evaluate up to -vvvvvv. a reasonable level to start is -vvv, connection debugging might require -vvvv. this argument may be specified multiple times. the way that -v just keeps giving 😭
  • -y, --yaml β€” use YAML format instead of the default JSON. ignored for --graph. yaml girlies rise 🌸

🧚 ARGUMENTS 🧚

group

the name of a group in the inventory, relevant when using --graph. yes, we said it twice, because the manpage said it twice and we don't gatekeep. πŸ’«


🌸 INVENTORY 🌸

Ansible stores the hosts it can potentially operate on in an inventory. this can be a YAML file, ini-like file, a script, directory, list, etc. β€” she's flexible like that πŸ¦‹

for additional options, see the documentation on <https://docs.ansible.com/>.


πŸ’œ ENVIRONMENT πŸ’œ

the following environment variables may be specified:

  • ANSIBLE_INVENTORY β€” override the default ansible inventory sources πŸŽ€
  • ANSIBLE_CONFIG β€” specify an override location for the ansible config file ✨

many more are available for most options in ansible.cfg.

for a full list check <https://docs.ansible.com/>, or use the ansible-config command. iykyk πŸ’…


πŸ“ FILES πŸ“

  • /etc/ansible/hosts β€” default inventory file
  • /etc/ansible/ansible.cfg β€” config file, used if present
  • ~/.ansible.cfg β€” user config file, overrides the default config if present
  • ./ansible.cfg β€” local config file (in current working directory), assumed to be 'project specific' and overrides the rest if present.

as mentioned above, the ANSIBLE_CONFIG environment variable will override all others. she's the final boss πŸ‘‘


πŸ‘‘ AUTHOR πŸ‘‘

Ansible was originally written by Michael DeHaan. legend behavior, honestly 🫢


Copyright Β© 2018 Red Hat, Inc | Ansible. Ansible is released under the terms of the GPLv3 license.


⭐ SEE ALSO ⭐

ansible (1), ansible-config (1), ansible-console (1), ansible-doc (1), ansible-galaxy (1), ansible-playbook (1), ansible-pull (1), ansible-vault (1)

extensive documentation is available in the documentation site: <<https://docs.ansible.com>>. IRC and mailing list info can be found in file CONTRIBUTING.md, available in: <<https://github.com/ansible/ansible>>


okay that's the whole page bestie, no notes πŸ’– this was Ansible 2.22.0, ansible-inventory(1) β€” go forth and dump that inventory, you absolute icon 🌈✨

πŸ“¦ where this page comes from
  • arch rolling: ansible-core 2.22.0-1 Β· GPL-3.0-or-later AND BSD-2-Clause AND PSF-2.0 AND MIT AND Apache-2.0
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms