From 77068780b2de1734148549e3260240ecb58ddbe9 Mon Sep 17 00:00:00 2001 From: Jonathan Herlin Date: Fri, 26 Mar 2021 10:34:19 +0100 Subject: [PATCH] Integrate cloudkitty Integrate the required bits to make Cloudkitty deploy without having to hand-pick files from the os_cloudkitty repo Change-Id: Id191e07eab2bef84dad30e55f59fd914b0358bfe --- .../conf.d/cloudkitty.yml.aio | 4 ++ .../conf.d/cloudkitty.yml.example | 8 +++ etc/openstack_deploy/user_secrets.yml | 10 +++ inventory/env.d/cloudkitty.yml | 24 +++++++ inventory/group_vars/haproxy/haproxy.yml | 13 ++++ inventory/group_vars/horizon_all.yml | 1 + inventory/inventory.ini | 6 ++ .../repo_packages/openstack_services.yml | 12 ++++ playbooks/os-cloudkitty-install.yml | 65 +++++++++++++++++++ playbooks/setup-openstack.yml | 1 + .../deploy-config-changes.yml | 17 +++++ tests/test_inventory.py | 6 ++ zuul.d/jobs.yaml | 2 + 13 files changed, 169 insertions(+) create mode 100644 etc/openstack_deploy/conf.d/cloudkitty.yml.aio create mode 100644 etc/openstack_deploy/conf.d/cloudkitty.yml.example create mode 100644 inventory/env.d/cloudkitty.yml create mode 100644 playbooks/os-cloudkitty-install.yml diff --git a/etc/openstack_deploy/conf.d/cloudkitty.yml.aio b/etc/openstack_deploy/conf.d/cloudkitty.yml.aio new file mode 100644 index 0000000000..cf4e4fb2c9 --- /dev/null +++ b/etc/openstack_deploy/conf.d/cloudkitty.yml.aio @@ -0,0 +1,4 @@ +# The controller host that will be running the cloudkitty services +cloudkitty_hosts: + aio1: + ip: 172.29.236.100 \ No newline at end of file diff --git a/etc/openstack_deploy/conf.d/cloudkitty.yml.example b/etc/openstack_deploy/conf.d/cloudkitty.yml.example new file mode 100644 index 0000000000..1337b7e32f --- /dev/null +++ b/etc/openstack_deploy/conf.d/cloudkitty.yml.example @@ -0,0 +1,8 @@ +# The infra nodes that will be running the cloudkitty services +cloudkitty_hosts: + infra1: + ip: 172.20.236.111 + infra2: + ip: 172.20.236.112 + infra3: + ip: 172.20.236.113 \ No newline at end of file diff --git a/etc/openstack_deploy/user_secrets.yml b/etc/openstack_deploy/user_secrets.yml index 8c982b647b..f1d83edfb6 100644 --- a/etc/openstack_deploy/user_secrets.yml +++ b/etc/openstack_deploy/user_secrets.yml @@ -80,6 +80,16 @@ cinder_oslomsg_rpc_password: ## Ceph/rbd: a UUID to be used by libvirt to refer to the client.cinder user cinder_ceph_client_uuid: +## Cloudkitty Options +cloudkitty_container_mysql_password: +cloudkitty_service_password: +cloudkitty_oslomsg_rpc_password: +#NOTE: Please uncomment those +# if you want to split rpc and notify users +# Please also wire the appropriate userid in +# your user variables. +#cloudkitty_oslomsg_notify_password: + ## Glance Options glance_container_mysql_password: glance_service_password: diff --git a/inventory/env.d/cloudkitty.yml b/inventory/env.d/cloudkitty.yml new file mode 100644 index 0000000000..25a53ca0ba --- /dev/null +++ b/inventory/env.d/cloudkitty.yml @@ -0,0 +1,24 @@ +--- +component_skel: + cloudkitty_api: + belongs_to: + - cloudkitty_all + cloudkitty_engine: + belongs_to: + - cloudkitty_all + +container_skel: + cloudkitty_container: + belongs_to: + - cloudkitty_containers + contains: + - cloudkitty_api + - cloudkitty_engine + +physical_skel: + cloudkitty_containers: + belongs_to: + - all_containers + cloudkitty_hosts: + belongs_to: + - hosts diff --git a/inventory/group_vars/haproxy/haproxy.yml b/inventory/group_vars/haproxy/haproxy.yml index 2bc12867a7..814b8128ad 100644 --- a/inventory/group_vars/haproxy/haproxy.yml +++ b/inventory/group_vars/haproxy/haproxy.yml @@ -99,6 +99,18 @@ haproxy_cinder_api_service: - "httpchk HEAD / HTTP/1.0\\r\\nUser-agent:\\ osa-haproxy-healthcheck" haproxy_service_enabled: "{{ groups['cinder_api'] is defined and groups['cinder_api'] | length > 0 }}" +haproxy_cloudkitty_api_service: + haproxy_service_name: cloudkitty_api + haproxy_backend_nodes: "{{ groups['cloudkitty_api'] | default([]) }}" + haproxy_ssl: "{{ haproxy_ssl }}" + haproxy_ssl_all_vips: "{{ haproxy_ssl_all_vips }}" + haproxy_port: 8089 + haproxy_balance_type: http + haproxy_balance_alg: source + haproxy_backend_options: + - "httpchk GET / HTTP/1.0\\r\\nUser-agent:\\ osa-haproxy-healthcheck" + haproxy_service_enabled: "{{ groups['cloudkitty_api'] is defined and groups['cloudkitty_api'] | length > 0 }}" + haproxy_designate_api_service: haproxy_service_name: designate_api haproxy_backend_nodes: "{{ groups['designate_api'] | default([]) }}" @@ -558,6 +570,7 @@ haproxy_default_services: - service: "{{ haproxy_barbican_service }}" - service: "{{ haproxy_ceph_rgw_service }}" - service: "{{ haproxy_cinder_api_service }}" + - service: "{{ haproxy_cloudkitty_api_service }}" - service: "{{ haproxy_designate_api_service }}" - service: "{{ haproxy_galera_service }}" - service: "{{ haproxy_glance_api_service }}" diff --git a/inventory/group_vars/horizon_all.yml b/inventory/group_vars/horizon_all.yml index c635514956..3f31a41400 100644 --- a/inventory/group_vars/horizon_all.yml +++ b/inventory/group_vars/horizon_all.yml @@ -16,6 +16,7 @@ horizon_external_ssl: "{{ openstack_external_ssl }}" horizon_service_region: "{{ service_region }}" horizon_enable_cinder_backup: "{{ hostvars['localhost']['cinder_service_backup_program_enabled'] }}" +horizon_enable_cloudkitty_ui: "{{ (groups['cloudkitty_all'] is defined) and (groups['cloudkitty_all'] | length > 0) }}" horizon_enable_adjutant_ui: "{{ (groups['adjutant_all'] is defined) and (groups['adjutant_all'] | length > 0) }}" horizon_enable_blazar_ui: "{{ (groups['blazar_all'] is defined) and (groups['blazar_all'] | length > 0) }}" horizon_enable_heat_ui: "{{ (groups['heat_all'] is defined) and (groups['heat_all'] | length > 0) }}" diff --git a/inventory/inventory.ini b/inventory/inventory.ini index 79e630a137..02c21d3774 100644 --- a/inventory/inventory.ini +++ b/inventory/inventory.ini @@ -92,6 +92,12 @@ cinder_volume [cinder_volume] #[cinder_volumes_container] +[cloudkitty_all:children] +cloudkitty_api +cloudkitty_engine +[cloudkitty_api] +[cloudkitty_engine] + [designate_all] [elasticsearch] diff --git a/playbooks/defaults/repo_packages/openstack_services.yml b/playbooks/defaults/repo_packages/openstack_services.yml index 2469ecbdf5..99b2b8ca1c 100644 --- a/playbooks/defaults/repo_packages/openstack_services.yml +++ b/playbooks/defaults/repo_packages/openstack_services.yml @@ -74,6 +74,18 @@ cinder_git_install_branch: 355681cd53fbb2f5fd2c4cecb55a83c5e0c27c2c # HEAD as of cinder_git_track_branch: master +## Cloudkitty service +cloudkitty_git_repo: https://opendev.org/openstack/cloudkitty +cloudkitty_git_install_branch: 3bf565997f3dc315cbcc37f6c8240e6253f6bb48 # HEAD as of 26.03.2021 +cloudkitty_git_track_branch: master + + +## Cloudkitty dashboard plugin +cloudkitty_dashboard_git_repo: https://opendev.org/openstack/cloudkitty-dashboard +cloudkitty_dashboard_git_install_branch: 4e166ded43d51dd2baf0d13bbe88c1333b1a5d22 # HEAD as of 29.03.2021 +cloudkitty_dashboard_git_track_branch: master + + ## Designate service designate_git_repo: https://opendev.org/openstack/designate designate_git_install_branch: 518e8a74c6d3809914ab19241d7062815ae69623 # HEAD as of 11.04.2021 diff --git a/playbooks/os-cloudkitty-install.yml b/playbooks/os-cloudkitty-install.yml new file mode 100644 index 0000000000..8b4878fcb2 --- /dev/null +++ b/playbooks/os-cloudkitty-install.yml @@ -0,0 +1,65 @@ +--- +# Copyright 2021, ELITS Cloud Services 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. + + +- name: Gather cloudkitty facts + hosts: cloudkitty_all + gather_facts: "{{ osa_gather_facts | default(True) }}" + tags: + - always + +- name: Install cloudkitty services + hosts: cloudkitty_all + serial: "{{ cloudkitty_api_serial | default(['1', '100%']) }}" + gather_facts: false + user: root + environment: "{{ deployment_environment_variables | default({}) }}" + vars_files: + - "defaults/repo_packages/openstack_services.yml" + - "defaults/{{ install_method }}_install.yml" + tags: + - cloudkitty + pre_tasks: + # In order to ensure that any container, software or + # config file changes which causes a container/service + # restart do not cause an unexpected outage, we drain + # the load balancer back end for this container. + - include_tasks: common-tasks/haproxy-endpoint-manage.yml + vars: + haproxy_backend: cloudkitty_api-back + haproxy_state: disabled + when: + - "'cloudkitty_api' in group_names" + - "groups['cloudkitty_api'] | length > 1" + + - include_tasks: common-tasks/unbound-clients.yml + when: + - hostvars['localhost']['resolvconf_enabled'] | bool + + roles: + - role: "os_cloudkitty" + + post_tasks: + # Now that container changes are done, we can set + # the load balancer back end for this container + # to available again. + - include_tasks: common-tasks/haproxy-endpoint-manage.yml + vars: + haproxy_backend: cloudkitty_api-back + haproxy_state: enabled + when: + - "'cloudkitty_api' in group_names" + - "groups['cloudkitty_api'] | length > 1" + diff --git a/playbooks/setup-openstack.yml b/playbooks/setup-openstack.yml index 4da24a88d1..9252b3f914 100644 --- a/playbooks/setup-openstack.yml +++ b/playbooks/setup-openstack.yml @@ -28,6 +28,7 @@ - import_playbook: os-adjutant-install.yml - import_playbook: os-ceilometer-install.yml - import_playbook: os-aodh-install.yml +- import_playbook: os-cloudkitty-install.yml - import_playbook: os-panko-install.yml - import_playbook: os-ironic-install.yml - import_playbook: os-magnum-install.yml diff --git a/scripts/upgrade-utilities/deploy-config-changes.yml b/scripts/upgrade-utilities/deploy-config-changes.yml index 7a4b4d6b13..858fafebee 100644 --- a/scripts/upgrade-utilities/deploy-config-changes.yml +++ b/scripts/upgrade-utilities/deploy-config-changes.yml @@ -75,6 +75,23 @@ tags: - update-secrets + # TODO(jonher): Remove after W cycle + - name: Add Cloudkitty secrets to user_secrets if defined elsewhere + lineinfile: + dest: "{{ openstack_config_dir }}/user_secrets.yml" + regexp: "^{{ item.key }}" + line: "{{ item.key }}: {{ item.value }}" + loop: + - { key: "cloudkitty_container_mysql_password", value: "{{ cloudkitty_container_mysql_password | default([]) }}" } + - { key: "cloudkitty_service_password", value: "{{ cloudkitty_service_password | default([]) }}" } + - { key: "cloudkitty_oslomsg_rpc_password", value: "{{ cloudkitty_oslomsg_rpc_password | default([]) }}" } + - { key: "cloudkitty_oslomsg_notify_password", value: "{{ cloudkitty_oslomsg_notify_password | default([]) }}" } + when: + - item.value + - not (user_secrets.stdout | regex_search('((^|\n)' ~ item.key ~ ')')) + tags: + - update-secrets + - name: Add missing secrets lineinfile: dest: "{{ openstack_config_dir }}/user_secrets.yml" diff --git a/tests/test_inventory.py b/tests/test_inventory.py index cc2f22c43a..d4c9f496f8 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -190,6 +190,12 @@ class TestAnsibleInventoryFormatConstraints(unittest.TestCase): 'cinder_scheduler', 'cinder_volume', 'cinder_volumes_container', + 'cloudkitty_all', + 'cloudkitty_api', + 'cloudkitty_containers', + 'cloudkitty_container', + 'cloudkitty_engine', + 'cloudkitty_hosts', 'compute-infra_all', 'compute-infra_containers', 'compute-infra_hosts', diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 841b7b510e..b11bf1fe30 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -132,6 +132,7 @@ - name: openstack/openstack-ansible-os_barbican - name: openstack/openstack-ansible-os_blazar - name: openstack/openstack-ansible-os_ceilometer + - name: openstack/openstack-ansible-os_cloudkitty - name: openstack/openstack-ansible-os_cinder - name: openstack/openstack-ansible-os_designate - name: openstack/openstack-ansible-os_glance @@ -178,6 +179,7 @@ - name: openstack/barbican-ui - name: openstack/ceilometer - name: openstack/cinder + - name: openstack/cloudkitty - name: openstack/designate - name: openstack/designate-dashboard - name: openstack/glance