ansible(1)

ansible(1) πŸ’…βœ¨

okay bestie, listen β€” this is ansible(1), the main character of the Ansible cinematic universe, from the System administration commands family, and I'm gonna walk you through the whole thing. no gatekeeping, no cap. 🫢


✨ Name ✨

ansible β€” define and run a single task 'playbook' against a set of hosts. that's it, that's the vibe. one task, a whole bunch of hosts. slay. πŸ’–


🌸 SYNOPSIS 🌸

usage: ansible [-h] [--version] [-v] [-b] [--become-method
BECOME_METHOD]
       [--become-user BECOME_USER] [-K | --become-password-file
BECOME_PASSWORD_FILE] [-i INVENTORY] [--list-hosts] [-l SUBSET]
       [--flush-cache] [-P POLL_INTERVAL] [-B SECONDS] [-o] [-t TREE]
       [--private-key PRIVATE_KEY_FILE] [-u REMOTE_USER] [-c CONNECTION]
       [-T TIMEOUT] [--ssh-common-args SSH_COMMON_ARGS]
       [--sftp-extra-args SFTP_EXTRA_ARGS] [--scp-extra-args
SCP_EXTRA_ARGS] [--ssh-extra-args SSH_EXTRA_ARGS] [-k |
--connection-password-file CONNECTION_PASSWORD_FILE] [-C] [-D]
       [-e EXTRA_VARS] [--vault-id VAULT_IDS] [-J |
--vault-password-file VAULT_PASSWORD_FILES] [-f FORKS] [-M
MODULE_PATH] [--playbook-dir BASEDIR] [--task-timeout
TASK_TIMEOUT] [-a MODULE_ARGS] [-m MODULE_NAME] pattern

like yes it's a lot of brackets but that's just how it eats. πŸ“


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically: ansible is an extra-simple tool/framework/API for doing 'remote things'. lowercase, iconic, humble-ish. and this specific command lets you define and run a single task 'playbook' against a set of hosts β€” one task, live, right there in your terminal. it's giving main character energy, honestly. πŸ‘‘


πŸ’… COMMON OPTIONS πŸ’…

okay this is the long part, but you got this. every single one, in order, no skipping. ✨

  • host pattern β€” your host pattern. the thing you're pointing at. 🎯
  • --become-method 'BECOME_METHOD' β€” the privilege escalation method to use (default=sudo). run ansible-doc -t become -l to list all the valid choices, iykyk.
  • --become-password-file 'BECOME_PASSWORD_FILE', --become-pass-file 'BECOME_PASSWORD_FILE' β€” become password file.
  • --become-user 'BECOME_USER' β€” run operations as this user (default=root).
  • --connection-password-file 'CONNECTION_PASSWORD_FILE', --conn-pass-file 'CONNECTION_PASSWORD_FILE' β€” connection password file.
  • --flush-cache β€” clear the fact cache for every host in inventory. yeet the cached facts. 🧹
  • --list-hosts β€” outputs a list of matching hosts; does not execute anything else. it's literally just "who would be affected", that's all. πŸ‘€
  • --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. fake playbook dir, real functionality. 🎭
  • --private-key 'PRIVATE_KEY_FILE', --key-file 'PRIVATE_KEY_FILE' β€” use this file to authenticate the connection.
  • --scp-extra-args 'SCP_EXTRA_ARGS' β€” specify extra arguments to pass to scp only (e.g. -l).
  • --sftp-extra-args 'SFTP_EXTRA_ARGS' β€” specify extra arguments to pass to sftp only (e.g. -f, -l).
  • --ssh-common-args 'SSH_COMMON_ARGS' β€” specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand).
  • --ssh-extra-args 'SSH_EXTRA_ARGS' β€” specify extra arguments to pass to ssh only (e.g. -R).
  • --task-timeout 'TASK_TIMEOUT' β€” set the task timeout limit in seconds, must be a positive integer. no zero, no negatives, no vibes-based numbers. ⏰
  • --vault-id β€” the vault identity to use. this argument may be specified multiple times. πŸ”
  • --vault-password-file, --vault-pass-file β€” vault password file.
  • --version β€” show the program's version number, config file location, configured module search path, module location, executable location, and exit. a whole info dump, honestly kind of a flex. πŸ“‹
  • -B 'SECONDS', --background 'SECONDS' β€” run asynchronously, failing after X seconds (default=N/A).
  • -C, --check β€” don't make any changes; instead, try to predict some of the changes that may occur. window shopping for infra. πŸ›οΈ
  • -D, --diff β€” when changing (small) files and templates, show the differences in those files; works great with --check.
  • -J, --ask-vault-password, --ask-vault-pass β€” ask for vault password.
  • -K, --ask-become-pass β€” ask for privilege escalation password.
  • -M, --module-path β€” prepend colon-separated path(s) to module library (default={{ ANSIBLE_HOME ~ "/plugins/modules:/usr/share/ansible/plugins/modules" }}). this argument may be specified multiple times.
  • -P 'POLL_INTERVAL', --poll 'POLL_INTERVAL' β€” set the poll interval if using -B (default=15).
  • -T 'TIMEOUT', --timeout 'TIMEOUT' β€” override the connection timeout in seconds (default depends on connection).
  • -a 'MODULE_ARGS', --args 'MODULE_ARGS' β€” the action's options in space separated k=v format: -a 'opt1=val1 opt2=val2' or a json string: -a '{"opt1": "val1", "opt2": "val2"}'.
  • -b, --become β€” run operations with become (does not imply password prompting). important clarification bestie, it does NOT prompt you for anything. πŸ™ˆ
  • -c 'CONNECTION', --connection 'CONNECTION' β€” connection type to use (default=ssh).
  • -e, --extra-vars β€” set additional variables as key=value or YAML/JSON, if filename prepend with @. this argument may be specified multiple times.
  • -f 'FORKS', --forks 'FORKS' β€” specify number of parallel processes to use (default=5). five little worker bees by default. 🐝
  • -h, --help β€” show this help message and exit.
  • -i, --inventory, --inventory-file β€” specify inventory host path or comma separated host list. this argument may be specified multiple times.
  • -k, --ask-pass β€” ask for connection password.
  • -l 'SUBSET', --limit 'SUBSET' β€” further limit selected hosts to an additional pattern. narrowing the guest list. πŸ’Œ
  • -m 'MODULE_NAME', --module-name 'MODULE_NAME' β€” name of the action to execute (default=command).
  • -o, --one-line β€” condense output. one line. that's the whole thing.
  • -t 'TREE', --tree 'TREE' β€” log output to this directory.
  • -u 'REMOTE_USER', --user 'REMOTE_USER' β€” connect as this user (default=None).
  • -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. πŸ—£οΈ

🌈 INVENTORY 🌈

Ansible stores the hosts it can potentially operate on in an inventory. this can be a YAML file, an ini-like file, a script, a directory, a list, etc. β€” like, it's flexible, it's fluid. 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_LIBRARY β€” override the default ansible module library path
  • ANSIBLE_CONFIG β€” specify 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. 🌟


πŸŽ€ 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
and as mentioned above, the ANSIBLE_CONFIG environment variable will override all others. it's the final boss of config precedence. πŸ‘‘

πŸ’œ AUTHOR πŸ’œ

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


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


⭐ SEE ALSO ⭐

ansible-config (1), ansible-console (1), ansible-doc (1), ansible-galaxy (1), ansible-inventory (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, you absolute scholar. this one's brought to you by Ansible 2.22.0 β€” that's the version, bestie, and yes, she's iconic. mwah, go run some tasks. πŸ’…βœ¨πŸŽ€

πŸ“¦ 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