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, likeapp*.dc*:!app01*πlistβ list the available hosts in your current pathlist groupsβ list the groups included in the current pathbecomeβ toggle the become flag!β forces the shell module instead of the ansible module (!yum update -y)verbosity [num]β set the verbosity levelforks [num]β set the number of forksbecome_user [user]β set the become_userremote_user [user]β set the remote_userbecome_method [method]β set the privilege escalation methodcheck [bool]β toggle check modediff [bool]β toggle diff modetimeout [integer]β set the timeout of tasks in seconds (0to 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). runansible-doc -t become -lto 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, includingroles/,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 toscponly (e.g.-l)--sftp-extra-args 'SFTP_EXTRA_ARGS'β extra args to pass tosftponly (e.g.-f,-l)--ssh-common-args 'SSH_COMMON_ARGS'β common args to pass tosftp/scp/ssh(e.g.ProxyCommand)--ssh-extra-args 'SSH_EXTRA_ARGS'β extra args to pass tosshonly (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 askey=valueor 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-vincreases 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 sourcesANSIBLE_LIBRARYβ override the default ansible module library pathANSIBLE_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
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