openstack-ansible/playbooks/common-playbooks/haproxy-service-config.yml
Dmitriy Rabotyagov 5ea6f419c7 Fix linters to satisfy ansible-lint 6.18
With update of ansible-lint to version >=6.0.0 a lot of new
linters were added, that enabled by default. In order to comply
with linter rules we're applying changes to the role.

Update of linters version is required for bumping ansible-core
version.

Change-Id: Icb7d9906bdc3dcb50c44c67881c2078ade8b72f2
2023-08-22 15:47:38 +00:00

44 lines
1.7 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.
- name: Adding hosts haproxy_service variables to haproxy
hosts: "{{ service_group }}"
gather_facts: false
run_once: true
tasks:
- name: "Temporarily copy haproxy_service_configs value to haproxy_all from {{ service_group }}"
add_host:
name: "{{ item }}"
haproxy_service_configs: "{{ hostvars[inventory_hostname][service_variable] }}"
with_items: "{{ groups['haproxy_all'] }}"
- name: Configuring haproxy for the service
hosts: haproxy_all
serial: "{{ haproxy_serial | default('50%') }}"
tasks:
- name: Configure haproxy for the service
import_role:
name: haproxy_server
tasks_from: haproxy_service_config_external.yml