ansible Command Examples

Manage groups of computers remotely over SSH. (use the /etc/ansible/hosts file to add new groups/hosts). Some subcommands such as ansible galaxy have their own usage documentation. More information: https://www.ansible.com/.

ansible {{group}} --list-hosts

ansible {{group}} -m ping

ansible {{group}} -m setup

ansible {{group}} -m command -a '{{my_command}}'

ansible {{group}} --become --ask-become-pass -m command -a '{{my_command}}'

ansible {{group}} -i {{inventory_file}} -m command -a '{{my_command}}'

ansible localhost -m debug -a '{{var=groups.keys()}}'