Merge "Rename role haproxy to loadbalancer"

This commit is contained in:
Zuul 2021-09-02 16:18:58 +00:00 committed by Gerrit Code Review
commit 0e9a6fe773
27 changed files with 65 additions and 46 deletions

View File

@ -577,6 +577,7 @@ enable_openstack_core: "yes"
enable_glance: "{{ enable_openstack_core | bool }}"
enable_haproxy: "yes"
enable_keepalived: "{{ enable_haproxy | bool }}"
enable_loadbalancer: "{{ enable_haproxy | bool or enable_keepalived | bool }}"
enable_keystone: "{{ enable_openstack_core | bool }}"
enable_keystone_federation: "{{ (keystone_identity_providers | length > 0) and (keystone_identity_mappings | length > 0) }}"
enable_mariadb: "yes"

View File

@ -75,9 +75,15 @@ control
[hacluster-remote:children]
compute
[haproxy:children]
[loadbalancer:children]
network
[keepalived:children]
loadbalancer
[haproxy:children]
loadbalancer
[mariadb:children]
control

View File

@ -99,9 +99,15 @@ control
[hacluster-remote:children]
compute
[haproxy:children]
[loadbalancer:children]
network
[keepalived:children]
loadbalancer
[haproxy:children]
loadbalancer
[mariadb:children]
control

View File

@ -1,3 +0,0 @@
---
- include_tasks: "{{ kolla_action }}.yml"
when: inventory_hostname in groups['haproxy']

View File

@ -1,7 +1,7 @@
---
project_name: "haproxy"
project_name: "loadbalancer"
haproxy_services:
loadbalancer_services:
haproxy:
container_name: haproxy
group: haproxy
@ -13,7 +13,7 @@ haproxy_services:
healthcheck: "{{ haproxy_healthcheck }}"
keepalived:
container_name: keepalived
group: haproxy
group: keepalived
enabled: "{{ enable_keepalived | bool }}"
image: "{{ keepalived_image_full }}"
privileged: True

View File

@ -49,7 +49,7 @@
- name: Restart backup haproxy container
vars:
service_name: "haproxy"
service: "{{ haproxy_services[service_name] }}"
service: "{{ loadbalancer_services[service_name] }}"
become: true
kolla_docker:
action: "recreate_or_restart_container"
@ -78,7 +78,7 @@
- name: Start backup keepalived container
vars:
service_name: "keepalived"
service: "{{ haproxy_services[service_name] }}"
service: "{{ loadbalancer_services[service_name] }}"
become: true
kolla_docker:
action: "recreate_or_restart_container"
@ -128,7 +128,7 @@
- name: Start master haproxy container
vars:
service_name: "haproxy"
service: "{{ haproxy_services[service_name] }}"
service: "{{ loadbalancer_services[service_name] }}"
become: true
kolla_docker:
action: "recreate_or_restart_container"
@ -157,7 +157,7 @@
- name: Start master keepalived container
vars:
service_name: "keepalived"
service: "{{ haproxy_services[service_name] }}"
service: "{{ loadbalancer_services[service_name] }}"
become: true
kolla_docker:
action: "recreate_or_restart_container"

View File

@ -1,5 +1,5 @@
---
- name: Check haproxy containers
- name: Check loadbalancer containers
become: true
kolla_docker:
action: "compare_container"
@ -13,6 +13,6 @@
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ haproxy_services }}"
with_dict: "{{ loadbalancer_services }}"
notify:
- "Restart {{ item.key }} container"

View File

