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 galaxy have their own usage documentation. More information: https://docs.ansible.com/ansible/latest/cli/ansible.html.

ansible {{group}} --list-hosts

ansible {{group}} {{[-m|--module-name]}} ping

ansible {{group}} {{[-m|--module-name]}} setup

ansible {{group}} {{[-m|--module-name]}} command {{[-a|--args]}} '{{my_command}}'

ansible {{group}} {{[-b|--become]}} --ask-become-pass {{[-m|--module-name]}} command {{[-a|--args]}} '{{my_command}}'

ansible {{group}} {{[-i|--inventory]}} {{inventory_file}} {{[-m|--module-name]}} command {{[-a|--args]}} '{{my_command}}'

ansible localhost {{[-m|--module-name]}} debug {{[-a|--args]}} '{{var=groups.keys()}}'