2016-11-23 11:29:38 +00:00
|
|
|
# ansible
|
|
|
|
|
|
|
|
> Manage groups of computers remotely over SSH.
|
|
|
|
> Use the /etc/ansible/hosts file to add new groups/hosts.
|
|
|
|
|
|
|
|
- List hosts belonging to a group:
|
|
|
|
|
|
|
|
`ansible {{group}} --list-hosts`
|
|
|
|
|
|
|
|
- Ping a group of hosts by invoking the ping module:
|
|
|
|
|
|
|
|
`ansible {{group}} -m ping`
|
|
|
|
|
|
|
|
- Display facts about a group of hosts by invoking the setup module:
|
|
|
|
|
|
|
|
`ansible {{group}} -m setup`
|
|
|
|
|
|
|
|
- Execute a command on a group of hosts by invoking command module with arguments:
|
|
|
|
|
2018-10-29 11:14:25 +00:00
|
|
|
`ansible {{group}} -m command -a '{{my_command}}'`
|
2016-11-23 11:29:38 +00:00
|
|
|
|
|
|
|
- Execute a command with administrative privileges:
|
|
|
|
|
2018-10-29 11:14:25 +00:00
|
|
|
`ansible {{group}} --become --ask-become-pass -m command -a '{{my_command}}'`
|
2016-11-23 11:29:38 +00:00
|
|
|
|
|
|
|
- Execute a command using a custom inventory file:
|
|
|
|
|
2018-10-29 11:14:25 +00:00
|
|
|
`ansible {{group}} -i {{inventory_file}} -m command -a '{{my_command}}'`
|