Add condition to os-net-config run during upgrade.

This add two conditionals:
 - first check that os-net-config needs upgrade
 - second verify that the configuration file exist and non empty.

This prevent unnecessary run of os-net-config and error in certain
network configuration.

Change-Id: Ic905f7ed7e7fc9018bc494f77811392045fddfe8
Closes-Bug: #1730328
This commit is contained in:
Sofer Athlan-Guyot 2017-11-06 11:22:54 +01:00
parent e463ca15fb
commit 48aa4ff004
1 changed files with 11 additions and 0 deletions

View File

@ -53,6 +53,16 @@ outputs:
fail: msg="rpm-python package was not present before this run! Check environment before re-running"
when: rpm_python_check.changed != false
tags: step0
- name: Check for os-net-config upgrade
shell: yum check-upgrade | grep os-net-config
register: os_net_config_need_upgrade
ignore_error: True
tags: step3
- name: Check that os-net-config has configuration
shell: test -s /etc/os-net-config/config.json
register: os_net_config_has_config
ignore_error: True
tags: step3
- block:
- name: Upgrade os-net-config
yum: name=os-net-config state=latest
@ -62,6 +72,7 @@ outputs:
failed_when: os_net_config_upgrade.rc not in [0,2]
changed_when: os_net_config_upgrade.rc == 2
tags: step3
when: not os_net_config_need_upgrade.stdout and os_net_config_has_config.rc == 0
- name: Update all packages
tags: step3
yum: name=* state=latest