2024-10-25 15:54:40 +08:00
|
|
|
WSL Fix for world-writable directories
|
|
|
|
```bash
|
|
|
|
export ANSIBLE_CONFIG=./ansible.cfg
|
|
|
|
```
|
2024-10-25 15:57:44 +08:00
|
|
|
Ping
|
|
|
|
```bash
|
|
|
|
ansible all -m ping
|
|
|
|
```
|
2024-10-25 15:56:43 +08:00
|
|
|
Gather facts
|
|
|
|
```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
|
|
|
```
|
|
|
|
Elevate command to root user
|
|
|
|
```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
|
|
|
```
|
|
|
|
Install packages
|
|
|
|
```bash
|
|
|
|
ansible all -m apt -a name=vim --become --ask-become-pass
|
2024-10-25 16:21:38 +08:00
|
|
|
```
|
|
|
|
Install/Update Packages (multiple arguments)
|
|
|
|
```
|
|
|
|
Install packages
|
|
|
|
```bash
|
|
|
|
ansible all -m apt -a "name=vim,nginx" --become --ask-become-pass
|
2024-10-25 15:56:43 +08:00
|
|
|
```
|