Skip to content

Commit 1ab8538

Browse files
authored
mslt
1 parent 81c8e0d commit 1ab8538

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

content/posts/ansible-utils-cmd.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ $ ansible --list-hosts lan
8484

8585
## Run module on specific host or group
8686
e.g.
87+
### Ping all hosts of group wan
8788
```
88-
# ping all hosts of group 'wan'
8989
$ ansible -m ping wan
9090
vm05 | SUCCESS => {
9191
"changed": false,
@@ -95,14 +95,25 @@ vm06 | SUCCESS => {
9595
"changed": false,
9696
"ping": "pong"
9797
}
98-
99-
# execute 'echo world' on host vm01
98+
```
99+
### execute 'echo world' on host vm01
100+
```
100101
$ ansible -m shell -a "echo 'hello world'" vm01
101102
vm01 | CHANGED | rc=0 >>
102103
hello world
103104
104105
```
105106

107+
### Generate a template locally
108+
Very useful for local debug and avoiding additional code in your playbook or task files in role.
109+
```
110+
# Generate the file /tmp/prometheus.yml from template roles/prometheus/templates/prometheus.yml
111+
$ ansible [--vault-password-file=~/.pass.txt] -m template -a "src=roles/prometheus/templates/prometheus.yml dest=/tmp/prometheus.yml" localhost
112+
113+
# Check the generated file locally
114+
$ promtool check config /tmp/prometheus.yml
115+
```
116+
106117
## Encryption/Decryption using ansible-vault
107118
Documentation: https://docs.ansible.com/ansible/latest/cli/ansible-vault.html
108119
### Using vault password file

0 commit comments

Comments
 (0)