From 7f81dbc85bb98a943697c62f02d69ece07a1da22 Mon Sep 17 00:00:00 2001 From: Vladislav Belogrudov <vladislav.belogrudov@oracle.com> Date: Fri, 4 Sep 2015 19:47:54 +0300 Subject: [PATCH] Check exit status of bootstrap containers Currently bootstrap containers are waited to exit but are not checked for exit status and ansible runs further tasks. If bootstrapping fails we notice it at much later time. Change-Id: I137fc11b0f9d1f03d2ded08a213e8dbd62741f92 Closes-Bug: #1492337 --- ansible/roles/cinder/tasks/bootstrap.yml | 6 ++++++ ansible/roles/glance/tasks/bootstrap.yml | 6 ++++++ ansible/roles/heat/tasks/bootstrap.yml | 6 ++++++ ansible/roles/keystone/tasks/bootstrap.yml | 6 ++++++ ansible/roles/neutron/tasks/bootstrap.yml | 6 ++++++ ansible/roles/nova/tasks/bootstrap.yml | 6 ++++++ ansible/roles/rabbitmq/tasks/bootstrap.yml | 5 +++++ 7 files changed, 41 insertions(+) diff --git a/ansible/roles/cinder/tasks/bootstrap.yml b/ansible/roles/cinder/tasks/bootstrap.yml index 8a4383fa6..0c6d8954f 100644 --- a/ansible/roles/cinder/tasks/bootstrap.yml +++ b/ansible/roles/cinder/tasks/bootstrap.yml @@ -71,8 +71,14 @@ - name: Waiting for bootstrap container to exit command: docker wait bootstrap_cinder when: database.stdout.find('localhost | SUCCESS => ') != -1 and (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed + register: bootstrap_result run_once: True +- name: Checking for bootstrap failures + fail: msg="Bootstrapping failed" + run_once: True + when: bootstrap_result|changed and bootstrap_result.stdout != "0" + - name: Cleaning up Cinder bootstrap container docker: name: bootstrap_cinder diff --git a/ansible/roles/glance/tasks/bootstrap.yml b/ansible/roles/glance/tasks/bootstrap.yml index ae7e50128..e69d1c27d 100644 --- a/ansible/roles/glance/tasks/bootstrap.yml +++ b/ansible/roles/glance/tasks/bootstrap.yml @@ -70,9 +70,15 @@ # https://github.com/ansible/ansible-modules-core/pull/1031 - name: Waiting for bootstrap container to exit command: docker wait bootstrap_glance + register: bootstrap_result run_once: True when: database.stdout.find('localhost | SUCCESS => ') != -1 and (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed +- name: Checking for bootstrap failures + fail: msg="Bootstrapping failed" + run_once: True + when: bootstrap_result|changed and bootstrap_result.stdout != "0" + - name: Cleaning up Glance bootstrap container docker: name: bootstrap_glance diff --git a/ansible/roles/heat/tasks/bootstrap.yml b/ansible/roles/heat/tasks/bootstrap.yml index 55ca525a1..ba79a360c 100644 --- a/ansible/roles/heat/tasks/bootstrap.yml +++ b/ansible/roles/heat/tasks/bootstrap.yml @@ -57,9 +57,15 @@ # https://github.com/ansible/ansible-modules-core/pull/1031 - name: Waiting for bootstrap container to exit command: docker wait bootstrap_heat + register: bootstrap_result run_once: True when: database.stdout.find('localhost | SUCCESS => ') != -1 and (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed +- name: Checking for bootstrap failures + fail: msg="Bootstrapping failed" + run_once: True + when: bootstrap_result|changed and bootstrap_result.stdout != "0" + - name: Cleaning up Heat boostrap container docker: name: bootstrap_heat diff --git a/ansible/roles/keystone/tasks/bootstrap.yml b/ansible/roles/keystone/tasks/bootstrap.yml index 78da1f2f7..5d58bdd50 100644 --- a/ansible/roles/keystone/tasks/bootstrap.yml +++ b/ansible/roles/keystone/tasks/bootstrap.yml @@ -60,9 +60,15 @@ # https://github.com/ansible/ansible-modules-core/pull/1031 - name: Waiting for Keystone bootstrap container to exit command: docker wait bootstrap_keystone + register: bootstrap_result run_once: True when: database.stdout.find('localhost | SUCCESS => ') != -1 and (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed +- name: Checking for bootstrap failures + fail: msg="Bootstrapping failed" + run_once: True + when: bootstrap_result|changed and bootstrap_result.stdout != "0" + - name: Cleaning up Keystone bootstrap container docker: name: bootstrap_keystone diff --git a/ansible/roles/neutron/tasks/bootstrap.yml b/ansible/roles/neutron/tasks/bootstrap.yml index a422dfc82..c933e2432 100644 --- a/ansible/roles/neutron/tasks/bootstrap.yml +++ b/ansible/roles/neutron/tasks/bootstrap.yml @@ -52,9 +52,15 @@ - name: Waiting for bootstrap container to exit command: docker wait bootstrap_neutron + register: bootstrap_result run_once: True when: database.stdout.find('localhost | SUCCESS => ') != -1 and (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed +- name: Checking for bootstrap failures + fail: msg="Bootstrapping failed" + run_once: True + when: bootstrap_result|changed and bootstrap_result.stdout != "0" + - name: Cleaning up Neutron bootstrap container docker: name: bootstrap_neutron diff --git a/ansible/roles/nova/tasks/bootstrap.yml b/ansible/roles/nova/tasks/bootstrap.yml index 273772f2b..2a95cb028 100644 --- a/ansible/roles/nova/tasks/bootstrap.yml +++ b/ansible/roles/nova/tasks/bootstrap.yml @@ -51,9 +51,15 @@ # https://github.com/ansible/ansible-modules-core/pull/1031 - name: Waiting for bootstrap container to exit command: docker wait bootstrap_nova + register: bootstrap_result run_once: True when: database.stdout.find('localhost | SUCCESS => ') != -1 and (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed +- name: Checking for bootstrap failures + fail: msg="Bootstrapping failed" + run_once: True + when: bootstrap_result|changed and bootstrap_result.stdout != "0" + - name: Cleaning up Nova bootstrap container docker: name: bootstrap_nova diff --git a/ansible/roles/rabbitmq/tasks/bootstrap.yml b/ansible/roles/rabbitmq/tasks/bootstrap.yml index 876015b1b..fc0d71940 100644 --- a/ansible/roles/rabbitmq/tasks/bootstrap.yml +++ b/ansible/roles/rabbitmq/tasks/bootstrap.yml @@ -48,8 +48,13 @@ - name: Waiting for bootstrap container command: docker wait rabbitmq_bootstrap + register: bootstrap_result when: exists.rc != 0 +- name: Checking for bootstrap failures + fail: msg="Bootstrapping failed" + when: bootstrap_result|changed and bootstrap_result.stdout != "0" + - name: Cleaning up bootstrap container docker: image: "{{ rabbitmq_image_full }}" -- GitLab