From 8cc05a3d00291aafc6a9d3fd4f430f2bf78c0c14 Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Thu, 14 Dec 2017 11:37:17 -0800 Subject: [PATCH] Add MySQL connection SSL support When 'octavia_galera_use_ssl' is True, use an encrypted connection to the database using either a self-signed or user-provided CA certificate. A new non-voting test has been added to verify that the role remains functional when enabling SSL features. Change-Id: I7a43d313474e17d7e968a5a9510368e3abdf6682 Partial-Bug: 1667789 --- defaults/main.yml | 4 +++- templates/octavia.conf.j2 | 3 ++- tox.ini | 11 +++++++++++ zuul.d/jobs.yaml | 21 +++++++++++++++++++++ zuul.d/project.yaml | 2 ++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 zuul.d/jobs.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 7bebc3ab..898b44aa 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -55,9 +55,11 @@ octavia_clients_endpoint: internalURL octavia_auth_strategy: keystone -## DB +## Database info octavia_galera_user: octavia octavia_galera_database: octavia +octavia_galera_use_ssl: "{{ galera_use_ssl | default(False) }}" +octavia_galera_ssl_ca_cert: "{{ galera_ssl_ca_cert | default('/etc/ssl/certs/galera-ca.pem') }}" octavia_db_max_overflow: 20 octavia_db_pool_size: 120 octavia_db_pool_timeout: 30 diff --git a/templates/octavia.conf.j2 b/templates/octavia.conf.j2 index cce9946f..655966a9 100644 --- a/templates/octavia.conf.j2 +++ b/templates/octavia.conf.j2 @@ -47,7 +47,8 @@ ssl = {{ octavia_rabbitmq_use_ssl }} rpc_conn_pool_size = {{ octavia_rpc_conn_pool_size }} [database] -connection = mysql+pymysql://{{ octavia_galera_user }}:{{ octavia_container_mysql_password }}@{{ octavia_galera_address }}/{{ octavia_galera_database }}?charset=utf8 +connection = mysql+pymysql://{{ octavia_galera_user }}:{{ octavia_container_mysql_password }}@{{ octavia_galera_address }}/{{ octavia_galera_database }}?charset=utf8{% if octavia_galera_use_ssl | bool %}&ssl_ca={{ octavia_galera_ssl_ca_cert }}{% endif %} + max_overflow = {{ octavia_db_max_overflow }} max_pool_size = {{ octavia_db_pool_size }} pool_timeout = {{ octavia_db_pool_timeout }} diff --git a/tox.ini b/tox.ini index a1cd1a97..520db52a 100644 --- a/tox.ini +++ b/tox.ini @@ -103,6 +103,17 @@ commands = bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" +[testenv:ssl] +deps = + {[testenv:ansible]deps} +setenv = + {[testenv]setenv} + ANSIBLE_PARAMETERS=-vvv -e galera_use_ssl=True +commands = + bash -c "{toxinidir}/tests/tests-repo-clone.sh" + bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" + + [testenv:linters] deps = {[testenv:ansible]deps} diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml new file mode 100644 index 00000000..93fff5ad --- /dev/null +++ b/zuul.d/jobs.yaml @@ -0,0 +1,21 @@ +--- +# Copyright 2017, Rackspace US, Inc. +# +# 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. + +- job: + name: openstack-ansible-octavia-ssl-nv + parent: openstack-ansible-functional-ubuntu-xenial + voting: false + vars: + tox_env: ssl diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 064b380e..9d9903dc 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -19,6 +19,7 @@ jobs: - openstack-ansible-linters - openstack-ansible-functional-ubuntu-xenial + - openstack-ansible-octavia-ssl-nv experimental: jobs: - openstack-ansible-integrated-deploy-aio @@ -26,3 +27,4 @@ jobs: - openstack-ansible-linters - openstack-ansible-functional-ubuntu-xenial + - openstack-ansible-octavia-ssl-nv