From 7dd14e002128b5e6fe5302e6f7fe8620682a7d53 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 13 Mar 2018 10:30:16 +0000 Subject: xci: Merge configure-network and syncronize-time roles Those roles were too small and only used as part of the host bootstrapping process. As such, we merge them into a common 'bootstrap-host' role which can be used to prepare the hosts after the initial deployment Change-Id: Ifc84cf40b98ced91b31aae699dc28e9642380550 Signed-off-by: Markos Chandras --- xci/playbooks/roles/.gitignore | 3 +- .../roles/bootstrap-host/defaults/main.yml | 11 ++ .../roles/bootstrap-host/files/network-config-suse | 17 +++ xci/playbooks/roles/bootstrap-host/tasks/main.yml | 15 +++ .../roles/bootstrap-host/tasks/network.yml | 132 +++++++++++++++++++++ xci/playbooks/roles/bootstrap-host/tasks/time.yml | 23 ++++ .../templates/debian/compute00.interface.j2 | 75 ++++++++++++ .../templates/debian/compute01.interface.j2 | 1 + .../templates/debian/controller00.interface.j2 | 74 ++++++++++++ .../templates/debian/controller01.interface.j2 | 1 + .../templates/debian/controller02.interface.j2 | 1 + .../templates/debian/opnfv.interface.j2 | 66 +++++++++++ .../templates/redhat/bridge.ifcfg.j2 | 9 ++ .../templates/redhat/interface.ifcfg.j2 | 10 ++ .../templates/suse/suse.interface.j2 | 17 +++ .../bootstrap-host/templates/suse/suse.routes.j2 | 1 + .../configure-network/files/network-config-suse | 17 --- .../roles/configure-network/tasks/main.yml | 132 --------------------- .../templates/debian/compute00.interface.j2 | 75 ------------ .../templates/debian/compute01.interface.j2 | 1 - .../templates/debian/controller00.interface.j2 | 74 ------------ .../templates/debian/controller01.interface.j2 | 1 - .../templates/debian/controller02.interface.j2 | 1 - .../templates/debian/opnfv.interface.j2 | 66 ----------- .../templates/redhat/bridge.ifcfg.j2 | 9 -- .../templates/redhat/interface.ifcfg.j2 | 10 -- .../templates/suse/suse.interface.j2 | 17 --- .../templates/suse/suse.routes.j2 | 1 - .../roles/synchronize-time/tasks/main.yml | 23 ---- 29 files changed, 454 insertions(+), 429 deletions(-) create mode 100644 xci/playbooks/roles/bootstrap-host/defaults/main.yml create mode 100755 xci/playbooks/roles/bootstrap-host/files/network-config-suse create mode 100644 xci/playbooks/roles/bootstrap-host/tasks/main.yml create mode 100644 xci/playbooks/roles/bootstrap-host/tasks/network.yml create mode 100644 xci/playbooks/roles/bootstrap-host/tasks/time.yml create mode 100644 xci/playbooks/roles/bootstrap-host/templates/debian/compute00.interface.j2 create mode 120000 xci/playbooks/roles/bootstrap-host/templates/debian/compute01.interface.j2 create mode 100644 xci/playbooks/roles/bootstrap-host/templates/debian/controller00.interface.j2 create mode 120000 xci/playbooks/roles/bootstrap-host/templates/debian/controller01.interface.j2 create mode 120000 xci/playbooks/roles/bootstrap-host/templates/debian/controller02.interface.j2 create mode 100644 xci/playbooks/roles/bootstrap-host/templates/debian/opnfv.interface.j2 create mode 100644 xci/playbooks/roles/bootstrap-host/templates/redhat/bridge.ifcfg.j2 create mode 100644 xci/playbooks/roles/bootstrap-host/templates/redhat/interface.ifcfg.j2 create mode 100644 xci/playbooks/roles/bootstrap-host/templates/suse/suse.interface.j2 create mode 100644 xci/playbooks/roles/bootstrap-host/templates/suse/suse.routes.j2 delete mode 100755 xci/playbooks/roles/configure-network/files/network-config-suse delete mode 100644 xci/playbooks/roles/configure-network/tasks/main.yml delete mode 100644 xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 delete mode 120000 xci/playbooks/roles/configure-network/templates/debian/compute01.interface.j2 delete mode 100644 xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 delete mode 120000 xci/playbooks/roles/configure-network/templates/debian/controller01.interface.j2 delete mode 120000 xci/playbooks/roles/configure-network/templates/debian/controller02.interface.j2 delete mode 100644 xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 delete mode 100644 xci/playbooks/roles/configure-network/templates/redhat/bridge.ifcfg.j2 delete mode 100644 xci/playbooks/roles/configure-network/templates/redhat/interface.ifcfg.j2 delete mode 100644 xci/playbooks/roles/configure-network/templates/suse/suse.interface.j2 delete mode 100644 xci/playbooks/roles/configure-network/templates/suse/suse.routes.j2 delete mode 100644 xci/playbooks/roles/synchronize-time/tasks/main.yml (limited to 'xci/playbooks/roles') diff --git a/xci/playbooks/roles/.gitignore b/xci/playbooks/roles/.gitignore index e0b47770..296233e0 100644 --- a/xci/playbooks/roles/.gitignore +++ b/xci/playbooks/roles/.gitignore @@ -1,8 +1,7 @@ * !.gitignore !clone-repository/ -!configure-network/ +!bootstrap-host/ !configure-nfs/ !prepare-functest/ !remote-folders/ -!synchronize-time/ diff --git a/xci/playbooks/roles/bootstrap-host/defaults/main.yml b/xci/playbooks/roles/bootstrap-host/defaults/main.yml new file mode 100644 index 00000000..8e5a0e34 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/defaults/main.yml @@ -0,0 +1,11 @@ +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2018 SUSE Linux GmbH and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +configure_network: yes +configure_time: yes diff --git a/xci/playbooks/roles/bootstrap-host/files/network-config-suse b/xci/playbooks/roles/bootstrap-host/files/network-config-suse new file mode 100755 index 00000000..02cdd998 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/files/network-config-suse @@ -0,0 +1,17 @@ +#!/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 + brctl addif br-vlan br-vlan-veth + else + brctl delif br-vlan br-vlan-veth + ip link del br-vlan-veth || true + fi +fi + diff --git a/xci/playbooks/roles/bootstrap-host/tasks/main.yml b/xci/playbooks/roles/bootstrap-host/tasks/main.yml new file mode 100644 index 00000000..7d6d259e --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/tasks/main.yml @@ -0,0 +1,15 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2018 SUSE Linx GmbH and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +- include: network.yml + when: configure_network + +- include: time.yml + when: configure_time diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network.yml b/xci/playbooks/roles/bootstrap-host/tasks/network.yml new file mode 100644 index 00000000..01edf459 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/tasks/network.yml @@ -0,0 +1,132 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2017 Ericsson AB and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +- name: ensure glean rules are removed + file: + path: "/etc/udev/rules.d/99-glean.rules" + state: absent + +- name: Determine required packages + set_fact: + network_packages: + - bridge-utils + - "{{ (ansible_pkg_mgr in ['zypper', 'apt']) | ternary('iproute2', 'iproute') }}" + - "{{ (ansible_pkg_mgr == 'apt') | ternary('vlan', 'bridge-utils') }}" + - iptables + +- name: Ensure networking packages are present + package: + name: "{{ network_packages }}" + state: present + +- block: + - name: configure modules + lineinfile: + dest: /etc/modules + state: present + create: yes + line: "8021q" + - name: add modules + modprobe: + name: 8021q + state: present + - name: ensure interfaces.d folder is empty + shell: "/bin/rm -rf /etc/network/interfaces.d/*" + - name: ensure interfaces file is updated + template: + src: "{{ ansible_os_family | lower }}/{{ ansible_hostname }}.interface.j2" + dest: "/etc/network/interfaces" + - name: restart network service + shell: "/sbin/ifconfig {{ ansible_default_ipv4.interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a" + async: 15 + poll: 0 + 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: "{{ ansible_default_ipv4.interface }}" } + - { name: "{{ ansible_default_ipv4.interface }}.10", vlan_id: 10 } + - { name: "{{ ansible_default_ipv4.interface }}.30", vlan_id: 30 } + - { name: "{{ ansible_default_ipv4.interface }}.20", vlan_id: 20 } + - { name: "br-mgmt", bridge_ports: "{{ ansible_default_ipv4.interface }}.10", ip: "{{ host_info[inventory_hostname].MGMT_IP }}/22" } + - { name: "br-vxlan", bridge_ports: "{{ ansible_default_ipv4.interface }}.30", ip: "{{ host_info[inventory_hostname].VXLAN_IP }}/22" } + - { name: "br-vlan", bridge_ports: "{{ ansible_default_ipv4.interface }}", ip: "{{ host_info[inventory_hostname].VLAN_IP }}/24" } + - { name: "br-storage", bridge_ports: "{{ ansible_default_ipv4.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" + mode: 0755 + + - 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 + service: + name: network + state: restarted + async: 15 + poll: 0 + when: ansible_os_family | lower == "suse" + +- block: + - name: Configure networking on CentOS for interfaces + template: + src: "{{ ansible_os_family | lower }}/interface.ifcfg.j2" + dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name }}" + with_items: + - { name: "{{ ansible_default_ipv4.interface }}" , bridge: "br-vlan" } + - { name: "{{ ansible_default_ipv4.interface }}.10", bridge: "br-mgmt" , vlan_id: 10 } + - { name: "{{ ansible_default_ipv4.interface }}.20", bridge: "br-storage", vlan_id: 20 } + - { name: "{{ ansible_default_ipv4.interface }}.30", bridge: "br-vxlan" , vlan_id: 30 } + - name: Configure networking on CentOS for bridges + template: + src: "{{ ansible_os_family | lower }}/bridge.ifcfg.j2" + dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name }}" + with_items: + - { name: "br-vlan" , ip: "{{ host_info[inventory_hostname].VLAN_IP }}", prefix: 24 } + - { name: "br-mgmt" , ip: "{{ host_info[inventory_hostname].MGMT_IP }}", prefix: 22 } + - { name: "br-storage", ip: "{{ host_info[inventory_hostname].STORAGE_IP }}", prefix: 22 } + - { name: "br-vxlan" , ip: "{{ host_info[inventory_hostname].VXLAN_IP }}", prefix: 22 } + - name: Add default route through br-vlan + lineinfile: + path: "/etc/sysconfig/network-scripts/ifcfg-br-vlan" + line: "GATEWAY=192.168.122.1" + - name: restart network service + service: + name: network + state: restarted + async: 15 + poll: 0 + when: ansible_os_family | lower == "redhat" + +- local_action: + module: wait_for + host: "{{ ansible_host }}" + delay: 15 + state: started + port: 22 + connect_timeout: 10 + timeout: 180 diff --git a/xci/playbooks/roles/bootstrap-host/tasks/time.yml b/xci/playbooks/roles/bootstrap-host/tasks/time.yml new file mode 100644 index 00000000..8f94d33f --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/tasks/time.yml @@ -0,0 +1,23 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2017 Ericsson AB and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +- name: install chrony + package: + name: "chrony" + state: latest +- name: restart chrony + service: + name: "{{ (ansible_pkg_mgr == 'apt') | ternary('chrony', 'chronyd') }}" + state: restarted +- name: synchronize time + shell: "chronyc -a 'burst 4/4' && chronyc -a makestep" + register: chrony_got_time + until: chrony_got_time.rc == 0 + retries: 5 + delay: 5 diff --git a/xci/playbooks/roles/bootstrap-host/templates/debian/compute00.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/debian/compute00.interface.j2 new file mode 100644 index 00000000..2da12f20 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/debian/compute00.interface.j2 @@ -0,0 +1,75 @@ +# {{ ansible_managed }} + +# The loopback network interface +auto lo +iface lo inet loopback + +# Physical interface +auto {{ ansible_default_ipv4.interface }} +iface {{ ansible_default_ipv4.interface }} inet manual + +# Container/Host management VLAN interface +auto {{ ansible_default_ipv4.interface }}.10 +iface {{ ansible_default_ipv4.interface }}.10 inet manual + vlan-raw-device {{ ansible_default_ipv4.interface }} + +# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface +auto {{ ansible_default_ipv4.interface }}.30 +iface {{ ansible_default_ipv4.interface }}.30 inet manual + vlan-raw-device {{ ansible_default_ipv4.interface }} + +# Storage network VLAN interface +auto {{ ansible_default_ipv4.interface }}.20 +iface {{ ansible_default_ipv4.interface }}.20 inet manual + vlan-raw-device {{ ansible_default_ipv4.interface }} + +# Container/Host management bridge +auto br-mgmt +iface br-mgmt inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }}.10 + address {{host_info[inventory_hostname].MGMT_IP}} + netmask 255.255.252.0 + +# compute1 VXLAN (tunnel/overlay) bridge config +auto br-vxlan +iface br-vxlan inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }}.30 + address {{host_info[inventory_hostname].VXLAN_IP}} + netmask 255.255.252.0 + +# OpenStack Networking VLAN bridge +auto br-vlan +iface br-vlan inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }} + address {{host_info[inventory_hostname].VLAN_IP}} + netmask 255.255.255.0 + gateway 192.168.122.1 + dns-nameserver 8.8.8.8 8.8.4.4 + offload-sg off + # Create veth pair, don't bomb if already exists + pre-up ip link add br-vlan-veth type veth peer name eth12 || true + # Set both ends UP + pre-up ip link set br-vlan-veth up + pre-up ip link set eth12 up + # Delete veth pair on DOWN + post-down ip link del br-vlan-veth || true + bridge_ports br-vlan-veth + +# OpenStack Storage bridge +auto br-storage +iface br-storage inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }}.20 + address {{host_info[inventory_hostname].STORAGE_IP}} + netmask 255.255.252.0 diff --git a/xci/playbooks/roles/bootstrap-host/templates/debian/compute01.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/debian/compute01.interface.j2 new file mode 120000 index 00000000..a74df1c2 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/debian/compute01.interface.j2 @@ -0,0 +1 @@ +compute00.interface.j2 \ No newline at end of file diff --git a/xci/playbooks/roles/bootstrap-host/templates/debian/controller00.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/debian/controller00.interface.j2 new file mode 100644 index 00000000..c540f66e --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/debian/controller00.interface.j2 @@ -0,0 +1,74 @@ +# {{ ansible_managed }} + +# The loopback network interface +auto lo +iface lo inet loopback + +# Physical interface +auto {{ ansible_default_ipv4.interface }} +iface {{ ansible_default_ipv4.interface }} inet manual + +# Container/Host management VLAN interface +auto {{ ansible_default_ipv4.interface }}.10 +iface {{ ansible_default_ipv4.interface }}.10 inet manual + vlan-raw-device {{ ansible_default_ipv4.interface }} + +# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface +auto {{ ansible_default_ipv4.interface }}.30 +iface {{ ansible_default_ipv4.interface }}.30 inet manual + vlan-raw-device {{ ansible_default_ipv4.interface }} + +# Storage network VLAN interface (optional) +auto {{ ansible_default_ipv4.interface }}.20 +iface {{ ansible_default_ipv4.interface }}.20 inet manual + vlan-raw-device {{ ansible_default_ipv4.interface }} + +# Container/Host management bridge +auto br-mgmt +iface br-mgmt inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }}.10 + address {{host_info[inventory_hostname].MGMT_IP}} + netmask 255.255.252.0 + +# OpenStack Networking VXLAN (tunnel/overlay) bridge +auto br-vxlan +iface br-vxlan inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }}.30 + address {{host_info[inventory_hostname].VXLAN_IP}} + netmask 255.255.252.0 + +# OpenStack Networking VLAN bridge +auto br-vlan +iface br-vlan inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }} + address {{host_info[inventory_hostname].VLAN_IP}} + netmask 255.255.255.0 + gateway 192.168.122.1 + dns-nameserver 8.8.8.8 8.8.4.4 + # Create veth pair, don't bomb if already exists + pre-up ip link add br-vlan-veth type veth peer name eth12 || true + # Set both ends UP + pre-up ip link set br-vlan-veth up + pre-up ip link set eth12 up + # Delete veth pair on DOWN + post-down ip link del br-vlan-veth || true + bridge_ports br-vlan-veth + +# OpenStack Storage bridge +auto br-storage +iface br-storage inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }}.20 + address {{host_info[inventory_hostname].STORAGE_IP}} + netmask 255.255.252.0 diff --git a/xci/playbooks/roles/bootstrap-host/templates/debian/controller01.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/debian/controller01.interface.j2 new file mode 120000 index 00000000..e835d7ca --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/debian/controller01.interface.j2 @@ -0,0 +1 @@ +controller00.interface.j2 \ No newline at end of file diff --git a/xci/playbooks/roles/bootstrap-host/templates/debian/controller02.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/debian/controller02.interface.j2 new file mode 120000 index 00000000..e835d7ca --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/debian/controller02.interface.j2 @@ -0,0 +1 @@ +controller00.interface.j2 \ No newline at end of file diff --git a/xci/playbooks/roles/bootstrap-host/templates/debian/opnfv.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/debian/opnfv.interface.j2 new file mode 100644 index 00000000..03f81dbb --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/debian/opnfv.interface.j2 @@ -0,0 +1,66 @@ +# {{ ansible_managed }} + +# The loopback network interface +auto lo +iface lo inet loopback + +# Physical interface +auto {{ ansible_default_ipv4.interface }} +iface {{ ansible_default_ipv4.interface }} inet manual + +# Container/Host management VLAN interface +auto {{ ansible_default_ipv4.interface }}.10 +iface {{ ansible_default_ipv4.interface }}.10 inet manual + vlan-raw-device {{ ansible_default_ipv4.interface }} + +# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface +auto {{ ansible_default_ipv4.interface }}.30 +iface {{ ansible_default_ipv4.interface }}.30 inet manual + vlan-raw-device {{ ansible_default_ipv4.interface }} + +# Storage network VLAN interface (optional) +auto {{ ansible_default_ipv4.interface }}.20 +iface {{ ansible_default_ipv4.interface }}.20 inet manual + vlan-raw-device {{ ansible_default_ipv4.interface }} + +# Container/Host management bridge +auto br-mgmt +iface br-mgmt inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }}.10 + address {{host_info[inventory_hostname].MGMT_IP}} + netmask 255.255.252.0 + +# OpenStack Networking VXLAN (tunnel/overlay) bridge +auto br-vxlan +iface br-vxlan inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }}.30 + address {{ host_info[inventory_hostname].VXLAN_IP }} + netmask 255.255.252.0 + +# OpenStack Networking VLAN bridge +auto br-vlan +iface br-vlan inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }} + address {{host_info[inventory_hostname].VLAN_IP}} + netmask 255.255.255.0 + gateway 192.168.122.1 + dns-nameserver 8.8.8.8 8.8.4.4 + +# OpenStack Storage bridge +auto br-storage +iface br-storage inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ ansible_default_ipv4.interface }}.20 + address {{host_info[inventory_hostname].STORAGE_IP}} + netmask 255.255.252.0 diff --git a/xci/playbooks/roles/bootstrap-host/templates/redhat/bridge.ifcfg.j2 b/xci/playbooks/roles/bootstrap-host/templates/redhat/bridge.ifcfg.j2 new file mode 100644 index 00000000..06b5f177 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/redhat/bridge.ifcfg.j2 @@ -0,0 +1,9 @@ +DEVICE={{ item.name }} +NM_CONTROLLED=no +IPADDR={{ item.ip }} +PREFIX={{ item.prefix }} +ONBOOT=yes +BOOTPROTO=none +TYPE=Bridge +DELAY=0 +STP=off diff --git a/xci/playbooks/roles/bootstrap-host/templates/redhat/interface.ifcfg.j2 b/xci/playbooks/roles/bootstrap-host/templates/redhat/interface.ifcfg.j2 new file mode 100644 index 00000000..a97ad0cf --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/redhat/interface.ifcfg.j2 @@ -0,0 +1,10 @@ +DEVICE={{ item.name }} +NM_CONTROLLED=no +ONBOOT=yes +BOOTPROTO=none +{% if item.vlan_id is defined %} +VLAN=yes +ETHERDEVICE={{ ansible_default_ipv4.interface }} +VLAN_ID={{ item.vlan_id }} +{% endif %} +BRIDGE={{ item.bridge }} diff --git a/xci/playbooks/roles/bootstrap-host/templates/suse/suse.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/suse/suse.interface.j2 new file mode 100644 index 00000000..27b01eb4 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/suse/suse.interface.j2 @@ -0,0 +1,17 @@ +STARTMODE='auto' +BOOTPROTO='static' +{% if item.vlan_id is defined %} +ETHERDEVICE={{ ansible_default_ipv4.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/bootstrap-host/templates/suse/suse.routes.j2 b/xci/playbooks/roles/bootstrap-host/templates/suse/suse.routes.j2 new file mode 100644 index 00000000..7c868447 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/suse/suse.routes.j2 @@ -0,0 +1 @@ +{{ item.route }} {{ item.gateway }} diff --git a/xci/playbooks/roles/configure-network/files/network-config-suse b/xci/playbooks/roles/configure-network/files/network-config-suse deleted file mode 100755 index 02cdd998..00000000 --- a/xci/playbooks/roles/configure-network/files/network-config-suse +++ /dev/null @@ -1,17 +0,0 @@ -#!/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 - brctl addif br-vlan br-vlan-veth - else - brctl delif br-vlan br-vlan-veth - 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 deleted file mode 100644 index 01edf459..00000000 --- a/xci/playbooks/roles/configure-network/tasks/main.yml +++ /dev/null @@ -1,132 +0,0 @@ ---- -# SPDX-license-identifier: Apache-2.0 -############################################################################## -# Copyright (c) 2017 Ericsson AB and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## -- name: ensure glean rules are removed - file: - path: "/etc/udev/rules.d/99-glean.rules" - state: absent - -- name: Determine required packages - set_fact: - network_packages: - - bridge-utils - - "{{ (ansible_pkg_mgr in ['zypper', 'apt']) | ternary('iproute2', 'iproute') }}" - - "{{ (ansible_pkg_mgr == 'apt') | ternary('vlan', 'bridge-utils') }}" - - iptables - -- name: Ensure networking packages are present - package: - name: "{{ network_packages }}" - state: present - -- block: - - name: configure modules - lineinfile: - dest: /etc/modules - state: present - create: yes - line: "8021q" - - name: add modules - modprobe: - name: 8021q - state: present - - name: ensure interfaces.d folder is empty - shell: "/bin/rm -rf /etc/network/interfaces.d/*" - - name: ensure interfaces file is updated - template: - src: "{{ ansible_os_family | lower }}/{{ ansible_hostname }}.interface.j2" - dest: "/etc/network/interfaces" - - name: restart network service - shell: "/sbin/ifconfig {{ ansible_default_ipv4.interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a" - async: 15 - poll: 0 - 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: "{{ ansible_default_ipv4.interface }}" } - - { name: "{{ ansible_default_ipv4.interface }}.10", vlan_id: 10 } - - { name: "{{ ansible_default_ipv4.interface }}.30", vlan_id: 30 } - - { name: "{{ ansible_default_ipv4.interface }}.20", vlan_id: 20 } - - { name: "br-mgmt", bridge_ports: "{{ ansible_default_ipv4.interface }}.10", ip: "{{ host_info[inventory_hostname].MGMT_IP }}/22" } - - { name: "br-vxlan", bridge_ports: "{{ ansible_default_ipv4.interface }}.30", ip: "{{ host_info[inventory_hostname].VXLAN_IP }}/22" } - - { name: "br-vlan", bridge_ports: "{{ ansible_default_ipv4.interface }}", ip: "{{ host_info[inventory_hostname].VLAN_IP }}/24" } - - { name: "br-storage", bridge_ports: "{{ ansible_default_ipv4.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" - mode: 0755 - - - 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 - service: - name: network - state: restarted - async: 15 - poll: 0 - when: ansible_os_family | lower == "suse" - -- block: - - name: Configure networking on CentOS for interfaces - template: - src: "{{ ansible_os_family | lower }}/interface.ifcfg.j2" - dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name }}" - with_items: - - { name: "{{ ansible_default_ipv4.interface }}" , bridge: "br-vlan" } - - { name: "{{ ansible_default_ipv4.interface }}.10", bridge: "br-mgmt" , vlan_id: 10 } - - { name: "{{ ansible_default_ipv4.interface }}.20", bridge: "br-storage", vlan_id: 20 } - - { name: "{{ ansible_default_ipv4.interface }}.30", bridge: "br-vxlan" , vlan_id: 30 } - - name: Configure networking on CentOS for bridges - template: - src: "{{ ansible_os_family | lower }}/bridge.ifcfg.j2" - dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name }}" - with_items: - - { name: "br-vlan" , ip: "{{ host_info[inventory_hostname].VLAN_IP }}", prefix: 24 } - - { name: "br-mgmt" , ip: "{{ host_info[inventory_hostname].MGMT_IP }}", prefix: 22 } - - { name: "br-storage", ip: "{{ host_info[inventory_hostname].STORAGE_IP }}", prefix: 22 } - - { name: "br-vxlan" , ip: "{{ host_info[inventory_hostname].VXLAN_IP }}", prefix: 22 } - - name: Add default route through br-vlan - lineinfile: - path: "/etc/sysconfig/network-scripts/ifcfg-br-vlan" - line: "GATEWAY=192.168.122.1" - - name: restart network service - service: - name: network - state: restarted - async: 15 - poll: 0 - when: ansible_os_family | lower == "redhat" - -- local_action: - module: wait_for - host: "{{ ansible_host }}" - delay: 15 - state: started - port: 22 - connect_timeout: 10 - timeout: 180 diff --git a/xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 deleted file mode 100644 index 2da12f20..00000000 --- a/xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 +++ /dev/null @@ -1,75 +0,0 @@ -# {{ ansible_managed }} - -# The loopback network interface -auto lo -iface lo inet loopback - -# Physical interface -auto {{ ansible_default_ipv4.interface }} -iface {{ ansible_default_ipv4.interface }} inet manual - -# Container/Host management VLAN interface -auto {{ ansible_default_ipv4.interface }}.10 -iface {{ ansible_default_ipv4.interface }}.10 inet manual - vlan-raw-device {{ ansible_default_ipv4.interface }} - -# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface -auto {{ ansible_default_ipv4.interface }}.30 -iface {{ ansible_default_ipv4.interface }}.30 inet manual - vlan-raw-device {{ ansible_default_ipv4.interface }} - -# Storage network VLAN interface -auto {{ ansible_default_ipv4.interface }}.20 -iface {{ ansible_default_ipv4.interface }}.20 inet manual - vlan-raw-device {{ ansible_default_ipv4.interface }} - -# Container/Host management bridge -auto br-mgmt -iface br-mgmt inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }}.10 - address {{host_info[inventory_hostname].MGMT_IP}} - netmask 255.255.252.0 - -# compute1 VXLAN (tunnel/overlay) bridge config -auto br-vxlan -iface br-vxlan inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }}.30 - address {{host_info[inventory_hostname].VXLAN_IP}} - netmask 255.255.252.0 - -# OpenStack Networking VLAN bridge -auto br-vlan -iface br-vlan inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }} - address {{host_info[inventory_hostname].VLAN_IP}} - netmask 255.255.255.0 - gateway 192.168.122.1 - dns-nameserver 8.8.8.8 8.8.4.4 - offload-sg off - # Create veth pair, don't bomb if already exists - pre-up ip link add br-vlan-veth type veth peer name eth12 || true - # Set both ends UP - pre-up ip link set br-vlan-veth up - pre-up ip link set eth12 up - # Delete veth pair on DOWN - post-down ip link del br-vlan-veth || true - bridge_ports br-vlan-veth - -# OpenStack Storage bridge -auto br-storage -iface br-storage inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }}.20 - address {{host_info[inventory_hostname].STORAGE_IP}} - netmask 255.255.252.0 diff --git a/xci/playbooks/roles/configure-network/templates/debian/compute01.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/compute01.interface.j2 deleted file mode 120000 index a74df1c2..00000000 --- a/xci/playbooks/roles/configure-network/templates/debian/compute01.interface.j2 +++ /dev/null @@ -1 +0,0 @@ -compute00.interface.j2 \ No newline at end of file diff --git a/xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 deleted file mode 100644 index c540f66e..00000000 --- a/xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 +++ /dev/null @@ -1,74 +0,0 @@ -# {{ ansible_managed }} - -# The loopback network interface -auto lo -iface lo inet loopback - -# Physical interface -auto {{ ansible_default_ipv4.interface }} -iface {{ ansible_default_ipv4.interface }} inet manual - -# Container/Host management VLAN interface -auto {{ ansible_default_ipv4.interface }}.10 -iface {{ ansible_default_ipv4.interface }}.10 inet manual - vlan-raw-device {{ ansible_default_ipv4.interface }} - -# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface -auto {{ ansible_default_ipv4.interface }}.30 -iface {{ ansible_default_ipv4.interface }}.30 inet manual - vlan-raw-device {{ ansible_default_ipv4.interface }} - -# Storage network VLAN interface (optional) -auto {{ ansible_default_ipv4.interface }}.20 -iface {{ ansible_default_ipv4.interface }}.20 inet manual - vlan-raw-device {{ ansible_default_ipv4.interface }} - -# Container/Host management bridge -auto br-mgmt -iface br-mgmt inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }}.10 - address {{host_info[inventory_hostname].MGMT_IP}} - netmask 255.255.252.0 - -# OpenStack Networking VXLAN (tunnel/overlay) bridge -auto br-vxlan -iface br-vxlan inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }}.30 - address {{host_info[inventory_hostname].VXLAN_IP}} - netmask 255.255.252.0 - -# OpenStack Networking VLAN bridge -auto br-vlan -iface br-vlan inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }} - address {{host_info[inventory_hostname].VLAN_IP}} - netmask 255.255.255.0 - gateway 192.168.122.1 - dns-nameserver 8.8.8.8 8.8.4.4 - # Create veth pair, don't bomb if already exists - pre-up ip link add br-vlan-veth type veth peer name eth12 || true - # Set both ends UP - pre-up ip link set br-vlan-veth up - pre-up ip link set eth12 up - # Delete veth pair on DOWN - post-down ip link del br-vlan-veth || true - bridge_ports br-vlan-veth - -# OpenStack Storage bridge -auto br-storage -iface br-storage inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }}.20 - address {{host_info[inventory_hostname].STORAGE_IP}} - netmask 255.255.252.0 diff --git a/xci/playbooks/roles/configure-network/templates/debian/controller01.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/controller01.interface.j2 deleted file mode 120000 index e835d7ca..00000000 --- a/xci/playbooks/roles/configure-network/templates/debian/controller01.interface.j2 +++ /dev/null @@ -1 +0,0 @@ -controller00.interface.j2 \ No newline at end of file diff --git a/xci/playbooks/roles/configure-network/templates/debian/controller02.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/controller02.interface.j2 deleted file mode 120000 index e835d7ca..00000000 --- a/xci/playbooks/roles/configure-network/templates/debian/controller02.interface.j2 +++ /dev/null @@ -1 +0,0 @@ -controller00.interface.j2 \ No newline at end of file diff --git a/xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 deleted file mode 100644 index 03f81dbb..00000000 --- a/xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 +++ /dev/null @@ -1,66 +0,0 @@ -# {{ ansible_managed }} - -# The loopback network interface -auto lo -iface lo inet loopback - -# Physical interface -auto {{ ansible_default_ipv4.interface }} -iface {{ ansible_default_ipv4.interface }} inet manual - -# Container/Host management VLAN interface -auto {{ ansible_default_ipv4.interface }}.10 -iface {{ ansible_default_ipv4.interface }}.10 inet manual - vlan-raw-device {{ ansible_default_ipv4.interface }} - -# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface -auto {{ ansible_default_ipv4.interface }}.30 -iface {{ ansible_default_ipv4.interface }}.30 inet manual - vlan-raw-device {{ ansible_default_ipv4.interface }} - -# Storage network VLAN interface (optional) -auto {{ ansible_default_ipv4.interface }}.20 -iface {{ ansible_default_ipv4.interface }}.20 inet manual - vlan-raw-device {{ ansible_default_ipv4.interface }} - -# Container/Host management bridge -auto br-mgmt -iface br-mgmt inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }}.10 - address {{host_info[inventory_hostname].MGMT_IP}} - netmask 255.255.252.0 - -# OpenStack Networking VXLAN (tunnel/overlay) bridge -auto br-vxlan -iface br-vxlan inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }}.30 - address {{ host_info[inventory_hostname].VXLAN_IP }} - netmask 255.255.252.0 - -# OpenStack Networking VLAN bridge -auto br-vlan -iface br-vlan inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }} - address {{host_info[inventory_hostname].VLAN_IP}} - netmask 255.255.255.0 - gateway 192.168.122.1 - dns-nameserver 8.8.8.8 8.8.4.4 - -# OpenStack Storage bridge -auto br-storage -iface br-storage inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ ansible_default_ipv4.interface }}.20 - address {{host_info[inventory_hostname].STORAGE_IP}} - netmask 255.255.252.0 diff --git a/xci/playbooks/roles/configure-network/templates/redhat/bridge.ifcfg.j2 b/xci/playbooks/roles/configure-network/templates/redhat/bridge.ifcfg.j2 deleted file mode 100644 index 06b5f177..00000000 --- a/xci/playbooks/roles/configure-network/templates/redhat/bridge.ifcfg.j2 +++ /dev/null @@ -1,9 +0,0 @@ -DEVICE={{ item.name }} -NM_CONTROLLED=no -IPADDR={{ item.ip }} -PREFIX={{ item.prefix }} -ONBOOT=yes -BOOTPROTO=none -TYPE=Bridge -DELAY=0 -STP=off diff --git a/xci/playbooks/roles/configure-network/templates/redhat/interface.ifcfg.j2 b/xci/playbooks/roles/configure-network/templates/redhat/interface.ifcfg.j2 deleted file mode 100644 index a97ad0cf..00000000 --- a/xci/playbooks/roles/configure-network/templates/redhat/interface.ifcfg.j2 +++ /dev/null @@ -1,10 +0,0 @@ -DEVICE={{ item.name }} -NM_CONTROLLED=no -ONBOOT=yes -BOOTPROTO=none -{% if item.vlan_id is defined %} -VLAN=yes -ETHERDEVICE={{ ansible_default_ipv4.interface }} -VLAN_ID={{ item.vlan_id }} -{% endif %} -BRIDGE={{ item.bridge }} diff --git a/xci/playbooks/roles/configure-network/templates/suse/suse.interface.j2 b/xci/playbooks/roles/configure-network/templates/suse/suse.interface.j2 deleted file mode 100644 index 27b01eb4..00000000 --- a/xci/playbooks/roles/configure-network/templates/suse/suse.interface.j2 +++ /dev/null @@ -1,17 +0,0 @@ -STARTMODE='auto' -BOOTPROTO='static' -{% if item.vlan_id is defined %} -ETHERDEVICE={{ ansible_default_ipv4.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 deleted file mode 100644 index 7c868447..00000000 --- a/xci/playbooks/roles/configure-network/templates/suse/suse.routes.j2 +++ /dev/null @@ -1 +0,0 @@ -{{ item.route }} {{ item.gateway }} diff --git a/xci/playbooks/roles/synchronize-time/tasks/main.yml b/xci/playbooks/roles/synchronize-time/tasks/main.yml deleted file mode 100644 index 8f94d33f..00000000 --- a/xci/playbooks/roles/synchronize-time/tasks/main.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -# SPDX-license-identifier: Apache-2.0 -############################################################################## -# Copyright (c) 2017 Ericsson AB and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## -- name: install chrony - package: - name: "chrony" - state: latest -- name: restart chrony - service: - name: "{{ (ansible_pkg_mgr == 'apt') | ternary('chrony', 'chronyd') }}" - state: restarted -- name: synchronize time - shell: "chronyc -a 'burst 4/4' && chronyc -a makestep" - register: chrony_got_time - until: chrony_got_time.rc == 0 - retries: 5 - delay: 5 -- cgit 1.2.3-korg