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