diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index b42f2e2fae..686e79a51d 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -576,6 +576,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" diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index f94d4f81cf..ead8ad6f74 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -75,9 +75,15 @@ control [hacluster-remote:children] compute -[haproxy:children] +[loadbalancer:children] network +[keepalived:children] +loadbalancer + +[haproxy:children] +loadbalancer + [mariadb:children] control diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index b1dd794f07..937032f230 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -99,9 +99,15 @@ control [hacluster-remote:children] compute -[haproxy:children] +[loadbalancer:children] network +[keepalived:children] +loadbalancer + +[haproxy:children] +loadbalancer + [mariadb:children] control diff --git a/ansible/roles/haproxy/tasks/main.yml b/ansible/roles/haproxy/tasks/main.yml deleted file mode 100644 index 94b59449f8..0000000000 --- a/ansible/roles/haproxy/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- include_tasks: "{{ kolla_action }}.yml" - when: inventory_hostname in groups['haproxy'] diff --git a/ansible/roles/haproxy/defaults/main.yml b/ansible/roles/loadbalancer/defaults/main.yml similarity index 98% rename from ansible/roles/haproxy/defaults/main.yml rename to ansible/roles/loadbalancer/defaults/main.yml index 145d595e37..ca48da20a4 100644 --- a/ansible/roles/haproxy/defaults/main.yml +++ b/ansible/roles/loadbalancer/defaults/main.yml @@ -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 diff --git a/ansible/roles/haproxy/handlers/main.yml b/ansible/roles/loadbalancer/handlers/main.yml similarity index 96% rename from ansible/roles/haproxy/handlers/main.yml rename to ansible/roles/loadbalancer/handlers/main.yml index fecff0ddc9..4adea1b1e7 100644 --- a/ansible/roles/haproxy/handlers/main.yml +++ b/ansible/roles/loadbalancer/handlers/main.yml @@ -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" diff --git a/ansible/roles/haproxy/tasks/check-containers.yml b/ansible/roles/loadbalancer/tasks/check-containers.yml similarity index 87% rename from ansible/roles/haproxy/tasks/check-containers.yml rename to ansible/roles/loadbalancer/tasks/check-containers.yml index bb19a0c804..d2c4035417 100644 --- a/ansible/roles/haproxy/tasks/check-containers.yml +++ b/ansible/roles/loadbalancer/tasks/check-containers.yml @@ -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" diff --git a/ansible/roles/haproxy/tasks/check.yml b/ansible/roles/loadbalancer/tasks/check.yml similarity index 100% rename from ansible/roles/haproxy/tasks/check.yml rename to ansible/roles/loadbalancer/tasks/check.yml diff --git a/ansible/roles/haproxy/tasks/config-host.yml b/ansible/roles/loadbalancer/tasks/config-host.yml similarity index 100% rename from ansible/roles/haproxy/tasks/config-host.yml rename to ansible/roles/loadbalancer/tasks/config-host.yml diff --git a/ansible/roles/haproxy/tasks/config.yml b/ansible/roles/loadbalancer/tasks/config.yml similarity index 84% rename from ansible/roles/haproxy/tasks/config.yml rename to ansible/roles/loadbalancer/tasks/config.yml index 26946804d7..f082073dbf 100644 --- a/ansible/roles/haproxy/tasks/config.yml +++ b/ansible/roles/loadbalancer/tasks/config.yml @@ -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 diff --git a/ansible/roles/haproxy/tasks/copy-certs.yml b/ansible/roles/loadbalancer/tasks/copy-certs.yml similarity index 68% rename from ansible/roles/haproxy/tasks/copy-certs.yml rename to ansible/roles/loadbalancer/tasks/copy-certs.yml index 486fa7b00f..7e26c26482 100644 --- a/ansible/roles/haproxy/tasks/copy-certs.yml +++ b/ansible/roles/loadbalancer/tasks/copy-certs.yml @@ -3,4 +3,4 @@ import_role: role: service-cert-copy vars: - project_services: "{{ haproxy_services }}" + project_services: "{{ loadbalancer_services }}" diff --git a/ansible/roles/haproxy/tasks/deploy-containers.yml b/ansible/roles/loadbalancer/tasks/deploy-containers.yml similarity index 100% rename from ansible/roles/haproxy/tasks/deploy-containers.yml rename to ansible/roles/loadbalancer/tasks/deploy-containers.yml diff --git a/ansible/roles/haproxy/tasks/deploy.yml b/ansible/roles/loadbalancer/tasks/deploy.yml similarity index 100% rename from ansible/roles/haproxy/tasks/deploy.yml rename to ansible/roles/loadbalancer/tasks/deploy.yml diff --git a/ansible/roles/loadbalancer/tasks/main.yml b/ansible/roles/loadbalancer/tasks/main.yml new file mode 100644 index 0000000000..61bef8fc90 --- /dev/null +++ b/ansible/roles/loadbalancer/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- include_tasks: "{{ kolla_action }}.yml" + when: inventory_hostname in groups['loadbalancer'] diff --git a/ansible/roles/haproxy/tasks/precheck.yml b/ansible/roles/loadbalancer/tasks/precheck.yml similarity index 98% rename from ansible/roles/haproxy/tasks/precheck.yml rename to ansible/roles/loadbalancer/tasks/precheck.yml index c488da28f7..6ccd8bdd6d 100644 --- a/ansible/roles/haproxy/tasks/precheck.yml +++ b/ansible/roles/loadbalancer/tasks/precheck.yml @@ -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 diff --git a/ansible/roles/haproxy/tasks/pull.yml b/ansible/roles/loadbalancer/tasks/pull.yml similarity index 100% rename from ansible/roles/haproxy/tasks/pull.yml rename to ansible/roles/loadbalancer/tasks/pull.yml diff --git a/ansible/roles/haproxy/tasks/reconfigure.yml b/ansible/roles/loadbalancer/tasks/reconfigure.yml similarity index 100% rename from ansible/roles/haproxy/tasks/reconfigure.yml rename to ansible/roles/loadbalancer/tasks/reconfigure.yml diff --git a/ansible/roles/haproxy/tasks/stop.yml b/ansible/roles/loadbalancer/tasks/stop.yml similarity index 63% rename from ansible/roles/haproxy/tasks/stop.yml rename to ansible/roles/loadbalancer/tasks/stop.yml index cb70188ba5..e4f0e49d8a 100644 --- a/ansible/roles/haproxy/tasks/stop.yml +++ b/ansible/roles/loadbalancer/tasks/stop.yml @@ -2,5 +2,5 @@ - import_role: name: service-stop vars: - project_services: "{{ haproxy_services }}" + project_services: "{{ loadbalancer_services }}" service_name: "{{ project_name }}" diff --git a/ansible/roles/haproxy/tasks/upgrade.yml b/ansible/roles/loadbalancer/tasks/upgrade.yml similarity index 100% rename from ansible/roles/haproxy/tasks/upgrade.yml rename to ansible/roles/loadbalancer/tasks/upgrade.yml diff --git a/ansible/roles/haproxy/templates/haproxy.json.j2 b/ansible/roles/loadbalancer/templates/haproxy/haproxy.json.j2 similarity index 100% rename from ansible/roles/haproxy/templates/haproxy.json.j2 rename to ansible/roles/loadbalancer/templates/haproxy/haproxy.json.j2 diff --git a/ansible/roles/haproxy/templates/haproxy_main.cfg.j2 b/ansible/roles/loadbalancer/templates/haproxy/haproxy_main.cfg.j2 similarity index 100% rename from ansible/roles/haproxy/templates/haproxy_main.cfg.j2 rename to ansible/roles/loadbalancer/templates/haproxy/haproxy_main.cfg.j2 diff --git a/ansible/roles/haproxy/templates/haproxy_run.sh.j2 b/ansible/roles/loadbalancer/templates/haproxy/haproxy_run.sh.j2 similarity index 100% rename from ansible/roles/haproxy/templates/haproxy_run.sh.j2 rename to ansible/roles/loadbalancer/templates/haproxy/haproxy_run.sh.j2 diff --git a/ansible/roles/haproxy/templates/keepalived.conf.j2 b/ansible/roles/loadbalancer/templates/keepalived/keepalived.conf.j2 similarity index 87% rename from ansible/roles/haproxy/templates/keepalived.conf.j2 rename to ansible/roles/loadbalancer/templates/keepalived/keepalived.conf.j2 index 43ac5d7aa3..e6e48370c1 100644 --- a/ansible/roles/haproxy/templates/keepalived.conf.j2 +++ b/ansible/roles/loadbalancer/templates/keepalived/keepalived.conf.j2 @@ -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 }} diff --git a/ansible/roles/haproxy/templates/keepalived.json.j2 b/ansible/roles/loadbalancer/templates/keepalived/keepalived.json.j2 similarity index 100% rename from ansible/roles/haproxy/templates/keepalived.json.j2 rename to ansible/roles/loadbalancer/templates/keepalived/keepalived.json.j2 diff --git a/ansible/roles/prechecks/tasks/database_checks.yml b/ansible/roles/prechecks/tasks/database_checks.yml index 0f53135a46..c4fb50c91a 100644 --- a/ansible/roles/prechecks/tasks/database_checks.yml +++ b/ansible/roles/prechecks/tasks/database_checks.yml @@ -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: diff --git a/ansible/site.yml b/ansible/site.yml index d96773fcd6..5383bd5ed7 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -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: diff --git a/tests/templates/inventory.j2 b/tests/templates/inventory.j2 index 887bc7179f..498e85a0a3 100644 --- a/tests/templates/inventory.j2 +++ b/tests/templates/inventory.j2 @@ -155,9 +155,15 @@ control [hacluster-remote:children] compute -[haproxy:children] +[loadbalancer:children] network +[keepalived:children] +loadbalancer + +[haproxy:children] +loadbalancer + [mariadb:children] control