From 7288062676e9f1153c7982f708952a7f4ba59706 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Wed, 17 Oct 2018 18:37:38 +0100 Subject: [PATCH] Use templating for nova cell database_connection Nova now allows use of templated urls in the database and mq connections which will allow static configuration elements to be applied to the urls read from the database per-node. This should be a simpler and less obscure method of configuring things like the per-node bind_address necessary for director's HA arrangement. This patch addresses the templated DB urls as part 1. Nova support added here: https://review.openstack.org/#/c/578163/ Related-Bug: 1808134 Co-Authored-By: Martin Schuppert Change-Id: If30b4647bca210663a22fd653e752d4d57345bdd --- docker/services/nova-api.yaml | 124 +++++++++++++++--- ...plated_cells_db_urls-2eb151090c49c51d.yaml | 10 ++ roles/Undercloud.yaml | 1 + roles_data_undercloud.yaml | 1 + 4 files changed, 115 insertions(+), 21 deletions(-) create mode 100644 releasenotes/notes/nova_templated_cells_db_urls-2eb151090c49c51d.yaml diff --git a/docker/services/nova-api.yaml b/docker/services/nova-api.yaml index 801f972fc7..a331981768 100644 --- a/docker/services/nova-api.yaml +++ b/docker/services/nova-api.yaml @@ -62,11 +62,20 @@ parameters: description: The password for the nova service and db account type: string hidden: true + MysqlIPv6: + default: false + description: Enable IPv6 in MySQL + type: boolean conditions: internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]} + mysql_ipv6_use_ip_address: + and: + - {equals: [{get_param: MysqlIPv6}, true]} + - {equals: [{get_param: EnableInternalTLS}, false]} + resources: ContainersCommon: @@ -195,16 +204,37 @@ outputs: nova_api_ensure_default_cell.sh: mode: "0700" - content: | - #!/bin/bash - DEFID=$(nova-manage cell_v2 list_cells | sed -e '1,3d' -e '$d' | awk -F ' *| *' '$2 == "default" {print $4}') - if [ "$DEFID" ]; then - echo "(cellv2) Updating default cell_v2 cell $DEFID" - su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 update_cell --cell_uuid $DEFID --name=default" - else - echo "(cellv2) Creating default cell_v2 cell" - su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 create_cell --name=default" - fi + content: + str_replace: + template: | + #!/bin/bash + DEFID=$(nova-manage cell_v2 list_cells | sed -e '1,3d' -e '$d' | awk -F ' *| *' '$2 == "default" {print $4}') + if [ "$DEFID" ]; then + echo "(cellv2) Updating default cell_v2 cell $DEFID" + su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 update_cell --cell_uuid $DEFID --name=default --database_connection='CELLDB'" + else + echo "(cellv2) Creating default cell_v2 cell" + su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 create_cell --name=default --database_connection='CELLDB'" + fi + params: + CELLDB: + list_join: + - '' + - - '{scheme}' + - '://' + - '{username}' + - ':' + - '{password}' + - '@' + - + if: + - mysql_ipv6_use_ip_address + - '[{hostname}]' + - '{hostname}' + - '/' + - 'nova' + - '?' + - '{query}' docker_config: step_2: get_attr: [NovaApiLogging, docker_config, step_2] @@ -230,7 +260,28 @@ outputs: detach: false user: root volumes: *nova_api_bootstrap_volumes - command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 map_cell0'" + command: + str_replace: + template: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 map_cell0 --database_connection=\"CELL0DB\"'" + params: + CELL0DB: + list_join: + - '' + - - '{scheme}' + - '://' + - '{username}' + - ':' + - '{password}' + - '@' + - + if: + - mysql_ipv6_use_ip_address + - '[{hostname}]' + - '{hostname}' + - '/' + - 'nova_cell0' + - '?' + - '{query}' nova_api_ensure_default_cell: start_order: 2 image: *nova_api_image @@ -477,19 +528,50 @@ outputs: - name: Setup cell_v2 (map cell0) shell: str_replace: - template: nova-manage cell_v2 map_cell0 --database_connection=CELL + template: nova-manage cell_v2 map_cell0 --database_connection='CELL0DB' params: - CELL: - make_url: - scheme: {get_param: [EndpointMap, MysqlInternal, protocol]} - username: nova - password: {get_param: NovaPassword} - host: {get_param: [EndpointMap, MysqlInternal, host]} - path: /nova_cell0 + CELL0DB: + list_join: + - '' + - - '{scheme}' + - '://' + - '{username}' + - ':' + - '{password}' + - '@' + - + if: + - mysql_ipv6_use_ip_address + - '[{hostname}]' + - '{hostname}' + - '/' + - 'nova_cell0' + - '?' + - '{query}' - name: Setup cell_v2 (create default cell) # (owalsh) puppet-nova expects the cell name 'default' - # (owalsh) pass the db uri explicitly to avoid https://bugs.launchpad.net/tripleo/+bug/1662344 - shell: nova-manage cell_v2 create_cell --name='default' --database_connection=$(hiera nova::database_connection) + shell: + str_replace: + template: nova-manage cell_v2 create_cell --name='default' --database_connection='CELLDB' + params: + CELLDB: + list_join: + - '' + - - '{scheme}' + - '://' + - '{username}' + - ':' + - '{password}' + - '@' + - + if: + - mysql_ipv6_use_ip_address + - '[{hostname}]' + - '{hostname}' + - '/' + - 'nova' + - '?' + - '{query}' register: nova_api_create_cell failed_when: nova_api_create_cell.rc not in [0,2] changed_when: nova_api_create_cell.rc == 0 diff --git a/releasenotes/notes/nova_templated_cells_db_urls-2eb151090c49c51d.yaml b/releasenotes/notes/nova_templated_cells_db_urls-2eb151090c49c51d.yaml new file mode 100644 index 0000000000..9653a7c985 --- /dev/null +++ b/releasenotes/notes/nova_templated_cells_db_urls-2eb151090c49c51d.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + Nova now allows use of templated urls in the database and mq + connections which will allow static configuration elements to be + applied to the urls read from the database per-node. This should + be a simpler and less obscure method of configuring things like + the per-node bind_address necessary for director's HA arrangement. + This patch addresses the templated DB urls as part 1. + Nova support added here - https://review.openstack.org/578163 diff --git a/roles/Undercloud.yaml b/roles/Undercloud.yaml index aa11222d64..5fc2becfed 100644 --- a/roles/Undercloud.yaml +++ b/roles/Undercloud.yaml @@ -65,6 +65,7 @@ - OS::TripleO::Services::MistralEventEngine - OS::TripleO::Services::MistralExecutor - OS::TripleO::Services::MySQL + - OS::TripleO::Services::MySQLClient - OS::TripleO::Services::NeutronApi - OS::TripleO::Services::NeutronCorePlugin - OS::TripleO::Services::NeutronDhcpAgent diff --git a/roles_data_undercloud.yaml b/roles_data_undercloud.yaml index 0b2b85f183..ff639780b9 100644 --- a/roles_data_undercloud.yaml +++ b/roles_data_undercloud.yaml @@ -68,6 +68,7 @@ - OS::TripleO::Services::MistralEventEngine - OS::TripleO::Services::MistralExecutor - OS::TripleO::Services::MySQL + - OS::TripleO::Services::MySQLClient - OS::TripleO::Services::NeutronApi - OS::TripleO::Services::NeutronCorePlugin - OS::TripleO::Services::NeutronDhcpAgent