2016-11-23 11:29:38 +00:00
|
|
|
# ansible
|
|
|
|
|
2021-09-13 09:21:21 +01:00
|
|
|
> 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.
|
2019-06-03 01:06:36 +01:00
|
|
|
> More information: <https://www.ansible.com/>.
|
2016-11-23 11:29:38 +00:00
|
|
|
|
|
|
|
- List hosts belonging to a group:
|
|
|
|
|
|
|
|
`ansible {{group}} --list-hosts`
|
|
|
|
|
2024-02-09 14:34:08 +00:00
|
|
|
- Ping a group of hosts by invoking the ping [m]odule:
|
2016-11-23 11:29:38 +00:00
|
|
|
|
|
|
|
`ansible {{group}} -m ping`
|
|
|
|
|
2024-02-09 14:34:08 +00:00
|
|
|
- Display facts about a group of hosts by invoking the setup [m]odule:
|
2016-11-23 11:29:38 +00:00
|
|
|
|
|
|
|
`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}}'`
|
2021-04-15 19:30:12 +01:00
|
|
|
|
|
|
|
- List the groups in an inventory:
|
|
|
|
|
|
|
|
`ansible localhost -m debug -a '{{var=groups.keys()}}'`
|