a60e47dce7
Users can configure standalone database but bootstrap takes wrong address - instead of cluster VIP it should take ceilometer_database_mysql_address. The latter is set to VIP by default. Change-Id: I7fc789e53565190c1d3b9966dc67f668237ebd83 Closes-Bug: #1634083
56 lines
2.6 KiB
YAML
56 lines
2.6 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.addUser({user':' "{{ ceilometer_database_user }}", pwd':' "{{ ceilometer_database_password}}", roles':' [ "readWrite", "dbAdmin" ]})'
|
|
register: mongodb_ceilometer_database
|
|
run_once: true
|
|
failed_when:
|
|
- "'already' not in database.stdout"
|
|
- database.stdout.split()[4] != 'connecting'
|
|
delegate_to: "{{ groups['mongodb'][0] }}"
|
|
when:
|
|
- ceilometer_database_type == "mongodb"
|
|
|
|
- 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='{{ database_port }}'
|
|
login_user='{{ database_user }}'
|
|
login_password='{{ database_password }}'
|
|
name='{{ ceilometer_database_name }}'"
|
|
register: mysql_ceilometer_database
|
|
changed_when: "{{ database.stdout.find('localhost | SUCCESS => ') != -1 and
|
|
(database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
|
|
failed_when: database.stdout.split()[2] != 'SUCCESS'
|
|
run_once: True
|
|
delegate_to: "{{ groups['ceilometer-api'][0] }}"
|
|
when:
|
|
- ceilometer_database_type == "mysql"
|
|
|
|
- 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='{{ 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"
|
|
|
|
# TODO(Jeffrey4l): fix idempotent when ceilomter_database_type == "gnocchi"
|
|
- include: bootstrap_service.yml
|
|
when: ((ceilometer_database_type == "mongodb" and mongodb_ceilometer_database.changed)
|
|
or (ceilometer_database_type == "mysql" and mysql_ceilometer_database.changed)
|
|
or ceilometer_database_type == "gnocchi")
|