From e8f6f7180dc5d78520d3ab298f279a8dd1b8795b Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 24 Aug 2017 13:33:38 +0100 Subject: xci: playbooks: configure-network: Prepare for multi-distro support Move the network templates inside the role since it's their only user. Moreover, remove the arguments when we include the role in playbooks and move the distro logic to the role itself. Change-Id: I938686fdb31b9896b9e97339799a0edd4c34bf36 Signed-off-by: Markos Chandras --- xci/playbooks/configure-opnfvhost.yml | 3 +- xci/playbooks/configure-targethosts.yml | 6 +- .../roles/configure-network/tasks/main.yml | 6 +- .../templates/debian/compute00.interface.j2 | 75 ++++++++++++++++++++++ .../templates/debian/controller00.interface.j2 | 66 +++++++++++++++++++ .../templates/debian/opnfv.interface.j2 | 66 +++++++++++++++++++ xci/template/compute.interface.j2 | 73 --------------------- xci/template/controller.interface.j2 | 64 ------------------ xci/template/opnfv.interface.j2 | 64 ------------------ 9 files changed, 213 insertions(+), 210 deletions(-) create mode 100644 xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 create mode 100644 xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 create mode 100644 xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 delete mode 100644 xci/template/compute.interface.j2 delete mode 100644 xci/template/controller.interface.j2 delete mode 100644 xci/template/opnfv.interface.j2 (limited to 'xci') diff --git a/xci/playbooks/configure-opnfvhost.yml b/xci/playbooks/configure-opnfvhost.yml index 53e34418..7bc434d7 100644 --- a/xci/playbooks/configure-opnfvhost.yml +++ b/xci/playbooks/configure-opnfvhost.yml @@ -48,8 +48,7 @@ - ../var/flavor-vars.yml - ../var/opnfv.yml roles: - # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros - - { role: configure-network, when: ansible_distribution_release == "xenial", src: "../template/opnfv.interface.j2", dest: "/etc/network/interfaces" } + - role: configure-network tasks: - name: generate SSH keys shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" diff --git a/xci/playbooks/configure-targethosts.yml b/xci/playbooks/configure-targethosts.yml index 50da1f22..88da1312 100644 --- a/xci/playbooks/configure-targethosts.yml +++ b/xci/playbooks/configure-targethosts.yml @@ -13,8 +13,7 @@ - ../var/{{ ansible_os_family }}.yml - ../var/flavor-vars.yml roles: - # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros - - { role: configure-network, src: "../template/controller.interface.j2", dest: "/etc/network/interfaces" } + - role: configure-network # we need to force sync time with ntp or the nodes will be out of sync timewise - role: synchronize-time @@ -24,8 +23,7 @@ - ../var/{{ ansible_os_family }}.yml - ../var/flavor-vars.yml roles: - # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros - - { role: configure-network, src: "../template/compute.interface.j2", dest: "/etc/network/interfaces" } + - role: configure-network # we need to force sync time with ntp or the nodes will be out of sync timewise - role: synchronize-time diff --git a/xci/playbooks/roles/configure-network/tasks/main.yml b/xci/playbooks/roles/configure-network/tasks/main.yml index aafadf71..df1580e5 100644 --- a/xci/playbooks/roles/configure-network/tasks/main.yml +++ b/xci/playbooks/roles/configure-network/tasks/main.yml @@ -27,8 +27,8 @@ shell: "/bin/rm -rf /etc/network/interfaces.d/*" - name: ensure interfaces file is updated template: - src: "{{ src }}" - dest: "{{ dest }}" + src: "{{ ansible_os_family | lower }}/{{ ansible_hostname }}.interface.j2" + dest: "/etc/network/interfaces" - name: restart network service shell: "/sbin/ifconfig {{ interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a" - when: ansible_distribution_release == "xenial" + when: ansible_os_family | lower == "debian" diff --git a/xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 new file mode 100644 index 00000000..6d6a3835 --- /dev/null +++ b/xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 @@ -0,0 +1,75 @@ +# {{ ansible_managed }} + +# The loopback network interface +auto lo +iface lo inet loopback + +# Physical interface +auto {{ interface }} +iface {{ interface }} inet manual + +# Container/Host management VLAN interface +auto {{ interface }}.10 +iface {{ interface }}.10 inet manual + vlan-raw-device {{ interface }} + +# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface +auto {{ interface }}.30 +iface {{ interface }}.30 inet manual + vlan-raw-device {{ interface }} + +# Storage network VLAN interface +auto {{ interface }}.20 +iface {{ interface }}.20 inet manual + vlan-raw-device {{ interface }} + +# Container/Host management bridge +auto br-mgmt +iface br-mgmt inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ 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 {{ 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 {{ 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 {{ interface }}.20 + address {{host_info[inventory_hostname].STORAGE_IP}} + netmask 255.255.252.0 diff --git a/xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 new file mode 100644 index 00000000..5d42a5d2 --- /dev/null +++ b/xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 @@ -0,0 +1,66 @@ +# {{ ansible_managed }} + +# The loopback network interface +auto lo +iface lo inet loopback + +# Physical interface +auto {{ interface }} +iface {{ interface }} inet manual + +# Container/Host management VLAN interface +auto {{ interface }}.10 +iface {{ interface }}.10 inet manual + vlan-raw-device {{ interface }} + +# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface +auto {{ interface }}.30 +iface {{ interface }}.30 inet manual + vlan-raw-device {{ interface }} + +# Storage network VLAN interface (optional) +auto {{ interface }}.20 +iface {{ interface }}.20 inet manual + vlan-raw-device {{ interface }} + +# Container/Host management bridge +auto br-mgmt +iface br-mgmt inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ 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 {{ 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 {{ 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 {{ interface }}.20 + address {{host_info[inventory_hostname].STORAGE_IP}} + netmask 255.255.252.0 diff --git a/xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 new file mode 100644 index 00000000..42826414 --- /dev/null +++ b/xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 @@ -0,0 +1,66 @@ +# {{ ansible_managed }} + +# The loopback network interface +auto lo +iface lo inet loopback + +# Physical interface +auto {{ interface }} +iface {{ interface }} inet manual + +# Container/Host management VLAN interface +auto {{ interface }}.10 +iface {{ interface }}.10 inet manual + vlan-raw-device {{ interface }} + +# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface +auto {{ interface }}.30 +iface {{ interface }}.30 inet manual + vlan-raw-device {{ interface }} + +# Storage network VLAN interface (optional) +auto {{ interface }}.20 +iface {{ interface }}.20 inet manual + vlan-raw-device {{ interface }} + +# Container/Host management bridge +auto br-mgmt +iface br-mgmt inet static + bridge_stp off + bridge_waitport 0 + bridge_fd 0 + bridge_ports {{ 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 {{ 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 {{ 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 {{ interface }}.20 + address {{host_info[inventory_hostname].STORAGE_IP}} + netmask 255.255.252.0 diff --git a/xci/template/compute.interface.j2 b/xci/template/compute.interface.j2 deleted file mode 100644 index 094544c3..00000000 --- a/xci/template/compute.interface.j2 +++ /dev/null @@ -1,73 +0,0 @@ -# The loopback network interface -auto lo -iface lo inet loopback - -# Physical interface -auto {{ interface }} -iface {{ interface }} inet manual - -# Container/Host management VLAN interface -auto {{ interface }}.10 -iface {{ interface }}.10 inet manual - vlan-raw-device {{ interface }} - -# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface -auto {{ interface }}.30 -iface {{ interface }}.30 inet manual - vlan-raw-device {{ interface }} - -# Storage network VLAN interface -auto {{ interface }}.20 -iface {{ interface }}.20 inet manual - vlan-raw-device {{ interface }} - -# Container/Host management bridge -auto br-mgmt -iface br-mgmt inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ 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 {{ 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 {{ 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 {{ interface }}.20 - address {{host_info[inventory_hostname].STORAGE_IP}} - netmask 255.255.252.0 diff --git a/xci/template/controller.interface.j2 b/xci/template/controller.interface.j2 deleted file mode 100644 index 638e78e1..00000000 --- a/xci/template/controller.interface.j2 +++ /dev/null @@ -1,64 +0,0 @@ -# The loopback network interface -auto lo -iface lo inet loopback - -# Physical interface -auto {{ interface }} -iface {{ interface }} inet manual - -# Container/Host management VLAN interface -auto {{ interface }}.10 -iface {{ interface }}.10 inet manual - vlan-raw-device {{ interface }} - -# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface -auto {{ interface }}.30 -iface {{ interface }}.30 inet manual - vlan-raw-device {{ interface }} - -# Storage network VLAN interface (optional) -auto {{ interface }}.20 -iface {{ interface }}.20 inet manual - vlan-raw-device {{ interface }} - -# Container/Host management bridge -auto br-mgmt -iface br-mgmt inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ 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 {{ 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 {{ 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 {{ interface }}.20 - address {{host_info[inventory_hostname].STORAGE_IP}} - netmask 255.255.252.0 diff --git a/xci/template/opnfv.interface.j2 b/xci/template/opnfv.interface.j2 deleted file mode 100644 index e9f8649c..00000000 --- a/xci/template/opnfv.interface.j2 +++ /dev/null @@ -1,64 +0,0 @@ -# The loopback network interface -auto lo -iface lo inet loopback - -# Physical interface -auto {{ interface }} -iface {{ interface }} inet manual - -# Container/Host management VLAN interface -auto {{ interface }}.10 -iface {{ interface }}.10 inet manual - vlan-raw-device {{ interface }} - -# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface -auto {{ interface }}.30 -iface {{ interface }}.30 inet manual - vlan-raw-device {{ interface }} - -# Storage network VLAN interface (optional) -auto {{ interface }}.20 -iface {{ interface }}.20 inet manual - vlan-raw-device {{ interface }} - -# Container/Host management bridge -auto br-mgmt -iface br-mgmt inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports {{ 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 {{ 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 {{ 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 {{ interface }}.20 - address {{host_info[inventory_hostname].STORAGE_IP}} - netmask 255.255.252.0 -- cgit 1.2.3-korg From a376c0d6454e2aa296364daf9bcf9e9e947e1cdd Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 24 Aug 2017 13:50:55 +0100 Subject: xci: playbooks: configure-nfs: Prepare for multi-distro support There is nothing Ubuntu specific in this role apart from the nfs server service name. As such we remove the block statement and make the service name configurable in order to prepare for multidistribution support. Change-Id: I3c8202315fc49b5e5afc2a0d03eaf80d83db5f4c Signed-off-by: Markos Chandras --- xci/playbooks/roles/configure-nfs/tasks/main.yml | 74 ++++++++++++----------- xci/playbooks/roles/configure-nfs/vars/debian.yml | 11 ++++ 2 files changed, 51 insertions(+), 34 deletions(-) create mode 100644 xci/playbooks/roles/configure-nfs/vars/debian.yml (limited to 'xci') diff --git a/xci/playbooks/roles/configure-nfs/tasks/main.yml b/xci/playbooks/roles/configure-nfs/tasks/main.yml index c52da0bf..51a2d43a 100644 --- a/xci/playbooks/roles/configure-nfs/tasks/main.yml +++ b/xci/playbooks/roles/configure-nfs/tasks/main.yml @@ -7,37 +7,43 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -# TODO: this is for xenial and needs to be adjusted for different distros -- block: - - name: make NFS directories - file: - dest: "{{ item }}" - mode: 0777 - state: directory - with_items: - - "/images" - - "/volumes" - - name: configure NFS service - lineinfile: - dest: /etc/services - state: present - create: yes - line: "{{ item }}" - with_items: - - "nfs 2049/tcp" - - "nfs 2049/udp" - - name: configure NFS exports - lineinfile: - dest: /etc/exports - state: present - create: yes - line: "{{ item }}" - with_items: - - "/images *(rw,sync,no_subtree_check,no_root_squash)" - - "/volumes *(rw,sync,no_subtree_check,no_root_squash)" - # TODO: the service name might be different on other distros and needs to be adjusted - - name: restart ubuntu xenial NFS service - service: - name: nfs-kernel-server - state: restarted - when: ansible_distribution_release == "xenial" + +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" +- name: make NFS directories + file: + dest: "{{ item }}" + mode: 0777 + state: directory + with_items: + - "/images" + - "/volumes" +- name: configure NFS service + lineinfile: + dest: /etc/services + state: present + create: yes + line: "nfs 2049/{{ item }}" + regexp: "^[[:space:]]*nfs[[:space:]]*2049/{{ item }}" + with_items: + - "tcp" + - "udp" +- name: configure NFS exports + lineinfile: + dest: /etc/exports + state: present + create: yes + line: "{{ item }}" + with_items: + - "/images *(rw,sync,no_subtree_check,no_root_squash)" + - "/volumes *(rw,sync,no_subtree_check,no_root_squash)" +- name: restart ubuntu xenial NFS service + service: + name: "{{ nfs_server_service }}" + state: restarted diff --git a/xci/playbooks/roles/configure-nfs/vars/debian.yml b/xci/playbooks/roles/configure-nfs/vars/debian.yml new file mode 100644 index 00000000..8d3c6561 --- /dev/null +++ b/xci/playbooks/roles/configure-nfs/vars/debian.yml @@ -0,0 +1,11 @@ +--- +# 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 +############################################################################## + +nfs_server_service: "nfs-kernel-server" -- cgit 1.2.3-korg