Upgrades: Refactor playbooks to set facts

To not to redefine variable multiple times in each service we
run check only once and we set fact. To increase readability of
generated playbook we add block per strep in services.

Change-Id: I2399a72709d240f84e3463c5c3b56942462d1e5c
This commit is contained in:
Lukas Bezdicka
2018-04-17 13:44:18 +02:00
parent e0139adfda
commit 56bec75c02
74 changed files with 1736 additions and 1587 deletions

View File

@@ -205,19 +205,22 @@ outputs:
/var/log/containers/openvswitch.
ignore_errors: true
upgrade_tasks:
- name: Check if ovn_northd is deployed
command: systemctl is-enabled --quiet ovn-northd
- when: step|int == 0
tags: common
ignore_errors: True
register: ovn_northd_enabled
- name: "PreUpgrade step0,validation: Check service ovn_northd is running"
command: systemctl is-active --quiet ovn-northd
when:
- step|int == 0
- ovn_northd_enabled.rc == 0
tags: validation
- name: Stop and disable ovn-northd service
when:
- step|int == 2
- ovn_northd_enabled.rc == 0
service: name=ovn-northd state=stopped enabled=no
block:
- name: Check if ovn_northd is deployed
command: systemctl is-enabled --quiet ovn-northd
ignore_errors: True
register: ovn_northd_enabled_result
- name: Set fact ovn_northd_enabled
set_fact:
ovn_northd_enabled: "{{ ovn_northd_enabled_result.rc == 0 }}"
- name: "PreUpgrade step0,validation: Check service ovn_northd is running"
command: systemctl is-active --quiet ovn-northd
when: ovn_northd_enabled|bool
tags: validation
- when: step|int == 2
block:
- name: Stop and disable ovn-northd service
when: ovn_northd_enabled|bool
service: name=ovn-northd state=stopped enabled=no