kolla-ansible/ansible/roles/ceilometer/tasks/bootstrap.yml
liyingjun c6dd71411a Add precheck for ceilometer backend
Currently when set enable_ceilometer: true and enable_mongodb: no,
the deploy will fail with ceilometer database creating error.
Add a precheck to avoid this situation in both prechecks and bootstrap.

Change-Id: I2d46ef9adeb8e028f3c18e6bc2d3752cc39bcb29
Closes-bug: #1605522
2016-09-01 23:23:28 +08:00

17 lines
774 B
YAML

---
- name: Checking backend for ceilometer
local_action: fail msg="No backend enabled for ceilometer. Mongodb is the only supported one for now"
changed_when: false
when: enable_ceilometer | bool and not enable_mongodb | bool
- name: Creating Ceilometer database
command: docker exec -t mongodb mongo --host {{ ceilometer_database_address }} --eval 'db = db.getSiblingDB("{{ ceilometer_database_name }}"); db.addUser({user':' "{{ ceilometer_database_user }}", pwd':' "{{ ceilometer_database_password}}", roles':' [ "readWrite", "dbAdmin" ]})'
register: database
run_once: true
failed_when:
- "'already' not in database.stdout"
- database.stdout.split()[4] != 'connecting'
delegate_to: "{{ groups['mongodb'][0] }}"
- include: bootstrap_service.yml