ansible ad hoc
时间: 2023-09-24 12:10:04 浏览: 117
Ansible ad hoc commands are one-line Ansible tasks that can be run directly from the command line without the need for writing playbooks. Ad hoc commands are useful for executing quick tasks on remote hosts, such as checking the system status, installing packages, or running specific commands.
To run an ad hoc command with Ansible, you can use the `ansible` command followed by the target hosts and the desired module and options. For example, to check the uptime of all hosts in the "web" inventory group:
```
ansible web -m command -a "uptime"
```
Here, `web` is the inventory group containing the target hosts, `-m command` specifies the module to use (in this case, the `command` module), and `-a "uptime"` is the argument passed to the module.
Ad hoc commands provide a quick and easy way to perform tasks without writing complex playbooks. However, for more complex automation and configuration management, it is recommended to use Ansible playbooks.
阅读全文