ansible-console(1)

πŸ’… ansible-console β€” the REPL bestie (System administration commands, ansible-console(1))

okay so picture this: you want to run ad-hoc Ansible tasks but you also want a cute little shell with tab completion. that's her. she's ansible-console, and honestly? she ate. ✨

🌸 SYNOPSIS

usage: ansible-console [-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] [--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]
       [--vault-id VAULT_IDS] [-J | --vault-password-file
       VAULT_PASSWORD_FILES] [-f FORKS] [-M MODULE_PATH] [--playbook-dir
       BASEDIR] [-e EXTRA_VARS] [--task-timeout TASK_TIMEOUT] [--step]
       [pattern]

πŸ¦‹ DESCRIPTION

It's a REPL β€” a read-eval-print loop, bestie β€” that lets you run ad-hoc tasks against an inventory of your choosing, from a genuinely nice shell with built-in tab completion. (Fun fact she's based on dominis' ansible-shell. credit where it's due πŸ’–)

She supports a bunch of commands, and you can change her config at runtime β€” main character energy fr:

  • cd [pattern] β€” change host/group. and yes you can use host patterns, like app*.dc*:!app01* πŸ‘‘
  • list β€” list the available hosts in your current path
  • list groups β€” list the groups included in the current path
  • become β€” toggle the become flag
  • ! β€” forces the shell module instead of the ansible module (!yum update -y)
  • verbosity [num] β€” set the verbosity level
  • forks [num] β€” set the number of forks
  • become_user [user] β€” set the become_user
  • remote_user [user] β€” set the remote_user
  • become_method [method] β€” set the privilege escalation method
  • check [bool] β€” toggle check mode
  • diff [bool] β€” toggle diff mode
  • timeout [integer] β€” set the timeout of tasks in seconds (0 to disable)
  • help [command/module] β€” display documentation for that command or module πŸŽ€
  • exit β€” exit ansible-console. sad but slay πŸ’…

✨ COMMON OPTIONS ✨

  • host pattern β€” the positional thingy, she's listed down in ARGUMENTS bestie 🫢
  • --become-method 'BECOME_METHOD' β€” the privilege escalation method to use (default=sudo). run ansible-doc -t become -l to see all the valid choices.
  • --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 the inventory. bye facts πŸ‘‹
  • --list-hosts β€” outputs a list of matching hosts; does not execute anything else
  • --playbook-dir 'BASEDIR' β€” since this tool doesn't use playbooks, you use this as a substitute playbook directory. it sets the relative path for lots of features, including roles/, group_vars/, etc.
  • --private-key 'PRIVATE_KEY_FILE', --key-file 'PRIVATE_KEY_FILE' β€” use this file to authenticate the connection
  • --scp-extra-args 'SCP_EXTRA_ARGS' β€” extra args to pass to scp only (e.g. -l)
  • --sftp-extra-args 'SFTP_EXTRA_ARGS' β€” extra args to pass to sftp only (e.g. -f, -l)
  • --ssh-common-args 'SSH_COMMON_ARGS' β€” common args to pass to sftp/scp/ssh (e.g. ProxyCommand)
  • --ssh-extra-args 'SSH_EXTRA_ARGS' β€” extra args to pass to ssh only (e.g. -R)
  • --step β€” one-step-at-a-time: confirm each task before running it. very "are you sure bestie" energy
  • --task-timeout 'TASK_TIMEOUT' β€” set the task timeout limit in seconds; must be a positive integer.
  • --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
  • -C, --check β€” don't make any changes; instead, try to predict some of the changes that may occur
  • -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 the vault password
  • -K, --ask-become-pass β€” ask for the privilege escalation password
  • -M, --module-path β€” prepend colon-separated path(s) to the module library (default={{ ANSIBLE_HOME ~ "/plugins/modules:/usr/share/ansible/plugins/modules" }}). this argument may be specified multiple times.
  • -T 'TIMEOUT', --timeout 'TIMEOUT' β€” override the connection timeout in seconds (the default depends on the connection)
  • -b, --become β€” run operations with become (this does not imply password prompting, jsyk)
  • -c 'CONNECTION', --connection 'CONNECTION' β€” connection type to use (default=ssh)
  • -e, --extra-vars β€” set additional variables as key=value or YAML/JSON; if it's a filename, prepend it with @. this argument may be specified multiple times.
  • -f 'FORKS', --forks 'FORKS' β€” specify the number of parallel processes to use (default=5)
  • -h, --help β€” show this help message and exit
  • -i, --inventory, --inventory-file β€” specify an inventory host path or a comma separated host list. this argument may be specified multiple times.
  • -k, --ask-pass β€” ask for the connection password
  • -l 'SUBSET', --limit 'SUBSET' β€” further limit selected hosts to an additional pattern
  • -u 'REMOTE_USER', --user 'REMOTE_USER' β€” connect as this user (default=None)
  • -v, --verbose β€” causes Ansible to print more debug messages. adding multiple -v increases the verbosity, and the builtin plugins currently evaluate up to -vvvvvv. a reasonable level to start at is -vvv, and connection debugging might require -vvvv. this argument may be specified multiple times.

πŸ’œ ARGUMENTS

  • host-pattern β€” a name of a group in the inventory, a shell-like glob selecting hosts in the inventory, or any combination of the two separated by commas. mix and match, she loves that πŸŽ€

🧚 INVENTORY

Ansible stores all the hosts she can potentially operate on in an inventory. that can be a YAML file, an ini-like file, a script, a directory, a list, etc. for additional options, go look at the docs over at <https://docs.ansible.com/>.

🌈 ENVIRONMENT

these 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 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 just 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 the current working directory), assumed to be "project specific", and overrides the rest if present.
as mentioned up there ⬆️, the ANSIBLE_CONFIG environment variable will override all the others. she's the final boss, no cap πŸ‘‘

🌟 AUTHOR

Ansible was originally written by Michael DeHaan. legend behaviour, 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-doc (1), ansible-galaxy (1), ansible-inventory (1), ansible-playbook (1), ansible-pull (1), ansible-vault (1)

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


and that's the whole page bestie, ily, go run some ad-hoc tasks πŸ’…βœ¨

Ansible 2.22.0 πŸ¦‹ the ansible-console(1) girlies stay winning, mwah πŸ’‹

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