GPT-OSS additions
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
## Ad-Hoc Commands
|
||||
# Ad‑hoc Commands
|
||||
|
||||
**Problem** – “I need to run a quick check or command on a host without writing a full playbook.”
|
||||
|
||||
**Solution** – Use the `ansible` command with the `-m` (module) option.
|
||||
|
||||
| Use‑case | Command | What it does |
|
||||
|----------|---------|--------------|
|
||||
| Ping a host | `ansible host1 -m ping` | Verifies connectivity. |
|
||||
| List services | `ansible host1 -m shell -a 'systemctl list-units --type=service'` | Executes a shell command. |
|
||||
| Gather facts | `ansible all -m setup` | Collects system information. |
|
||||
| Run playbook file only | `ansible-playbook site.yml` | Executes the full playbook. |
|
||||
|
||||
**Example – Quick package check**
|
||||
|
||||
```bash
|
||||
ansible all -m ping
|
||||
ansible all -m command -a "uptime"
|
||||
ansible webserver -m apt -a "name=vim state=present"
|
||||
ansible web2 -m yum -a "name=nginx state=latest"
|
||||
```
|
||||
|
||||
Ansible is ideal for orchestrating infrastructure as code across cloud, on-premise, and hybrid environments.
|
||||
|
||||
---
|
||||
> **Tip** – Add `-vv` for verbose output to see command execution details.
|
||||
|
||||
Reference in New Issue
Block a user