Prevent the abusive restart of the octavia services

The octavia services were always restarted when running the
ansible-playbook

1. The 'Bring the management port interface up' task should only be run
   if the 'create octavia management interface' task changed.
   Add a when clause that checks the output of the previous task.
2. A 'when' clause compares 2 strings, but one of the strings always
   starts with a whitespace, while the other string doesn't.
   Trim the output of a task to make sure the strings are formatted
   correctly.

Closes-Bug: 1964099
Change-Id: Ic46ba50c7200d5b4eacd1ee8c03d135bdcc2e353
(cherry picked from commit 78d58174c3)
This commit is contained in:
Gregory Thiemonge 2022-03-08 10:55:16 +01:00
parent 92ebc5c62a
commit fde5700210
2 changed files with 4 additions and 1 deletions

View File

@ -13,6 +13,7 @@
template:
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ mgmt_port_dev }}"
src: "ifcfg.j2"
register: octavia_ifcfg_file
- name: Bring the management port interface up
become: true
@ -20,3 +21,5 @@
command: "ifup {{ mgmt_port_dev }}"
notify:
- octavia config updated
when:
- octavia_ifcfg_file.changed|bool

View File

@ -71,7 +71,7 @@
- name: retrieve current ip list
set_fact:
current_ip_list: "{{ config_contents.stdout }}"
current_ip_list: "{{ config_contents.stdout | trim }}"
# This isn't perfect as they execution order will make them not match, but we can avoid a restart
# if things have stayed the same.