ansible commands
56 commands, each with a one-line explanation. Click a command to copy it, or its title for details.
Commands 56 shown
-
ansible-playbook -i inventory/prod playbook.yml --diffRun playbook with diff output to see what changes
-
ansible-playbook -i inventory playbook.yml --limit host1,host2Run only against specific hosts from inventory
-
ansible-playbook -i inventory playbook.yml --tags install,configureExecute only tasks matching these tags
-
ansible-playbook -i inventory playbook.yml --skip-tags cleanupSkip tasks with the specified tags
-
ansible-playbook -i inventory playbook.yml --check --diffSimulate execution without making changes
-
ansible all -i inventory -m pingCheck connectivity to all hosts in inventory
-
ansible all -i inventory -m shell -a 'uptime'Run a one-liner shell command on all hosts
-
ansible all -i inventory -m copy -a 'src=./file dest=/tmp/file'Copy a file to all hosts
-
ansible <host> -i inventory -m setup | jq '._ansible_facts'Collect all Ansible facts (OS, CPU, network) from a host
-
ansible-vault encrypt_string 'secret_value' --name 'db_password'Inline-encrypt a string for use in playbooks
-
ansible-vault encrypt vars/secrets.ymlEncrypt an entire variable file with Ansible Vault
-
ansible-vault decrypt vars/secrets.ymlDecrypt an Ansible Vault-encrypted file in place
-
ansible-vault view vars/secrets.ymlView contents of vault-encrypted file without decrypting on disk
-
ansible-galaxy install -r requirements.yml -p roles/Download roles listed in requirements.yml to local roles dir
-
ansible-galaxy collection install community.kubernetesInstall an Ansible collection from Ansible Galaxy
-
ansible-inventory -i inventory --list | jq 'keys'Show all hosts and groups parsed from inventory
-
ansible-playbook playbook.yml -e 'env=prod version=2.0'Pass extra variables at runtime overriding playbook defaults
-
ansible-playbook playbook.yml -vvvMaximum verbosity — shows every task, connection, output
-
ansible-playbook playbook.yml --syntax-checkValidate YAML syntax without executing any tasks
-
ansible all -m ping -i inventory.iniCheck SSH connectivity and Python for all hosts
-
ansible webservers -m shell -a 'uptime && free -h' -i inventory.iniRun a shell command on all hosts in the webservers group
-
ansible <host> -m setup -i inventory.ini | jq '.ansible_facts | {os: .ansible_distribution, mem: .ansible_memtotal_mb}'Collect and filter Ansible facts for a single host
-
ansible-playbook site.yml --check --diff -i inventory.iniShow what would change without making any modifications
-
ansible-playbook deploy.yml -e 'env=prod version=2.1.0' -i inventory.iniOverride variables from the command line
-
ansible-playbook site.yml --limit 'web-01,web-02' -i inventory.iniRun playbook only on specified hosts
-
ansible-playbook site.yml --tags 'config,restart' -i inventory.iniExecute only tasks marked with specified tags
-
ansible-playbook site.yml --skip-tags 'slow,optional' -i inventory.iniSkip tasks with specified tags
-
ansible-playbook site.yml -vvv -i inventory.ini 2>&1 | tee /tmp/ansible.logMaximum verbosity for debugging; save to log
-
ansible-vault encrypt_string 'supersecret' --name 'db_password'Inline-encrypt a value for use in playbook vars
-
ansible-vault view group_vars/all/vault.ymlDisplay decrypted content of a vault-encrypted file
-
ansible all -m copy -a 'src=./nginx.conf dest=/etc/nginx/nginx.conf owner=root mode=0644' -i inventory.iniPush a local file to all hosts with specific permissions
-
ansible webservers -m service -a 'name=nginx state=restarted' -b -i inventory.iniAd-hoc service restart with privilege escalation (-b)
-
ansible-inventory -i inventory.ini --graphDisplay inventory group hierarchy as a tree
-
molecule test -s defaultRun full Molecule test suite: create, converge, verify, destroy
-
ansible all -i inventory.ini -m pingVerify SSH connectivity to all hosts in inventory
-
ansible webservers -i inventory.ini -m shell -a 'df -h' -bExecute a shell command on all webservers with sudo (-b)
-
ansible myhost -i inventory.ini -m setup | jq '.ansible_facts.ansible_distribution'Collect and inspect Ansible facts for one host
-
ansible-playbook site.yml -i inventory.ini --tags 'nginx,ssl'Execute only tasks tagged nginx or ssl
-
ansible-playbook site.yml -i inventory.ini --skip-tags 'slow,optional'Skip tasks tagged slow or optional
-
ansible-vault encrypt_string 'mysecretpassword' --name 'db_password'Inline-encrypt a single string value for use in vars
-
ansible-playbook deploy.yml -i inventory.ini --limit 'web01,web02'Run playbook only on web01 and web02
-
ansible-playbook site.yml -i inventory.ini --stepConfirm each task before execution (debug mode)
-
ansible-vault rekey vault.yml --new-vault-password-file new_pass.txtRe-encrypt vault with a new password without exposing plaintext; rotate secrets safely
-
ansible-playbook site.yml --vault-id dev@dev_pass.txt --vault-id prod@promptMix vault IDs: file for dev, interactive prompt for prod; lets you stage secrets per env
-
EDITOR=vim ansible-vault edit group_vars/prod/secrets.yml --vault-password-file ~/.vault_passDecrypt, edit in $EDITOR, re-encrypt atomically — never writes plaintext to disk
-
ansible-inventory -i aws_ec2.yml --graph --varsRender dynamic cloud inventory tree with host vars; verify plugin grouping before a run
-
ansible-inventory -i aws_ec2.yml --list --yaml > resolved_inventory.ymlMaterialize a dynamic inventory to static YAML for diffing or offline debugging
-
plugin: constructed keyed_groups: - key: tags.Role prefix: role - key: placement.region prefix: regionAuto-build host groups from facts/tags via constructed plugin; e.g. role_web, region_eu
-
molecule init role my_role --driver-name docker && cd my_role && MOLECULE_DISTRO=ubuntu2204 molecule createScaffold a role with a Molecule scenario; MOLECULE_DISTRO picks the test image
-
molecule converge && molecule verifyApply the role to the test instance, then run assertions (testinfra/ansible verifiers)
-
molecule idempotenceRe-run the role and fail if any task reports changed — catches non-idempotent tasks
-
molecule login --host instanceSSH into a live Molecule test container to inspect state mid-scenario before destroy
-
ansible-playbook site.yml --start-at-task "Deploy app config"Skip everything before a named task; resume a failed long playbook without redoing setup
-
ansible-playbook site.yml --list-tasks --list-hosts -i prodPreview execution plan: every task and resolved target host, without connecting
-
ANSIBLE_CALLBACKS_ENABLED=profile_tasks ansible-playbook site.ymlRank tasks by wall-clock time to find the slow steps; profile_roles is the per-role variant
-
ANSIBLE_KEEP_REMOTE_FILES=1 ansible-playbook site.yml -vvvv --limit <host>Preserve pushed module scripts under ~/.ansible/tmp to debug a failing module by hand
no commands match — try a different search