From cee7a02143a1826479e6444c6fb5f1c2b6074ab7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Fri, 31 Mar 2017 12:50:16 +0000 Subject: [PATCH] Allow the split of install and config If keystone install is done separately from the config (filtering or interruption), a re-run of the role will not mark the venv as changed, and the db sync will not trigger. Here we force a flush on file next to the venv change, and use this file (local fact) as a way to know if a db sync is required. When a dbsync is considered done, i.e after the expand and migrate stages, we mark the db_migrate as done for all the nodes. Change-Id: I318700582a65cc1ea6571d9460fd58bed949a4e9 Depends-On: Ie4a47e85bf31e1ac3a2bd6f0dec510bb24abdbbd --- tasks/keystone_db_setup.yml | 1 + tasks/keystone_install.yml | 10 ++++++++++ tasks/main.yml | 22 ++++++++++++++++++---- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/tasks/keystone_db_setup.yml b/tasks/keystone_db_setup.yml index 9217194d..e4e36bb5 100644 --- a/tasks/keystone_db_setup.yml +++ b/tasks/keystone_db_setup.yml @@ -50,5 +50,6 @@ - name: Check if Keystone DB sync contract is required command: "true" changed_when: keystone_db_sync_check.rc == 4 + register: dbsync notify: - Perform a Keystone DB sync contract diff --git a/tasks/keystone_install.yml b/tasks/keystone_install.yml index 7b50c9b0..83c19d1f 100644 --- a/tasks/keystone_install.yml +++ b/tasks/keystone_install.yml @@ -251,3 +251,13 @@ dest: admin - src: "{{ keystone_bin }}/keystone-wsgi-public" dest: main + +- name: Record the need for a db sync + ini_file: + dest: /etc/ansible/facts.d/keystone.fact + section: general + option: need_db_sync + value: True + when: keystone_get_venv | changed or + keystone_venv_dir | changed or + install_packages | changed diff --git a/tasks/main.yml b/tasks/main.yml index 7e9ce196..a6fa6519 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -50,6 +50,12 @@ tags: - keystone-install +- name: refresh local facts + setup: + filter: ansible_local + tags: + - keystone-config + - include: keystone_post_install.yml tags: - keystone-config @@ -81,10 +87,18 @@ - include: keystone_db_setup.yml when: - keystone_database_enabled | bool - - inventory_hostname == groups['keystone_all'][0] - - (keystone_get_venv is defined and keystone_get_venv | changed) or - (keystone_venv_dir is defined and keystone_venv_dir | changed) or - (install_packages is defined and install_packages | changed) + - inventory_hostname == ansible_play_hosts[0] + - ansible_local.keystone.general.need_db_sync | bool + tags: + - keystone-config + +- name: Disable the need of a db sync on all nodes + ini_file: + dest: /etc/ansible/facts.d/keystone.fact + section: general + option: need_db_sync + value: False + when: dbsync | succeeded tags: - keystone-config