972ebbe5db
Allow deprecation of haproxy endpoints by setting the state of the service to 'absent'. It will also now clean up any config files when there are no backends, or the service is disabled. Change-Id: I1db5932c559b5e04d330c114164869dd43c1cbb2
68 lines
2.0 KiB
YAML
68 lines
2.0 KiB
YAML
---
|
|
# Copyright 2016, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: Playbook for role testing
|
|
hosts: localhost
|
|
connection: local
|
|
user: root
|
|
become: true
|
|
vars_files:
|
|
- test-vars.yml
|
|
tasks:
|
|
- name: Create marker file for idempotence
|
|
copy:
|
|
content: mark
|
|
dest: /tmp/haproxy_pass1
|
|
register: haproxy_pass1
|
|
|
|
- name: Set fact for idempotence test
|
|
set_fact:
|
|
idempotence_pass_1: "{{ haproxy_pass1 is changed }}"
|
|
|
|
- name: Set fact for absent service state
|
|
set_fact:
|
|
absent_service_state: "{{ (haproxy_pass1 is changed) | ternary('present', 'absent') }}"
|
|
|
|
- name: Run the haproxy_server role
|
|
include_role:
|
|
name: "haproxy_server"
|
|
|
|
- name: Run role again on first pass
|
|
when:
|
|
- "idempotence_pass_1 | bool"
|
|
block:
|
|
- name: Ensure the absent service is present
|
|
stat:
|
|
path: "/etc/haproxy/conf.d/test_absent_service"
|
|
register: absent_services
|
|
failed_when: not absent_services.stat.exists
|
|
|
|
- name: Set fact for absent service state
|
|
set_fact:
|
|
absent_service_state: "absent"
|
|
|
|
- name: Run the haproxy_server role (again)
|
|
include_role:
|
|
name: "haproxy_server"
|
|
|
|
- name: Ensure the absent service is missing
|
|
stat:
|
|
path: "/etc/haproxy/conf.d/test_absent_service"
|
|
register: absent_services
|
|
when:
|
|
- "not (idempotence_pass_1 | bool)"
|
|
failed_when: absent_services.stat.exists
|
|
|