Skip to content

Commit 72db02c

Browse files
committed
add documentation/sample for checkmode
1 parent 9a9c28e commit 72db02c

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Example playbook
2424
### A complete example that ensures a record is present in a given table.
2525

2626
```yaml
27+
2728
---
2829
- hosts: all
2930
roles:
@@ -60,6 +61,7 @@ Thus:
6061
### A complete example that ensures a record is not present in a given table.
6162

6263
```yaml
64+
6365
---
6466
- hosts: all
6567
roles:
@@ -83,3 +85,6 @@ Thus:
8385
Make sure you have a running mysql server (e.g.: use the *docker-compose.yml*-file) and update the connection-parameters if necessary.
8486

8587
Run via `ansible-playbook -i demo.yml` (or even simpler `./demo.yml`) and undo (to start all over) with `ansible-playbook -i reset.yml`.
88+
89+
After running `./demo.yml`, you can run `./checkmode-demo.yml -C` to test ansible's [check mode](https://docs.ansible.com/ansible/latest/user_guide/playbooks_checkmode.html).
90+
Just run `./demo.yml` and `./checkmode-demo.yml` a few times with `-C` and without `-C` to get a feel for it.

examples/checkmode-demo.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env ansible-playbook
2+
---
3+
- hosts: all
4+
gather_facts: no
5+
tasks:
6+
- name: update a row
7+
mysql_query:
8+
name: ansible-playbook-example
9+
table: simple_table
10+
login_host: ::1
11+
login_user: root
12+
login_password: password
13+
identifiers:
14+
identifier1: 4
15+
identifier2: 'eight'
16+
values:
17+
value1: 42
18+
value2: 'myvalue'
19+
defaults:
20+
default1: can be anything, will be ignored for update
21+
default2: will not change
22+
23+
- name: insert a row
24+
mysql_query:
25+
name: ansible-playbook-example
26+
table: simple_table
27+
login_host: ::1
28+
login_user: root
29+
login_password: password
30+
identifiers:
31+
identifier1: 14
32+
identifier2: 'eighteen'
33+
values:
34+
value1: 115
35+
value2: 'one-hundred-sixteen'
36+
defaults:
37+
default1: 125
38+
default2: one-hundred-25

0 commit comments

Comments
 (0)