This converts ansible module usage to FQCN along with some minor linting fixes. Change-Id: I9932bfdc23d0fd3e0632b2433ed8ccea0e8c3a1e Signed-off-by: Dmitriy Rabotyagov <dmitriy.rabotyagov@cleura.com>
38 lines
1.8 KiB
YAML
38 lines
1.8 KiB
YAML
---
|
|
# Copyright 2023, Cleura AB
|
|
#
|
|
# 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.
|
|
|
|
# Haproxy service configs are stored in service group vars
|
|
# (for ex. `glance_haproxy_services` are stored in glance group vars).
|
|
# This is because they may refer to other variables in this group that are not
|
|
# used only for haproxy(like `glance_backend_ssl`).
|
|
# Group haproxy_all does not have access to service group vars by default.
|
|
# To solve this, haproxy_all hosts are temporarily added to `service_group`.
|
|
# After haproxy is configured, refresh_inventory is triggered to restore the
|
|
# original inventory state.
|
|
|
|
- hosts: haproxy
|
|
serial: "{{ haproxy_serial | default('50%') }}"
|
|
tasks:
|
|
- name: Configure haproxy for the service
|
|
ansible.builtin.import_role:
|
|
name: haproxy_server
|
|
tasks_from: haproxy_service_config_external.yml
|
|
vars:
|
|
_service_configs: "{{ groups[service_group] | map('extract', hostvars, service_variable) | flatten | unique }}"
|
|
_unlimited_configs: "{{ _service_configs | rejectattr('haproxy_limit_hosts', 'defined') }}"
|
|
_filtered_configs: >-
|
|
{{ _service_configs | selectattr('haproxy_limit_hosts', 'defined') | selectattr('haproxy_limit_hosts', 'search', inventory_hostname) }}
|
|
haproxy_service_configs: "{{ (_unlimited_configs + _filtered_configs) }}"
|