@ -10,11 +10,11 @@
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ haproxy_services }}"
with_dict: "{{ loadbalancer_services }}"
- name: Ensuring service config subdir exists
- name: Ensuring haproxy service config subdir exists
vars:
service: "{{ haproxy_services['haproxy'] }}"
service: "{{ loadbalancer_services['haproxy'] }}"
file:
path: "{{ node_config_directory }}/haproxy/services.d"
state: "directory"
@ -28,20 +28,20 @@
- name: Copying over config.json files for services
template:
src: "{{ item.key }}.json.j2"
src: "{{ item.key }}/{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660"
become: true
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ haproxy_services }}"
with_dict: "{{ loadbalancer_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Copying over haproxy.cfg
vars:
service: "{{ haproxy_services['haproxy'] }}"
service: "{{ loadbalancer_services['haproxy'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/haproxy/haproxy.cfg"
@ -53,13 +53,13 @@
with_first_found:
- "{{ node_custom_config }}/haproxy/{{ inventory_hostname }}/haproxy_main.cfg"
- "{{ node_custom_config }}/haproxy/haproxy_main.cfg"
- "haproxy_main.cfg.j2"
- "haproxy/haproxy_main.cfg.j2"
notify:
- Restart haproxy container
- name: Copying over custom haproxy services configuration
vars:
service: "{{ haproxy_services['haproxy'] }}"
service: "{{ loadbalancer_services['haproxy'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/haproxy/services.d/"
@ -75,7 +75,7 @@
- name: Copying over keepalived.conf
vars:
service: "{{ haproxy_services['keepalived'] }}"
service: "{{ loadbalancer_services['keepalived'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/keepalived/keepalived.conf"
@ -87,13 +87,13 @@
with_first_found:
- "{{ node_custom_config }}/keepalived/{{ inventory_hostname }}/keepalived.conf"
- "{{ node_custom_config }}/keepalived/keepalived.conf"
- "keepalived.conf.j2"
- "keepalived/keepalived.conf.j2"
notify:
- Restart keepalived container
- name: Copying over haproxy.pem
vars:
service: "{{ haproxy_services['haproxy'] }}"
service: "{{ loadbalancer_services['haproxy'] }}"
copy:
src: "{{ kolla_external_fqdn_cert }}"
dest: "{{ node_config_directory }}/haproxy/{{ item }}"
@ -111,7 +111,7 @@
- name: Copying over haproxy-internal.pem
vars:
service: "{{ haproxy_services['haproxy'] }}"
service: "{{ loadbalancer_services['haproxy'] }}"
copy:
src: "{{ kolla_internal_fqdn_cert }}"
dest: "{{ node_config_directory }}/haproxy/{{ item }}"
@ -133,7 +133,7 @@
- name: Copying over haproxy start script
vars:
service: "{{ haproxy_services['haproxy'] }}"
service: "{{ loadbalancer_services['haproxy'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/haproxy/haproxy_run.sh"
@ -145,6 +145,6 @@
with_first_found:
- "{{ node_custom_config }}/haproxy/{{ inventory_hostname }}/haproxy_run.sh"
- "{{ node_custom_config }}/haproxy/haproxy_run.sh"
- "haproxy_run.sh.j2"
- "haproxy/haproxy_run.sh.j2"
notify:
- Restart haproxy container

View File

@ -3,4 +3,4 @@
import_role:
role: service-cert-copy
vars:
project_services: "{{ haproxy_services }}"
project_services: "{{ loadbalancer_services }}"

View File

@ -0,0 +1,3 @@
---
- include_tasks: "{{ kolla_action }}.yml"
when: inventory_hostname in groups['loadbalancer']

View File

