From 033a444fefc1e7131559a444d43131b004de66d3 Mon Sep 17 00:00:00 2001 From: Jeffrey Zhang Date: Fri, 14 Oct 2016 10:47:00 +0800 Subject: [PATCH] Fix ceilometer idempotent bootstrap_service in ceilometer should only be ran once during multi deployment to keep idempotent Partial-Bug: #1633463 Change-Id: Ic5d256e2e887661b4679c4518e8c3865b85189bf --- ansible/roles/ceilometer/tasks/bootstrap.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ansible/roles/ceilometer/tasks/bootstrap.yml b/ansible/roles/ceilometer/tasks/bootstrap.yml index a70e460046..a3c39eaa7f 100644 --- a/ansible/roles/ceilometer/tasks/bootstrap.yml +++ b/ansible/roles/ceilometer/tasks/bootstrap.yml @@ -1,7 +1,7 @@ --- - 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: database + register: mongodb_ceilometer_database run_once: true failed_when: - "'already' not in database.stdout" @@ -18,7 +18,7 @@ login_user='{{ database_user }}' login_password='{{ database_password }}' name='{{ ceilometer_database_name }}'" - register: database + 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' @@ -48,4 +48,8 @@ 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")