From c5fbcbfbbb2f1acdfbe0c20c392fa671906be633 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Wed, 17 Jul 2024 18:45:27 +0200 Subject: [PATCH] Rename haproxy_hosts to load_balancer_hosts Due to the way of how dynamic_inventory parses groups, usage of `haproxy_hosts` which are eventually mapped to `haproxy` lead bare metal hosts to be also a part of `haproxy_all` group, which might be not expected or anticipated. Change-Id: Ib1199236a6dfecb47b5840f04cb4b1486cc2f6a6 --- .../inventory/understanding-inventory.rst | 2 +- etc/openstack_deploy/conf.d/haproxy.yml.aio | 2 +- etc/openstack_deploy/conf.d/haproxy.yml.example | 2 +- .../openstack_user_config.yml.aio | 2 +- .../openstack_user_config.yml.example | 4 ++-- .../openstack_user_config.yml.multibond.example | 2 +- .../openstack_user_config.yml.pod.example | 2 +- .../openstack_user_config.yml.prod-ceph.example | 2 +- .../openstack_user_config.yml.prod.example | 2 +- ...enstack_user_config.yml.provnet-group.example | 2 +- .../openstack_user_config.yml.singlebond.example | 2 +- .../openstack_user_config.yml.test.example | 2 +- inventory/env.d/haproxy.yml | 7 +++++++ ...roxy_hosts_envd_renamed-56edb1aa3f56539b.yaml | 16 ++++++++++++++++ tests/test_inventory.py | 7 +++++-- 15 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 releasenotes/notes/haproxy_hosts_envd_renamed-56edb1aa3f56539b.yaml diff --git a/doc/source/reference/inventory/understanding-inventory.rst b/doc/source/reference/inventory/understanding-inventory.rst index 7ee8200c3e..0c276852ec 100644 --- a/doc/source/reference/inventory/understanding-inventory.rst +++ b/doc/source/reference/inventory/understanding-inventory.rst @@ -39,7 +39,7 @@ Ansible group mappings. These groups map to the physical hosts. The ``haproxy.yml.example`` file in the ``conf.d/`` directory provides -a simple example of defining a host group (``haproxy_hosts``) with two hosts +a simple example of defining a host group (``load_balancer_hosts``) with two hosts (``infra1`` and ``infra2``). The ``swift.yml.example`` file provides a more complex example. Here, host diff --git a/etc/openstack_deploy/conf.d/haproxy.yml.aio b/etc/openstack_deploy/conf.d/haproxy.yml.aio index 33107c65ce..2a79b0e8aa 100644 --- a/etc/openstack_deploy/conf.d/haproxy.yml.aio +++ b/etc/openstack_deploy/conf.d/haproxy.yml.aio @@ -1,4 +1,4 @@ --- -haproxy_hosts: +load_balancer_hosts: aio1: ip: 172.29.236.100 diff --git a/etc/openstack_deploy/conf.d/haproxy.yml.example b/etc/openstack_deploy/conf.d/haproxy.yml.example index 7224ed5ff8..0613929d58 100644 --- a/etc/openstack_deploy/conf.d/haproxy.yml.example +++ b/etc/openstack_deploy/conf.d/haproxy.yml.example @@ -1,5 +1,5 @@ # The nodes where haproxy will run -haproxy_hosts: +load_balancer_hosts: infra1: ip: 172.20.236.110 infra2: diff --git a/etc/openstack_deploy/openstack_user_config.yml.aio b/etc/openstack_deploy/openstack_user_config.yml.aio index 1b3c44cabc..16ff995670 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.aio +++ b/etc/openstack_deploy/openstack_user_config.yml.aio @@ -132,6 +132,6 @@ repo-infra_hosts: aio1: ip: 172.29.236.100 -haproxy_hosts: +load_balancer_hosts: aio1: ip: 172.29.236.100 diff --git a/etc/openstack_deploy/openstack_user_config.yml.example b/etc/openstack_deploy/openstack_user_config.yml.example index 1c00457fd3..aaa210fc19 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.example +++ b/etc/openstack_deploy/openstack_user_config.yml.example @@ -805,7 +805,7 @@ # # -------- # -# Level: haproxy_hosts (optional) +# Level: load_balancer_hosts (optional) # List of target hosts on which to deploy HAProxy. Recommend at least one # target host for this service if hardware load balancers are not being # used. @@ -825,7 +825,7 @@ # While HAProxy can be used as a virtual load balancer, it is recommended to use # a physical load balancer in a production environment. # -# haproxy_hosts: +# load_balancer_hosts: # lb1: # ip: 172.29.236.100 # lb2: diff --git a/etc/openstack_deploy/openstack_user_config.yml.multibond.example b/etc/openstack_deploy/openstack_user_config.yml.multibond.example index 95436f9c0f..4c425e3ca0 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.multibond.example +++ b/etc/openstack_deploy/openstack_user_config.yml.multibond.example @@ -111,7 +111,7 @@ repo-infra_hosts: # load balancer # Ideally the load balancer should not use the Infrastructure hosts. # Dedicated hardware is best for improved performance and security. -haproxy_hosts: +load_balancer_hosts: infra1: ip: 172.29.236.11 infra2: diff --git a/etc/openstack_deploy/openstack_user_config.yml.pod.example b/etc/openstack_deploy/openstack_user_config.yml.pod.example index 1f640b0af4..a8598947a1 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.pod.example +++ b/etc/openstack_deploy/openstack_user_config.yml.pod.example @@ -300,7 +300,7 @@ repo-infra_hosts: *controllers # load balancer # Ideally the load balancer should not use the Infrastructure hosts. # Dedicated hardware is best for improved performance and security. -haproxy_hosts: *controllers +load_balancer_hosts: *controllers ### ### OpenStack diff --git a/etc/openstack_deploy/openstack_user_config.yml.prod-ceph.example b/etc/openstack_deploy/openstack_user_config.yml.prod-ceph.example index 405957365c..cfba8b556c 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.prod-ceph.example +++ b/etc/openstack_deploy/openstack_user_config.yml.prod-ceph.example @@ -123,7 +123,7 @@ repo-infra_hosts: *infrastructure_hosts # load balancer # Ideally the load balancer should not use the Infrastructure hosts. # Dedicated hardware is best for improved performance and security. -haproxy_hosts: *infrastructure_hosts +load_balancer_hosts: *infrastructure_hosts ### ### OpenStack diff --git a/etc/openstack_deploy/openstack_user_config.yml.prod.example b/etc/openstack_deploy/openstack_user_config.yml.prod.example index b44b6dcf8a..6cc61003ee 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.prod.example +++ b/etc/openstack_deploy/openstack_user_config.yml.prod.example @@ -105,7 +105,7 @@ repo-infra_hosts: # load balancer # Ideally the load balancer should not use the Infrastructure hosts. # Dedicated hardware is best for improved performance and security. -haproxy_hosts: +load_balancer_hosts: infra1: ip: 172.29.236.11 infra2: diff --git a/etc/openstack_deploy/openstack_user_config.yml.provnet-group.example b/etc/openstack_deploy/openstack_user_config.yml.provnet-group.example index 47abe1ad92..b8ee750ea8 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.provnet-group.example +++ b/etc/openstack_deploy/openstack_user_config.yml.provnet-group.example @@ -149,7 +149,7 @@ repo-infra_hosts: # load balancer # Ideally the load balancer should not use the Infrastructure hosts. # Dedicated hardware is best for improved performance and security. -haproxy_hosts: +load_balancer_hosts: infra1: ip: 172.29.236.11 infra2: diff --git a/etc/openstack_deploy/openstack_user_config.yml.singlebond.example b/etc/openstack_deploy/openstack_user_config.yml.singlebond.example index cb8b1f8577..3a83b6c46e 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.singlebond.example +++ b/etc/openstack_deploy/openstack_user_config.yml.singlebond.example @@ -111,7 +111,7 @@ repo-infra_hosts: # load balancer # Ideally the load balancer should not use the Infrastructure hosts. # Dedicated hardware is best for improved performance and security. -haproxy_hosts: +load_balancer_hosts: infra1: ip: 172.29.236.11 infra2: diff --git a/etc/openstack_deploy/openstack_user_config.yml.test.example b/etc/openstack_deploy/openstack_user_config.yml.test.example index 6917928c3b..94939192f3 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.test.example +++ b/etc/openstack_deploy/openstack_user_config.yml.test.example @@ -82,7 +82,7 @@ repo-infra_hosts: ip: 172.29.236.11 # load balancer -haproxy_hosts: +load_balancer_hosts: infra1: ip: 172.29.236.11 diff --git a/inventory/env.d/haproxy.yml b/inventory/env.d/haproxy.yml index dea5d2f0cb..5265d836ea 100644 --- a/inventory/env.d/haproxy.yml +++ b/inventory/env.d/haproxy.yml @@ -23,12 +23,19 @@ container_skel: haproxy_container: belongs_to: - haproxy_containers + - load_balancer_containers contains: - haproxy properties: is_metal: true physical_skel: + load_balancer_containers: + belongs_to: + - all_containers + load_balancer_hosts: + belongs_to: + - hosts haproxy_containers: belongs_to: - all_containers diff --git a/releasenotes/notes/haproxy_hosts_envd_renamed-56edb1aa3f56539b.yaml b/releasenotes/notes/haproxy_hosts_envd_renamed-56edb1aa3f56539b.yaml new file mode 100644 index 0000000000..b1a74fc71c --- /dev/null +++ b/releasenotes/notes/haproxy_hosts_envd_renamed-56edb1aa3f56539b.yaml @@ -0,0 +1,16 @@ +--- + +upgrade: + - | + Group name for HAProxy destination hosts in `openstack_user_config.yml`` + was renamed from ``haproxy_hosts`` to ``load_balancer_hosts``. + While backwards compatability is kept, it is recommended to replace + defenition with the new group during the upgrade. +deprecations: + - | + Usage of ``haproxy_hosts`` in `openstack_user_config.yml`` has been + deprecated in favor of ``load_balancer_hosts``. +fixes: + - | + ``haproxy_all`` group is no longer populated with bare metal hosts in + case of installing haproxy/keepalived inside LXC containers. diff --git a/tests/test_inventory.py b/tests/test_inventory.py index cbabcd19c4..ed8fd0001a 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -233,6 +233,9 @@ class TestAnsibleInventoryFormatConstraints(unittest.TestCase): 'haproxy_container', 'haproxy_containers', 'haproxy_hosts', + 'load_balancer_containers', + 'load_balancer_hosts', + 'load_balancer_all', 'heat_all', 'heat_api', 'heat_api_cfn', @@ -789,7 +792,7 @@ class TestConfigChecks(TestConfigCheckBase): self.assertEqual(context.exception.new_host, 'host2') def test_two_hosts_same_ip_externally(self): - self.set_new_hostname(self.user_defined_config, "haproxy_hosts", + self.set_new_hostname(self.user_defined_config, "load_balancer_hosts", "aio1", "hap") with self.assertRaises(di.MultipleHostsWithOneIPError) as context: get_inventory() @@ -801,7 +804,7 @@ class TestConfigChecks(TestConfigCheckBase): def test_one_host_two_ips_externally(self): # haproxy chosen because it was last in the config file as of # writing - self.set_new_ip(self.user_defined_config, 'haproxy_hosts', 'aio1', + self.set_new_ip(self.user_defined_config, 'load_balancer_hosts', 'aio1', '172.29.236.101') with self.assertRaises(di.MultipleIpForHostError) as context: get_inventory()