From cdfa53ec374a14a2556a2952449e58c13263daff Mon Sep 17 00:00:00 2001 From: Egon Rijpkema Date: Wed, 10 May 2017 11:54:40 +0200 Subject: [PATCH] Moved database initialization to its own script --- roles/mariadb/scripts/initialize_db.sh | 6 ++++++ roles/mariadb/tasks/main.yml | 7 ++----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 roles/mariadb/scripts/initialize_db.sh diff --git a/roles/mariadb/scripts/initialize_db.sh b/roles/mariadb/scripts/initialize_db.sh new file mode 100644 index 0000000..2553e75 --- /dev/null +++ b/roles/mariadb/scripts/initialize_db.sh @@ -0,0 +1,6 @@ +#!/bin/bash +mysql -uroot -pgeheim --host 127.0.0.1 << EOF +CREATE DATABASE IF NOT EXISTS KEYSTONE; +GRANT ALL PRIVILEGES ON KEYSTONE.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone'; +GRANT ALL PRIVILEGES ON KEYSTONE.* TO 'keystone'@'%' IDENTIFIED BY 'keystone'; +EOF diff --git a/roles/mariadb/tasks/main.yml b/roles/mariadb/tasks/main.yml index 7ad4035..578a3d3 100644 --- a/roles/mariadb/tasks/main.yml +++ b/roles/mariadb/tasks/main.yml @@ -14,8 +14,5 @@ systemd: name: mysql.service state: started -- name: create keystone db and credentials. - command: echo "create database if not exists keystone; \n - GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone'; \n - GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystone'" \ - | mysql -uroot -pgeheim --host 127.0.0.1 +- name: Initialize db + script: scripts/initialize_db.sh