--- - 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 kolla_toolbox: module_name: mysql_db module_args: 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 kolla_toolbox: module_name: mysql_db module_args: login_host: "{{ database_address }}" login_port: "{{ database_port }}" login_user: "{{ database_user }}" login_password: "{{ database_password }}" name: "{{ ceilometer_database_name }}" register: mysql_ceilometer_database 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 kolla_toolbox: module_name: mysql_user module_args: login_host: "{{ database_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" run_once: True delegate_to: "{{ groups['ceilometer-api'][0] }}" when: - ceilometer_database_type == "mysql" - "'FAILED' in mysql_access.stdout" # TODO(Jeffrey4l): fix idempotent when ceilometer_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" and mysql_ceilometer_database.changed ) or ceilometer_database_type == "gnocchi")