From 19d04fc15d5807574a7685714cbba66b3e546acb Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Fri, 28 Jul 2017 13:03:58 +0100 Subject: [PATCH] tests: bootstrap-host: Add ability to configure networking on SUSE Add ability to configure networking on SUSE. Moreover, since the ifup/ifdown network scripts are not destro specific, we rename them and use them for SUSE as well. Change-Id: I59c16e050b4774b88c397e404f82c176482a3b1f --- .../tasks/prepare_networking.yml | 47 ++++++++++++++++++- ...fg.j2 => rpm_interface_ifdown-post.cfg.j2} | 0 ....cfg.j2 => rpm_interface_ifup-post.cfg.j2} | 0 .../templates/suse_interface_default.cfg.j2 | 8 ++++ 4 files changed, 53 insertions(+), 2 deletions(-) rename tests/roles/bootstrap-host/templates/{redhat_interface_ifdown-post.cfg.j2 => rpm_interface_ifdown-post.cfg.j2} (100%) rename tests/roles/bootstrap-host/templates/{redhat_interface_ifup-post.cfg.j2 => rpm_interface_ifup-post.cfg.j2} (100%) create mode 100644 tests/roles/bootstrap-host/templates/suse_interface_default.cfg.j2 diff --git a/tests/roles/bootstrap-host/tasks/prepare_networking.yml b/tests/roles/bootstrap-host/tasks/prepare_networking.yml index 128955ad1d..5143c596b8 100644 --- a/tests/roles/bootstrap-host/tasks/prepare_networking.yml +++ b/tests/roles/bootstrap-host/tasks/prepare_networking.yml @@ -53,7 +53,7 @@ - name: Put down post-up script for veth-peer interfaces (RedHat) template: - src: "redhat_interface_{{ item[0] | default('default') }}.cfg.j2" + src: "rpm_interface_{{ item[0] }}.cfg.j2" dest: "/etc/sysconfig/network-scripts/{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}" mode: "0755" with_nested: @@ -75,6 +75,49 @@ - item[1].veth_peer is defined - ansible_pkg_mgr in ['yum', 'dnf'] +- name: Copy network configuration (SUSE) + template: + src: "suse_interface_default.cfg.j2" + dest: "/etc/sysconfig/network/ifcfg-{{ item.name | default('br-mgmt') }}" + with_items: "{{ bridges }}" + register: network_interfaces_suse + when: + - ansible_pkg_mgr == 'zypper' + +- name: Put down post-up script for veth-peer interfaces (SUSE) + template: + src: "rpm_interface_{{ item[0] }}.cfg.j2" + dest: "/etc/sysconfig/network/scripts/{{ 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 }}" + when: + - item[1].veth_peer is defined + - ansible_pkg_mgr == 'zypper' + +- name: Ensure the postup scripts are loaded (SUSE) + lineinfile: + dest: "/etc/sysconfig/network/ifcfg-{{ item[1].name | default('br-mgmt') }}" + line: "POST_UP_SCRIPTS=\"compat:suse:{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}\"" + with_nested: + - [ "ifup-post" ] + - "{{ bridges }}" + when: + - item[1].veth_peer is defined + - ansible_pkg_mgr == 'zypper' + +- name: Ensure the postdown scripts are loaded (SUSE) + lineinfile: + dest: "/etc/sysconfig/network/ifcfg-{{ item[1].name | default('br-mgmt') }}" + line: "POST_DOWN_SCRIPTS=\"compat:suse:{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}\"" + with_nested: + - [ "ifdown-post" ] + - "{{ bridges }}" + when: + - item[1].veth_peer is defined + - ansible_pkg_mgr == 'zypper' + - name: Copy multinode network configuration (Debian) template: src: osa_interfaces_multinode.cfg.j2 @@ -131,7 +174,7 @@ - name: Start the network interfaces command: "ifup {{ item.name }}" when: - - osa_interfaces | changed or network_interfaces_rhel | changed + - osa_interfaces | changed or network_interfaces_rhel | changed or network_interfaces_suse | changed - item.enabled | default(True) with_items: - { name: br-mgmt } diff --git a/tests/roles/bootstrap-host/templates/redhat_interface_ifdown-post.cfg.j2 b/tests/roles/bootstrap-host/templates/rpm_interface_ifdown-post.cfg.j2 similarity index 100% rename from tests/roles/bootstrap-host/templates/redhat_interface_ifdown-post.cfg.j2 rename to tests/roles/bootstrap-host/templates/rpm_interface_ifdown-post.cfg.j2 diff --git a/tests/roles/bootstrap-host/templates/redhat_interface_ifup-post.cfg.j2 b/tests/roles/bootstrap-host/templates/rpm_interface_ifup-post.cfg.j2 similarity index 100% rename from tests/roles/bootstrap-host/templates/redhat_interface_ifup-post.cfg.j2 rename to tests/roles/bootstrap-host/templates/rpm_interface_ifup-post.cfg.j2 diff --git a/tests/roles/bootstrap-host/templates/suse_interface_default.cfg.j2 b/tests/roles/bootstrap-host/templates/suse_interface_default.cfg.j2 new file mode 100644 index 0000000000..58d7d5e89d --- /dev/null +++ b/tests/roles/bootstrap-host/templates/suse_interface_default.cfg.j2 @@ -0,0 +1,8 @@ +{% if item.veth_peer is defined %} +# This interface has a veth peer +{% endif %} +BRIDGE='yes' +IPADDR={{ item.ip_addr | default('10.1.0.1') }} +NETMASK={{ item.netmask | default('255.255.255.0') }} +STARTMODE='auto' +BOOTPROTO='static'