c02f114967
Submission includes support for - creating and registering services and checks - reading, writing and lookup for values in consul's kv store - creating and manipulating sessions for distributed locking on values in the kv - creating and manipulating ACLs for restricting access to the kv store - inventory support that reads the Consul catalog and group nodes according to - datacenters - exposed services - service availability - arbitrary groupings from the kv store This submission makes extensive use of the python-consul library and this is required as a dependency and can be installed from pip. The tests were written to target a vagrant cluster which can be setup by following the instructions here http://github.com/sgargan/consul-vagrant
77 lines
1.8 KiB
YAML
77 lines
1.8 KiB
YAML
- 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: /usr/bin/true
|
|
interval: 15
|
|
|
|
- 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={{item}} state=absent
|
|
with_items:
|
|
- basic_result.session_id
|
|
- with_check.session_id
|
|
- with_delay.session_id
|
|
|
|
- name: remove check
|
|
consul:
|
|
check_name: session_check
|
|
state: absent
|