@ -2,7 +2,7 @@
- import_role:
name: service-precheck
vars:
service_precheck_services: "{{ haproxy_services }}"
service_precheck_services: "{{ loadbalancer_services }}"
service_name: "{{ project_name }}"
- name: Get container facts
@ -19,7 +19,7 @@
changed_when: false
when:
- enable_keepalived | bool
- inventory_hostname in groups['haproxy']
- inventory_hostname in groups['keepalived']
- name: Group hosts by whether they are running HAProxy
group_by:
@ -34,7 +34,7 @@
# NOTE(mgoddard): We can only reliably run this precheck if all hosts in
# the haproxy group are included in the batch. This may not be the case if
# using --limit or --serial.
all_hosts_in_batch: "{{ groups['haproxy'] | difference(ansible_play_batch) | list | length == 0 }}"
all_hosts_in_batch: "{{ groups['loadbalancer'] | difference(ansible_play_batch) | list | length == 0 }}"
set_fact:
keepalived_vip_prechecks: "{{ all_hosts_in_batch and groups['keepalived_running_True'] is not defined }}"
haproxy_vip_prechecks: "{{ all_hosts_in_batch and groups['haproxy_running_True'] is not defined }}"
@ -156,7 +156,7 @@
- enable_haproxy | bool
- enable_keepalived | bool
- container_facts['keepalived'] is not defined
- inventory_hostname in groups['haproxy']
- inventory_hostname in groups['loadbalancer']
- name: Getting haproxy stat
shell: echo "show stat" | docker exec -i haproxy socat unix-connect:/var/lib/kolla/haproxy/haproxy.sock stdio # noqa 306

View File

@ -2,5 +2,5 @@
- import_role:
name: service-stop
vars:
project_services: "{{ haproxy_services }}"
project_services: "{{ loadbalancer_services }}"
service_name: "{{ project_name }}"

View File

@ -10,13 +10,13 @@ vrrp_instance kolla_internal_vip_{{ keepalived_virtual_router_id }} {
nopreempt
interface {{ api_interface }}
virtual_router_id {{ keepalived_virtual_router_id }}
priority {{ groups['haproxy'].index(inventory_hostname) + 1 }}
priority {{ groups['loadbalancer'].index(inventory_hostname) + 1 }}
advert_int 1
{% if keepalived_traffic_mode == 'unicast' %}
unicast_src_ip {{ api_interface_address }}
{% if groups['haproxy'] | length > 1 %}
{% if groups['loadbalancer'] | length > 1 %}
unicast_peer {
{% for host in groups['haproxy'] %}
{% for host in groups['loadbalancer'] %}
{% set ip_addr = 'api' | kolla_address(host) %}
{% if ip_addr != api_interface_address %}
{{ ip_addr }}

View File

@ -8,7 +8,7 @@
when:
- not enable_mariadb | bool
- enable_external_mariadb_load_balancer | bool
- inventory_hostname in groups['haproxy']
- inventory_hostname in groups['loadbalancer']
- name: "Check if external database address is reachable from all hosts"
wait_for:

View File

@ -34,7 +34,6 @@
- enable_glance_{{ enable_glance | bool }}
- enable_gnocchi_{{ enable_gnocchi | bool }}
- enable_grafana_{{ enable_grafana | bool }}
- enable_haproxy_{{ enable_haproxy | bool }}
- enable_hacluster_{{ enable_hacluster | bool }}
- enable_heat_{{ enable_heat | bool }}
- enable_horizon_{{ enable_horizon | bool }}
@ -45,6 +44,7 @@
- enable_keystone_{{ enable_keystone | bool }}
- enable_kibana_{{ enable_kibana | bool }}
- enable_kuryr_{{ enable_kuryr | bool }}
- enable_loadbalancer_{{ enable_loadbalancer | bool }}
- enable_magnum_{{ enable_magnum | bool }}
- enable_manila_{{ enable_manila | bool }}
- enable_mariadb_{{ enable_mariadb | bool }}
@ -113,17 +113,17 @@
tags: chrony,
when: enable_chrony | bool }
- name: Apply role haproxy
- name: Apply role loadbalancer
gather_facts: false
hosts:
- haproxy
- '&enable_haproxy_True'
- loadbalancer
- '&enable_loadbalancer_True'
serial: '{{ kolla_serial|default("0") }}'
tags:
- haproxy
- loadbalancer
roles:
- { role: haproxy,
when: enable_haproxy | bool }
- { role: loadbalancer,
when: enable_loadbalancer | bool }
tasks:
- block:
- include_role:

View File

@ -155,9 +155,15 @@ control
[hacluster-remote:children]
compute
[haproxy:children]
[loadbalancer:children]
network
[keepalived:children]
loadbalancer
[haproxy:children]
loadbalancer
[mariadb:children]
control