mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
227 lines
5.3 KiB
YAML
227 lines
5.3 KiB
YAML
10 years ago
|
- name: cleanup any previous failed runs
|
||
|
consul:
|
||
|
service_id: '{{item}}'
|
||
|
state: absent
|
||
|
with_items:
|
||
|
- service1
|
||
|
- service2
|
||
8 years ago
|
- service3
|
||
9 years ago
|
- http_check
|
||
10 years ago
|
- with_check
|
||
|
- with_tags
|
||
|
|
||
9 years ago
|
- name: cleanup previous checks
|
||
|
consul:
|
||
|
check_id: '{{item}}'
|
||
|
state: absent
|
||
9 years ago
|
with_items:
|
||
9 years ago
|
- node_level
|
||
|
- node_level_http
|
||
|
|
||
10 years ago
|
- name: register very basic service with consul gets default id
|
||
|
consul:
|
||
|
service_name: service1
|
||
|
service_port: 80
|
||
|
register: basic_result
|
||
|
|
||
|
- name: verify basic service registration
|
||
|
assert:
|
||
|
that:
|
||
|
- basic_result.changed
|
||
|
- basic_result.service_port == 80
|
||
|
- basic_result.service_id == 'service1'
|
||
|
- basic_result.service_name == 'service1'
|
||
|
|
||
|
- name: register very basic service with explicit id
|
||
|
consul:
|
||
|
service_name: Basic Service
|
||
|
service_id: service2
|
||
|
service_port: 80
|
||
|
register: basic2_result
|
||
|
|
||
|
- name: verify service2 registration
|
||
|
assert:
|
||
|
that:
|
||
|
- basic2_result.changed
|
||
|
- basic2_result.service_port == 80
|
||
|
- basic2_result.service_id == 'service2'
|
||
|
- basic2_result.service_name == 'Basic Service'
|
||
|
|
||
7 years ago
|
- name: register service without name
|
||
|
consul:
|
||
|
service_id: this_will_fail
|
||
|
register: noname_result
|
||
|
ignore_errors: True
|
||
|
|
||
|
- name: verify registering service without name fails
|
||
|
assert:
|
||
|
that:
|
||
|
- noname_result | failed
|
||
|
|
||
8 years ago
|
- name: register very basic service without service_port
|
||
|
consul:
|
||
|
service_name: Basic Service Without Port
|
||
|
service_id: service3
|
||
|
register: basic3_result
|
||
|
|
||
|
- name: verify service3 registration
|
||
|
assert:
|
||
|
that:
|
||
|
- basic3_result.changed
|
||
|
- basic3_result.service_port == None
|
||
|
- basic3_result.service_id == 'service3'
|
||
|
- basic3_result.service_name == 'Basic Service Without Port'
|
||
|
|
||
9 years ago
|
- name: register a service with an http check
|
||
|
consul:
|
||
|
service_name: http_check
|
||
|
service_id: http_check
|
||
|
service_port: 80
|
||
|
http: "http://localhost/status"
|
||
|
interval: 60s
|
||
|
register: http_result
|
||
|
|
||
|
- name: verify service with an http check
|
||
|
assert:
|
||
|
that:
|
||
|
- http_result.changed
|
||
|
- http_result.service_port == 80
|
||
|
- http_result.checks | length == 1
|
||
|
|
||
10 years ago
|
- name: register very basic service with check script
|
||
|
consul:
|
||
|
service_name: with_check
|
||
|
service_port: 80
|
||
|
script: "sh -c true"
|
||
9 years ago
|
interval: 60s
|
||
10 years ago
|
register: script_result
|
||
|
|
||
|
- name: verify service with check registration
|
||
|
assert:
|
||
|
that:
|
||
|
- script_result.changed
|
||
|
- script_result.service_port == 80
|
||
|
- script_result.service_id == 'with_check'
|
||
|
- script_result.checks | length == 1
|
||
|
|
||
|
- name: register service with some service tags
|
||
|
consul:
|
||
|
service_name: with_tags
|
||
|
service_port: 80
|
||
|
tags:
|
||
|
- prod
|
||
|
- webservers
|
||
|
register: tags_result
|
||
|
|
||
|
|
||
|
- name: verify tags registration
|
||
|
assert:
|
||
|
that:
|
||
|
- tags_result.changed
|
||
|
- "tags_result.tags == ['prod', 'webservers']"
|
||
|
|
||
|
- name: create a node level check
|
||
|
consul:
|
||
|
check_name: Node Level Check
|
||
|
check_id: node_level
|
||
|
script: "sh -c true"
|
||
|
interval: 50m
|
||
|
register: nodelevel_result
|
||
|
|
||
|
- name: verify service with check registration
|
||
|
assert:
|
||
|
that:
|
||
|
- nodelevel_result.changed
|
||
|
- nodelevel_result.check_name == 'Node Level Check'
|
||
|
- nodelevel_result.check_id == 'node_level'
|
||
|
- nodelevel_result.script == 'sh -c true'
|
||
|
- nodelevel_result.interval == '50m'
|
||
|
|
||
9 years ago
|
- name: create a node level http check
|
||
|
consul:
|
||
|
check_name: Node Level HTTP Check
|
||
|
check_id: node_level_http
|
||
|
http: 'http://localhost/status'
|
||
|
interval: 1m
|
||
|
timeout: 30s
|
||
|
register: nodelevel_http_result
|
||
|
|
||
|
- name: verify node level http check
|
||
|
assert:
|
||
|
that:
|
||
|
- nodelevel_http_result.changed
|
||
|
- nodelevel_http_result.check_name == 'Node Level HTTP Check'
|
||
|
- nodelevel_http_result.check_id == 'node_level_http'
|
||
|
- nodelevel_http_result.http == 'http://localhost/status'
|
||
|
- nodelevel_http_result.interval == '1m'
|
||
|
- nodelevel_http_result.timeout == '30s'
|
||
|
|
||
10 years ago
|
- name: remove a service
|
||
|
consul:
|
||
|
service_id: 'service1'
|
||
|
state: absent
|
||
|
register: delete_service_result
|
||
|
|
||
|
- name: verify service removal
|
||
|
assert:
|
||
|
that:
|
||
|
- delete_service_result.changed
|
||
|
|
||
8 years ago
|
- name: removal of an non-existent service causes no change
|
||
10 years ago
|
consul:
|
||
|
service_id: 'service1'
|
||
|
state: absent
|
||
|
register: delete_service_result
|
||
|
|
||
|
- name: verify service removal caused no change
|
||
|
assert:
|
||
|
that:
|
||
|
- not delete_service_result.changed
|
||
|
|
||
|
- name: remove a check
|
||
|
consul:
|
||
|
check_id: 'node_level'
|
||
|
state: absent
|
||
|
register: delete_check_result
|
||
|
|
||
|
- name: verify check removal
|
||
|
assert:
|
||
|
that:
|
||
|
- delete_check_result.changed
|
||
|
|
||
8 years ago
|
- name: removal of an non-existent check causes no change
|
||
10 years ago
|
consul:
|
||
|
check_id: 'node_level'
|
||
|
state: absent
|
||
|
register: delete_check_result
|
||
|
|
||
|
- name: verify check removal cause no change
|
||
|
assert:
|
||
|
that:
|
||
|
- not delete_service_result.changed
|
||
|
|
||
|
- name: add service to test removal by name
|
||
|
consul:
|
||
|
service_name: by_name
|
||
|
service_port: 12345
|
||
|
|
||
|
- name: remove service by name
|
||
|
consul:
|
||
|
service_name: by_name
|
||
|
state: absent
|
||
|
register: delete_service_by_name_result
|
||
|
|
||
|
- name: verify service removal
|
||
|
assert:
|
||
|
that:
|
||
|
- delete_service_by_name_result.changed
|
||
|
|
||
|
- name: cleanup
|
||
|
consul:
|
||
|
service_id: '{{item}}'
|
||
|
state: absent
|
||
|
with_items:
|
||
|
- service2
|
||
|
- with_check
|
||
|
- with_tags
|