Fix Creating Ceilometer MongoDB database failed

The check whether 'already' presents in mongodb output
should belong to changed_when.

Change-Id: Ib982a59820d53ccf5439f59df50c1b1938650967
Closes-Bug: #1641113
This commit is contained in:
Duong Ha-Quang 2017-02-24 14:25:40 +07:00
parent 7bf0e3b083
commit 2ade45e1c7

View File

@ -3,9 +3,8 @@
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" ]})' 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 register: mongodb_ceilometer_database
run_once: true run_once: true
failed_when: changed_when: "{{ 'already' not in mongodb_ceilometer_database.stdout }}"
- "'already' not in mongodb_ceilometer_database.stdout" failed_when: "{{ mongodb_ceilometer_database.stdout.split()[4] != 'connecting' }}"
- mongodb_ceilometer_database.stdout.split()[4] != 'connecting'
delegate_to: "{{ groups['mongodb'][0] }}" delegate_to: "{{ groups['mongodb'][0] }}"
when: when:
- ceilometer_database_type == "mongodb" - ceilometer_database_type == "mongodb"