From 705f58fb0b3bd3599e3265a982d7d6235a2d2d8d Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Thu, 8 Mar 2018 21:14:19 +0000 Subject: [PATCH] Only try to stop services that exist Test for the presence of services before trying to stop them. Avoids a delay during initial deploy. Change-Id: Id3ccba83a402074af77b62f67754a834d6f765b7 (cherry picked from commit 966b08123c4b350eb5a47e0ac301d2f89f85cd74) --- tasks/keystone_db_setup.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tasks/keystone_db_setup.yml b/tasks/keystone_db_setup.yml index bf8951d6..9b2235be 100644 --- a/tasks/keystone_db_setup.yml +++ b/tasks/keystone_db_setup.yml @@ -44,25 +44,27 @@ - keystone-config # When keystone is initially built, the service does not yet exist on the -# host this task is executed on. We therefore use failed_when for the task -# to catch a failure that's outside the norm. -- name: Ensure keystone service is stopped +# host this task is executed on. Detect the presence of the services. +- name: Test if keystone service exists service: name: "{{ item }}" + check_mode: yes + register: keystone_service_exists + with_items: "{{ keystone_wsgi_program_names }}" + +- name: Ensure keystone service is stopped + service: + name: "{{ item.name }}" state: stopped register: _stop until: _stop | success retries: 5 delay: 2 - with_items: "{{ keystone_wsgi_program_names }}" + with_items: "{{ keystone_service_exists.results }}" when: - "(ansible_local['openstack_ansible']['keystone']['need_db_expand'] | bool) or (ansible_local['openstack_ansible']['keystone']['need_db_migrate'] | bool)" - failed_when: - - "_stop.msg is defined" - - "'no service or tool' not in _stop.msg" - - "'systemd could not find' not in _stop.msg" - - "'Could not find the requested service' not in _stop.msg" + - "(item.status['LoadState'] == 'loaded' | bool)" notify: - Manage LB - Restart uWSGI