2024-10-25 21:35:23 +08:00
|
|
|
- WSL Fix for world-writable directories
|
2024-10-25 15:54:40 +08:00
|
|
|
```bash
|
|
|
|
export ANSIBLE_CONFIG=./ansible.cfg
|
|
|
|
```
|
2024-10-25 21:35:23 +08:00
|
|
|
- Ping
|
2024-10-25 15:57:44 +08:00
|
|
|
```bash
|
|
|
|
ansible all -m ping
|
|
|
|
```
|
2024-10-25 21:35:23 +08:00
|
|
|
- Gather facts
|
2024-10-25 15:56:43 +08:00
|
|
|
```bash
|
2024-10-25 15:57:44 +08:00
|
|
|
ansible all -m gather_facts
|
|
|
|
|
|
|
|
# Limit to one device
|
|
|
|
ansible all -m gather_facts --limit ADDRESS
|
2024-10-25 16:07:45 +08:00
|
|
|
```
|
2024-10-25 21:35:23 +08:00
|
|
|
- Elevate command to root user
|
2024-10-25 16:07:45 +08:00
|
|
|
```bash
|
|
|
|
# This will fail without sudo
|
|
|
|
ansible all -m apt -a update_cache=true
|
|
|
|
|
|
|
|
# This will succeed
|
2024-10-25 16:07:55 +08:00
|
|
|
# Equivalent to sudo apt-update
|
|
|
|
ansible all -m apt -a update_cache=true --become --ask-become-me-pass
|
2024-10-25 16:11:48 +08:00
|
|
|
```
|
2024-10-25 21:35:23 +08:00
|
|
|
- Install packages
|
2024-10-25 16:11:48 +08:00
|
|
|
```bash
|
|
|
|
ansible all -m apt -a name=vim --become --ask-become-pass
|
2024-10-25 16:21:38 +08:00
|
|
|
```
|
2024-10-25 21:35:23 +08:00
|
|
|
- Install/Update Package (multiple arguments)
|
2024-10-25 16:21:38 +08:00
|
|
|
```bash
|
2024-10-25 16:22:30 +08:00
|
|
|
ansible all -m apt -a "name=vim state=latest" --become --ask-become-pass
|
2024-10-25 16:30:38 +08:00
|
|
|
```
|
2024-10-25 21:35:23 +08:00
|
|
|
- `sudo apt update` equivalent
|
2024-10-25 16:30:38 +08:00
|
|
|
```bash
|
|
|
|
ansible all -m apt -a "name=apt state=latest" --become --ask-become-pass
|
2024-10-25 15:56:43 +08:00
|
|
|
```
|