blob: aa5d49a2f94b2bf509a2a52005da5114cb414b87 (
plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
- name: register basic session with consul
consul_session:
name: session1
register: basic_result
- name: verify basic session registration
assert:
that:
- basic_result.changed
- basic_result.session_id | length == 36
- basic_result.name == 'session1'
- name: add checks for session health check
consul:
check_name: session_check
script: /bin/true
interval: 1
- pause: seconds=2
- name: register a session with check
consul_session:
name: session_with_check
checks:
- session_check
register: with_check
- name: verify basic session registration
assert:
that:
- with_check.changed
- with_check.session_id | length == 36
- with_check.name == 'session_with_check'
- with_check.checks == ['session_check']
- name: register a session with lock_delay
consul_session:
name: session_with_delay
delay: 20
register: with_delay
- name: verify registration of session with delay
assert:
that:
- with_delay.changed
- with_delay.session_id | length == 36
- with_delay.name == 'session_with_delay'
- with_delay.delay == "20"
- name: retrieve session by id
consul_session: id='{{with_delay.session_id}}' state=info
register: retrieved_by_id
- name: verify retrieval by id
assert:
that:
- with_delay.session_id == retrieved_by_id.sessions[1].ID
- name: retrieve sessions by id
consul_session: state=list
register: retrieved_by_list
- name: verify retrieval by list
assert:
that:
- 3 <= retrieved_by_list.sessions[0]
- name: remove sessions
consul_session: id='{{basic_result.session_id}}' state=absent
- consul_session: id='{{with_check.session_id}}' state=absent
- consul_session: id='{{with_delay.session_id}}' state=absent
- name: remove check
consul:
check_name: session_check
state: absent
|