-
Notifications
You must be signed in to change notification settings - Fork 0
/
advanced-templates.yml
52 lines (43 loc) · 1.21 KB
/
advanced-templates.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
# Various ansible advanced or lesser used tips & tricks
#
# Consider deleting this file and using Google Doc as master
#
vars_prompt:
- name: test
prompt: "Password?"
private: true
tasks:
- name: smoke test for port
wait_for:
state: drained
port: 22
delegate_to: localhost
- name: Add host dynamcially
add_host:
- name: async and poll
async:
poll:
- name: loop with _control & _var
loop:
- name: cmd _when & register
ansible.builtin.command: 'run_this'
changed_when: "run_this_stdout.rc == 1"
failed_when: "run_this_stdout.rc > 1"
register: "run_this_stdout"
- name: smoke test check for http
ansible.builtin.uri:
url: http://localhost/myapp
return_content: yes
register: result
until: '"Hello World" in result.content'
retries: 10
delay: 1
- name: example to validate vars or values, plus when positioning
when: my_param is defined
ansible.builtin.assert:
that:
- my_param <= 100
- my_param >= 0
fail_msg: "'my_param' must be between 0 and 100"
success_msg: "'my_param' is between 0 and 100"