From 00b1a2bb834cbef9ad1eff6cc22dbe84ea499f03 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Sun, 13 May 2018 18:59:58 +0100 Subject: [PATCH] Simplify fact setting The conditionals are currently difficult to follow. This simplifies them by splitting the fact setting up and doing a fact refresh after the first one is set. Change-Id: Ieba6845b4ef53012a872cb262f28cda9a36bed38 --- tasks/cinder_install.yml | 36 +++++++++++++++++---------------- tasks/cinder_install_source.yml | 14 +++++++++++++ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/tasks/cinder_install.yml b/tasks/cinder_install.yml index da7e5cfd..0edfc5b1 100644 --- a/tasks/cinder_install.yml +++ b/tasks/cinder_install.yml @@ -13,6 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Record the installation method + ini_file: + dest: "/etc/ansible/facts.d/openstack_ansible.fact" + section: "cinder" + option: "install_method" + value: "{{ cinder_install_method }}" + +- name: Refresh local facts to ensure the cinder section is present + setup: + filter: ansible_local + gather_subset: "!all" + - name: Install distro packages package: name: "{{ cinder_package_list }}" @@ -28,26 +40,16 @@ include_tasks: cinder_install_source.yml when: cinder_install_method == 'source' -- name: Initialise the upgrade facts +- name: Set the upgrade facts ini_file: dest: "/etc/ansible/facts.d/openstack_ansible.fact" section: cinder - option: "{{ item.name }}" - value: "{{ item.state }}" + option: "{{ item }}" + value: true with_items: - - name: "need_online_data_migrations" - state: "True" - - name: "need_service_restart" - state: "True" - - name: "install_method" - state: "{{ cinder_install_method }}" - when: (cinder_install_method == 'source' and - ((cinder_get_venv | changed) or - (cinder_venv_dir | changed))) or + - "need_online_data_migrations" + - "need_service_restart" + when: (install_packages | changed) or - (ansible_local is not defined) or - ('openstack_ansible' not in ansible_local) or - ('cinder' not in ansible_local['openstack_ansible']) or ('need_online_data_migrations' not in ansible_local['openstack_ansible']['cinder']) or - ('need_service_restart' not in ansible_local['openstack_ansible']['cinder']) or - ('install_method' not in ansible_local['openstack_ansible']['cinder']) + ('need_service_restart' not in ansible_local['openstack_ansible']['cinder']) diff --git a/tasks/cinder_install_source.yml b/tasks/cinder_install_source.yml index 4b7b64fe..36d644d1 100644 --- a/tasks/cinder_install_source.yml +++ b/tasks/cinder_install_source.yml @@ -120,6 +120,20 @@ tags: - skip_ansible_lint +- name: Initialise the upgrade facts + ini_file: + dest: "/etc/ansible/facts.d/openstack_ansible.fact" + section: cinder + option: "{{ item }}" + value: true + with_items: + - "need_online_data_migrations" + - "need_service_restart" + when: (cinder_get_venv | changed) or + (cinder_venv_dir | changed) or + ('need_online_data_migrations' not in ansible_local['openstack_ansible']['cinder']) or + ('need_service_restart' not in ansible_local['openstack_ansible']['cinder']) + - name: Record the venv tag deployed ini_file: dest: "/etc/ansible/facts.d/openstack_ansible.fact"