From 7088e885f82144a23df56faa1e0c7d75f29de071 Mon Sep 17 00:00:00 2001 From: rthallisey Date: Thu, 27 Aug 2015 16:18:17 -0400 Subject: [PATCH] Replace config-external with a JSON file for Galera Change-Id: I82abc9a31571376679c4f463f5a6ae77a49ec2f6 Partially-Implements: blueprint replace-config-external --- ansible/roles/mariadb/tasks/bootstrap.yml | 2 +- ansible/roles/mariadb/tasks/config.yml | 5 +++++ ansible/roles/mariadb/tasks/start.yml | 2 +- ansible/roles/mariadb/templates/mariadb.json.j2 | 12 ++++++++++++ docker/mariadb/start.sh | 17 +++++++++-------- 5 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 ansible/roles/mariadb/templates/mariadb.json.j2 diff --git a/ansible/roles/mariadb/tasks/bootstrap.yml b/ansible/roles/mariadb/tasks/bootstrap.yml index e616cf7a57..7beeae5bfe 100644 --- a/ansible/roles/mariadb/tasks/bootstrap.yml +++ b/ansible/roles/mariadb/tasks/bootstrap.yml @@ -66,7 +66,7 @@ insecure_registry: "{{ docker_insecure_registry }}" name: mariadb image: "{{ mariadb_image_full }}" - volumes: "{{ node_config_directory }}/mariadb/:/opt/kolla/mariadb/:ro" + volumes: "{{ node_config_directory }}/mariadb/:/opt/kolla/config_files/:ro" volumes_from: - "mariadb_data" env: diff --git a/ansible/roles/mariadb/tasks/config.yml b/ansible/roles/mariadb/tasks/config.yml index 868ae0524e..e41da656ad 100644 --- a/ansible/roles/mariadb/tasks/config.yml +++ b/ansible/roles/mariadb/tasks/config.yml @@ -7,3 +7,8 @@ config_template_dest: - "{{ node_templates_directory }}/mariadb/galera.cnf_minimal" config_dest: "{{ node_config_directory }}/mariadb/galera.cnf" + +- name: Copying Mariadb JSON configuration file + template: + src: "roles/mariadb/templates/mariadb.json.j2" + dest: "{{ node_config_directory }}/mariadb/config.json" diff --git a/ansible/roles/mariadb/tasks/start.yml b/ansible/roles/mariadb/tasks/start.yml index fe4c416b11..54f698813d 100644 --- a/ansible/roles/mariadb/tasks/start.yml +++ b/ansible/roles/mariadb/tasks/start.yml @@ -13,7 +13,7 @@ insecure_registry: "{{ docker_insecure_registry }}" name: mariadb image: "{{ mariadb_image_full }}" - volumes: "{{ node_config_directory }}/mariadb/:/opt/kolla/mariadb/:ro" + volumes: "{{ node_config_directory }}/mariadb/:/opt/kolla/config_files/:ro" volumes_from: - "mariadb_data" env: diff --git a/ansible/roles/mariadb/templates/mariadb.json.j2 b/ansible/roles/mariadb/templates/mariadb.json.j2 new file mode 100644 index 0000000000..909bcad88b --- /dev/null +++ b/ansible/roles/mariadb/templates/mariadb.json.j2 @@ -0,0 +1,12 @@ +{% set mysql_dir = 'mysql/conf.d' if kolla_base_distro in ['ubuntu', 'debian'] else 'my.cnf.d' %} +{ + "command": "/usr/bin/mysqld_safe", + "config_files": [ + { + "source": "/opt/kolla/config_files/galera.cnf", + "dest": "/etc/{{ mysql_dir }}/galera.cnf", + "owner": "mysql", + "perm": "0600" + } + ] +} diff --git a/docker/mariadb/start.sh b/docker/mariadb/start.sh index 986cca7339..f33dc74938 100755 --- a/docker/mariadb/start.sh +++ b/docker/mariadb/start.sh @@ -2,16 +2,14 @@ set -o errexit -CMD="/usr/bin/mysqld_safe" -ARGS="" - -# loading common functions +# Loading common functions source /opt/kolla/kolla-common.sh -# Execute config strategy -set_configs +# Generate run command +python /opt/kolla/set_configs.py +CMD=$(cat /command_options) -# loading functions +# Loading functions source /opt/kolla/config/config-galera.sh chown mysql: /var/lib/mysql @@ -22,6 +20,9 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]] && [[ ! -e /var/lib/mysql/cluster.exists ]]; t touch /var/lib/mysql/cluster.exists populate_db bootstrap_db + exec $CMD $ARGS + exit 0 fi -exec $CMD $ARGS +echo "Running command: ${CMD}" +exec $CMD