summaryrefslogtreecommitdiffstats
path: root/xci/playbooks/roles
diff options
context:
space:
mode:
authorMarkos Chandras <mchandras@suse.de>2017-09-01 15:47:23 +0100
committerMarkos Chandras <mchandras@suse.de>2017-09-17 22:42:43 +0100
commit319262cf70ff518c49ee0d5dfd0ec0ab9088f2e6 (patch)
tree6bf6df3d44041f1b066fdda39c3b36979f2ed7b7 /xci/playbooks/roles
parent8559733be3c0b3274c3671c3ba76affb425bf73f (diff)
xci: configure-network: Add ability to configure network on SUSE hosts
Change-Id: I42c6f5f07ac87b5599758947fabe5fce36d44a2e Signed-off-by: Markos Chandras <mchandras@suse.de>
Diffstat (limited to 'xci/playbooks/roles')
-rwxr-xr-xxci/playbooks/roles/configure-network/files/network-config-suse15
-rw-r--r--xci/playbooks/roles/configure-network/tasks/main.yml49
-rw-r--r--xci/playbooks/roles/configure-network/templates/suse/suse.interface.j217
-rw-r--r--xci/playbooks/roles/configure-network/templates/suse/suse.routes.j21
4 files changed, 77 insertions, 5 deletions
diff --git a/xci/playbooks/roles/configure-network/files/network-config-suse b/xci/playbooks/roles/configure-network/files/network-config-suse
new file mode 100755
index 00000000..1a9f1e7d
--- /dev/null
+++ b/xci/playbooks/roles/configure-network/files/network-config-suse
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+INTERFACE=$1
+ACTION=$4
+
+if [[ $INTERFACE == "br-vlan" ]]; then
+ if [[ $ACTION == "pre-up" ]]; then
+ ip link add br-vlan-veth type veth peer name eth12 || true
+ ip link set br-vlan-veth up
+ ip link set eth12 up
+ else
+ ip link del br-vlan-veth || true
+ fi
+fi
+
diff --git a/xci/playbooks/roles/configure-network/tasks/main.yml b/xci/playbooks/roles/configure-network/tasks/main.yml
index df1580e5..126389d8 100644
--- a/xci/playbooks/roles/configure-network/tasks/main.yml
+++ b/xci/playbooks/roles/configure-network/tasks/main.yml
@@ -7,7 +7,11 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# TODO: this role needs to be adjusted for different distros
+- name: ensure glean rules are removed
+ file:
+ path: "/etc/udev/rules.d/99-glean.rules"
+ state: absent
+
- block:
- name: configure modules
lineinfile:
@@ -19,10 +23,6 @@
modprobe:
name: 8021q
state: present
- - name: ensure glean rules are removed
- file:
- path: "/etc/udev/rules.d/99-glean.rules"
- state: absent
- name: ensure interfaces.d folder is empty
shell: "/bin/rm -rf /etc/network/interfaces.d/*"
- name: ensure interfaces file is updated
@@ -32,3 +32,42 @@
- name: restart network service
shell: "/sbin/ifconfig {{ interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a"
when: ansible_os_family | lower == "debian"
+
+- block:
+ - name: Remove existing network configuration
+ file:
+ path: "/etc/sysconfig/network/{{ item }}"
+ state: absent
+ with_items:
+ - "ifcfg-eth0"
+ - "ifroute-eth0"
+
+ - name: Configure networking on SUSE
+ template:
+ src: "{{ ansible_os_family | lower }}/suse.interface.j2"
+ dest: "/etc/sysconfig/network/ifcfg-{{ item.name }}"
+ with_items:
+ - { name: "{{ interface }}" }
+ - { name: "{{ interface }}.10", vlan_id: 10 }
+ - { name: "{{ interface }}.30", vlan_id: 30 }
+ - { name: "{{ interface }}.20", vlan_id: 20 }
+ - { name: "br-mgmt", bridge_ports: "{{ interface }}.10", ip: "{{ host_info[inventory_hostname].MGMT_IP }}/22" }
+ - { name: "br-vxlan", bridge_ports: "{{ interface }}.30", ip: "{{ host_info[inventory_hostname].VXLAN_IP }}/22" }
+ - { name: "br-vlan", bridge_ports: "{{ interface }}", ip: "{{ host_info[inventory_hostname].VLAN_IP }}/24" }
+ - { name: "br-storage", bridge_ports: "{{ interface }}.20", ip: "{{ host_info[inventory_hostname].STORAGE_IP }}/22" }
+
+ - name: Add postup/postdown scripts on SUSE
+ copy:
+ src: "network-config-suse"
+ dest: "/etc/sysconfig/network/scripts/network-config-suse"
+
+ - name: Configure routes on SUSE
+ template:
+ src: "{{ ansible_os_family | lower }}/suse.routes.j2"
+ dest: "/etc/sysconfig/network/ifroute-{{ item.name }}"
+ with_items:
+ - { name: "br-vlan", gateway: "192.168.122.1", route: "default" }
+
+ - name: restart network service
+ shell: "/usr/sbin/wicked ifreload all"
+ when: ansible_os_family | lower == "suse"
diff --git a/xci/playbooks/roles/configure-network/templates/suse/suse.interface.j2 b/xci/playbooks/roles/configure-network/templates/suse/suse.interface.j2
new file mode 100644
index 00000000..ffa418d4
--- /dev/null
+++ b/xci/playbooks/roles/configure-network/templates/suse/suse.interface.j2
@@ -0,0 +1,17 @@
+STARTMODE='auto'
+BOOTPROTO='static'
+{% if item.vlan_id is defined %}
+ETHERDEVICE={{ interface }}
+VLAN_ID={{ item.vlan_id }}
+{% endif %}
+{% if item.bridge_ports is defined %}
+BRIDGE='yes'
+BRIDGE_FORWARDDELAY='0'
+BRIDGE_STP=off
+BRIDGE_PORTS={{ item.bridge_ports }}
+{% endif %}
+{% if item.ip is defined %}
+IPADDR={{ item.ip }}
+{% endif %}
+PRE_UP_SCRIPT="compat:suse:network-config-suse"
+POST_DOWN_SCRIPT="compat:suse:network-config-suse"
diff --git a/xci/playbooks/roles/configure-network/templates/suse/suse.routes.j2 b/xci/playbooks/roles/configure-network/templates/suse/suse.routes.j2
new file mode 100644
index 00000000..7c868447
--- /dev/null
+++ b/xci/playbooks/roles/configure-network/templates/suse/suse.routes.j2
@@ -0,0 +1 @@
+{{ item.route }} {{ item.gateway }}