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
This commit is contained in:
Jesse Pretorius 2018-05-13 18:59:58 +01:00
parent 5b0612ceb6
commit 00b1a2bb83
2 changed files with 33 additions and 17 deletions

View File

@ -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'])

View File

@ -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"