ce8978884e
This fix adds possibility to configure external mysql database backend with a different set of credentials, i.e. not requiring external db admins to provide or match their passwords if ceilometer user and database already are preconfigured. Change-Id: Icb78e069770adcc6d2437caca173a5852177178f Closes-Bug: #1638238
74 lines
3.3 KiB
YAML
74 lines
3.3 KiB
YAML
---
|
|
- name: Creating Ceilometer MongoDB database
|
|
command: docker exec -t mongodb mongo --host {{ ceilometer_database_mongodb_address }} --eval 'db = db.getSiblingDB("{{ ceilometer_database_name }}"); db.createUser({user':' "{{ ceilometer_database_user }}", pwd':' "{{ ceilometer_database_password}}", roles':' [ "readWrite", "dbAdmin" ]})'
|
|
register: mongodb_ceilometer_database
|
|
run_once: true
|
|
failed_when:
|
|
- "'already' not in mongodb_ceilometer_database.stdout"
|
|
- mongodb_ceilometer_database.stdout.split()[4] != 'connecting'
|
|
delegate_to: "{{ groups['mongodb'][0] }}"
|
|
when:
|
|
- ceilometer_database_type == "mongodb"
|
|
|
|
- name: Checking Ceilometer mysql database
|
|
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
|
|
-m mysql_db
|
|
-a "login_host='{{ ceilometer_database_mysql_address }}'
|
|
login_port='{{ ceilometer_database_port }}'
|
|
login_user='{{ ceilometer_database_user }}'
|
|
login_password='{{ ceilometer_database_password }}'
|
|
name='{{ ceilometer_database_name }}'"
|
|
register: mysql_access
|
|
failed_when: False
|
|
changed_when: False
|
|
run_once: True
|
|
when:
|
|
- ceilometer_database_type == "mysql"
|
|
|
|
- name: Creating Ceilometer mysql database
|
|
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
|
|
-m mysql_db
|
|
-a "login_host='{{ ceilometer_database_mysql_address }}'
|
|
login_port='{{ ceilometer_database_port }}'
|
|
login_user='{{ database_user }}'
|
|
login_password='{{ database_password }}'
|
|
name='{{ ceilometer_database_name }}'"
|
|
register: mysql_ceilometer_database
|
|
changed_when: "{{ mysql_ceilometer_database.stdout.find('localhost | SUCCESS => ') != -1 and
|
|
(mysql_ceilometer_database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
|
|
failed_when: mysql_ceilometer_database.stdout.split()[2] != 'SUCCESS'
|
|
run_once: True
|
|
delegate_to: "{{ groups['ceilometer-api'][0] }}"
|
|
when:
|
|
- ceilometer_database_type == "mysql"
|
|
- "'FAILED' in mysql_access.stdout"
|
|
|
|
- name: Creating Ceilometer database user and setting permissions
|
|
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
|
|
-m mysql_user
|
|
-a "login_host='{{ ceilometer_database_mysql_address }}'
|
|
login_port='{{ ceilometer_database_port }}'
|
|
login_user='{{ database_user }}'
|
|
login_password='{{ database_password }}'
|
|
name='{{ ceilometer_database_name }}'
|
|
password='{{ ceilometer_database_password }}'
|
|
host='%'
|
|
priv='{{ ceilometer_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['ceilometer-api'][0] }}"
|
|
when:
|
|
- ceilometer_database_type == "mysql"
|
|
- "'FAILED' in mysql_access.stdout"
|
|
|
|
# TODO(Jeffrey4l): fix idempotent when ceilomter_database_type == "gnocchi"
|
|
# NOTE(vbel): bootstrapping of mysql db for ceilometer is idempotent
|
|
- include: bootstrap_service.yml
|
|
when: ((ceilometer_database_type == "mongodb" and mongodb_ceilometer_database.changed)
|
|
or ceilometer_database_type == "mysql"
|
|
or ceilometer_database_type == "gnocchi")
|