a18174b3b4
Change-Id: I63197f8c5646e44a9a7287e644c904a1e227af23
71 lines
3.0 KiB
YAML
71 lines
3.0 KiB
YAML
---
|
|
- name: Creating Panko MongoDB database
|
|
command: docker exec -t mongodb mongo --host {{ panko_database_mongodb_address }} --eval 'db = db.getSiblingDB("{{ panko_database_name }}"); db.createUser({user':' "{{ panko_database_user }}", pwd':' "{{ panko_database_password }}", roles':' [ "readWrite", "dbAdmin" ]})'
|
|
register: mongodb_panko_database
|
|
run_once: true
|
|
failed_when:
|
|
- "'already' not in mongodb_panko_database.stdout"
|
|
- mongodb_panko_database.stdout.split()[4] != 'connecting'
|
|
delegate_to: "{{ groups['mongodb'][0] }}"
|
|
when:
|
|
- panko_database_type == "mongodb"
|
|
|
|
- name: Checking Panko mysql database
|
|
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
|
|
-m mysql_db
|
|
-a "login_host='{{ panko_database_mysql_address }}'
|
|
login_port='{{ panko_database_port }}'
|
|
login_user='{{ panko_database_user }}'
|
|
login_password='{{ panko_database_password }}'
|
|
name='{{ panko_database_name }}'"
|
|
register: mysql_access
|
|
failed_when: False
|
|
changed_when: False
|
|
run_once: True
|
|
when:
|
|
- panko_database_type == "mysql"
|
|
|
|
- name: Creating panko mysql database
|
|
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
|
|
-m mysql_db
|
|
-a "login_host='{{ panko_database_mysql_address }}'
|
|
login_port='{{ panko_database_port }}'
|
|
login_user='{{ database_user }}'
|
|
login_password='{{ database_password }}'
|
|
name='{{ panko_database_name }}'"
|
|
register: mysql_panko_database
|
|
changed_when: "{{ mysql_panko_database.stdout.find('localhost | SUCCESS => ') != -1 and
|
|
(mysql_panko_database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
|
|
failed_when: mysql_panko_database.stdout.split()[2] != 'SUCCESS'
|
|
run_once: True
|
|
delegate_to: "{{ groups['panko-api'][0] }}"
|
|
when:
|
|
- panko_database_type == "mysql"
|
|
- "'FAILED' in mysql_access.stdout"
|
|
|
|
- name: Creating panko database user and setting permissions
|
|
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
|
|
-m mysql_user
|
|
-a "login_host='{{ panko_database_mysql_address }}'
|
|
login_port='{{ panko_database_port }}'
|
|
login_user='{{ database_user }}'
|
|
login_password='{{ database_password }}'
|
|
name='{{ panko_database_name }}'
|
|
password='{{ panko_database_password }}'
|
|
host='%'
|
|
priv='{{ panko_database_name }}.*:ALL'
|
|
append_privs='yes'"
|
|
register: database_user_create
|
|
changed_when: "{{ database_user_create.stdout.find('localhost | SUCCESS => ') != -1 and
|
|
(database_user_create.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
|
|
failed_when: database_user_create.stdout.split()[2] != 'SUCCESS'
|
|
run_once: True
|
|
delegate_to: "{{ groups['panko-api'][0] }}"
|
|
when:
|
|
- panko_database_type == "mysql"
|
|
- "'FAILED' in mysql_access.stdout"
|
|
|
|
- include: bootstrap_service.yml
|
|
when: ((panko_database_type == "mongodb" and mongodb_panko_database.changed)
|
|
or panko_database_type == "mysql" and mysql_panko_database.changed)
|