Ping all hosts (ad-hoc)

Check SSH access and Python on all hosts

ansible all -m ping -i inventory.ini

tool
ansible56 commands
tags
ansible

More ansible commands

  • ansible webservers -m shell -a 'uptime && free -h' -i inventory.ini

    Run 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 Ansible facts for one host and keep only the OS and memory

  • ansible-playbook site.yml --check --diff -i inventory.ini

    Show what would change, with diffs, without changing anything

  • ansible-playbook deploy.yml -e 'env=prod version=2.1.0' -i inventory.ini

    Override variables from the command line

  • ansible-playbook site.yml --limit 'web-01,web-02' -i inventory.ini

    Run the playbook only on the listed hosts

all 56 ansible commands