SUSE: Remove post-up/post-down scripts from default ifcfg files

We do not need to use post-up/post-down scripts in the default ifcfg
files. These scripts are only installed when the ifcfg file handles a
veth pair. So even though we have them in the ifcfg files by default
nothing actually happens when we bring the interface up and down. This
can be very confusing to users who may wonder why we even have these
entries without installing the matching networking scripts.

The previous implementation was not quite correct anyway because
we were using item[0] and item[1] without having nested loops so the
results were sometimes unpredictable.

Change-Id: I14cbf062d67ad4f0e71c0fdeeaa89a4bdc12a4fe
This commit is contained in:
Markos Chandras 2017-05-19 16:11:20 +01:00
parent c6f0af6834
commit 0a40e658cd
2 changed files with 26 additions and 10 deletions

View File

@ -6,5 +6,3 @@ IPADDR={{ item.ip_addr | default('10.1.0.1') }}
NETMASK={{ item.netmask | default('255.255.255.0') }}
STARTMODE='auto'
BOOTPROTO='static'
POST_UP_SCRIPT="compat:suse:{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}"
POST_DOWN_SCRIPTS="compat:suse:{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}"

View File

@ -96,14 +96,32 @@
- item[1].veth_peer is defined
- ansible_pkg_mgr == 'yum'
- name: Put down post-up script for veth-peer interfaces (SUSE)
template:
src: "network_interfaces/rpm_interface_{{ item[0] | default('default') }}.cfg.j2"
dest: "/etc/sysconfig/network/script/{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}"
mode: "0755"
with_nested:
- [ "ifup-post", "ifdown-post" ]
- "{{ bridges }}"
# NOTE(hworang): Nested loops do not work on blocks. See
# https://github.com/ansible/ansible/issues/13262
# As such we need to do that on a per-task basis.
- block:
- name: Put down post-up script for veth-peer interfaces (SUSE)
template:
src: "network_interfaces/rpm_interface_{{ item[0] }}.cfg.j2"
dest: "/etc/sysconfig/network/script/{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}"
mode: "0755"
with_nested:
- [ "ifup-post", "ifdown-post" ]
- "{{ bridges }}"
- name: Configure ifcfg files to use the post-up script (SUSE)
lineinfile:
dest: "/etc/sysconfig/network/script/{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}"
line: POST_UP_SCRIPT=\"compat:suse:{{ item[0] | default('dummy') }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}\"
with_nested:
- [ "ifup-post", "ifdown-post" ]
- "{{ bridges }}"
- name: Configure ifcfg files to use the post-down script (SUSE)
lineinfile:
dest: "/etc/sysconfig/network/script/{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}"
line: POST_DOWN_SCRIPTS=\"compat:suse:{{ item[0] | default('dummy') }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}\"
with_nested:
- [ "ifup-post", "ifdown-post" ]
- "{{ bridges }}"
when:
- item[1].veth_peer is defined
- ansible_pkg_mgr == 'zypper'