Merge "Provision mininet-ovs-26 image with Ansible"
authorVenkatrangan Govindarajan <vgovindarajan@luminanetworks.com>
Mon, 15 Apr 2019 08:52:21 +0000 (08:52 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 15 Apr 2019 08:52:21 +0000 (08:52 +0000)
packer/provision/mininet-ovs-2.6.sh [deleted file]
packer/provision/mininet-ovs-2.6.yaml [new file with mode: 0644]
packer/templates/mininet-ovs-2.6.json

diff --git a/packer/provision/mininet-ovs-2.6.sh b/packer/provision/mininet-ovs-2.6.sh
deleted file mode 100644 (file)
index 6673762..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/bash -x
-
-# vim: sw=4 ts=4 sts=4 et tw=72 :
-
-# force any errors to cause the script and job to end in failure
-set -xeu -o pipefail
-
-# Ensure that necessary variables are set to enable noninteractive mode in
-# commands.
-export DEBIAN_FRONTEND=noninteractive
-
-# To handle the prompt style that is expected all over the environment
-# with how use use robotframework we need to make sure that it is
-# consistent for any of the users that are created during dynamic spin
-# ups
-echo 'PS1="[\u@\h \W]> "' >> /etc/skel/.bashrc
-
-echo '---> Install OpenVSwitch 2.6.1'
-apt-get update -m
-apt-get install dh-autoreconf debhelper autoconf automake libssl-dev pkg-config bzip2 openssl python-all procps python-qt4 python-zopeinterface python-twisted-conch
-mkdir /root/ovs
-cd /root
-pwd
-wget http://openvswitch.org/releases/openvswitch-2.6.1.tar.gz
-tar -xzvf openvswitch-2.6.1.tar.gz -C /root/ovs --strip-components=1
-cd /root/ovs
-DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary
-cd /root
-dpkg -i openvswitch-common_2.6.1-1_amd64.deb openvswitch-switch_2.6.1-1_amd64.deb python-openvswitch_2.6.1-1_all.deb openvswitch-vtep_2.6.1-1_amd64.deb
-systemctl unmask openvswitch-switch
-service openvswitch-switch start
-service openvswitch-vtep start
-echo '---> Waiting 15 secs for services to start'
-sleep 15
-ovs-vsctl --version
-ovs-vsctl show
-# We want to see the entire ps output not just the pid
-# shellcheck disable=SC2009
-ps -elf | grep ovs
-# shellcheck disable=SC2009
-ps -elf | grep vtep
-echo '---> Finished installing OpenVSwitch 2.6.1'
-
-echo '---> Installing mininet'
-apt-get install mininet
-
-echo '---> Installing build pre-requisites'
-apt-get install build-essential snmp libsnmp-dev snmpd libpcap-dev \
-autoconf make automake libtool libconfig-dev libssl-dev libffi-dev libssl-doc pkg-config
-
-git clone https://github.com/intracom-telecom-sdn/mtcbench.git
-mtcbench/deploy/docker/provision.sh
-# TODO: remove workaround for build issue with mtcbench
-# when mtcbench dependency build correctly
-# https://github.com/intracom-telecom-sdn/mtcbench/issues/10
-mtcbench/build_mtcbench.sh || true
-cd mtcbench/oflops/cbench
-make
-cp cbench /usr/local/bin/
-
-echo '---> Installing exabgp'
-apt-get install exabgp
-
-# Install vlan for vlan based tests in VTN suites
-apt-get install vlan
-
-# Install netaddr package which is needed by some custom mininet topologies
-apt-get install python-netaddr
diff --git a/packer/provision/mininet-ovs-2.6.yaml b/packer/provision/mininet-ovs-2.6.yaml
new file mode 100644 (file)
index 0000000..6715b38
--- /dev/null
@@ -0,0 +1,93 @@
+---
+- import_playbook: ../common-packer/provision/baseline.yaml
+
+- hosts: all
+  become_user: root
+  become_method: sudo
+  vars:
+    ovs_version: 2.6.1
+    ovs_checksum: sha256:307b20aba6a179bf13e5da9ac242933c31349073762473a9d4782619c8c1cf0c
+
+  pre_tasks:
+    - include_role: name=lfit.system-update
+
+  tasks:
+    - name: 'Install OpenVSwitch {{ovs_version}}'
+      block:
+        - name: 'Install dependencies required for OpenVSwitch {{ovs_version}}'
+          apt: 'name={{item}} state=present'
+          with_items:
+            - dh-autoreconf
+            - debhelper
+            - autoconf
+            - automake
+            - libssl-dev
+            - pkg-config
+            - bzip2
+            - openssl
+            - python-all
+            - procps
+            - python-qt4
+            - python-zopeinterface
+            - python-twisted-conch
+          become: true
+        - name: Create OVS root
+          file:
+            path: /tmp/ovs
+            state: directory
+            mode: 0755
+        - name: 'Fetch OpenVSwitch {{ovs_version}} to /tmp'
+          get_url:
+            url: 'http://openvswitch.org/releases/openvswitch-2.6.1.tar.gz'
+            dest: '/tmp/openvswitch-2.6.1.tar.gz'
+            checksum: '{{ovs_checksum}}'
+        - name: 'Unarchive OpenVSwitch {{ovs_version}}'
+          unarchive:
+            src: '/tmp/openvswitch-{{ovs_version}}.tar.gz'
+            dest: /tmp/ovs
+            remote_src: true
+        - name: 'Build OpenVSwitch {{ovs_version}}'
+          shell: DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary
+          args:
+            chdir: '/tmp/ovs/openvswitch-{{ovs_version}}'
+        - name: 'Install OpenVSwitch {{ovs_version}}'
+          apt: 'deb={{item}}'
+          with_items:
+            - /tmp/ovs/openvswitch-common_2.6.1-1_amd64.deb
+            - /tmp/ovs/openvswitch-switch_2.6.1-1_amd64.deb
+            - /tmp/ovs/python-openvswitch_2.6.1-1_all.deb
+            - /tmp/ovs/openvswitch-vtep_2.6.1-1_amd64.deb
+          become: true
+        - name: Enable openvswitch-switch service
+          systemd:
+            name: openvswitch-switch
+            enabled: true
+            masked: false
+          become: true
+        - name: Enable openvswitch-vtep service
+          systemd:
+            name: openvswitch-vtep
+            enabled: true
+            masked: false
+          become: true
+
+    - name: Install Mininet
+      apt: name=mininet state=present
+      become: true
+
+    - name: Install exabgp
+      apt: name=exabgp state=present
+      become: true
+
+    - name: Install vlan for vlan based tests in VTN suites
+      apt: name=vlan state=present
+      become: true
+
+    - name: Install python-netaddr for custom mininet topologies
+      apt: name=python-netaddr state=present
+      become: true
+
+  post_tasks:
+    - name: System Reseal
+      script: ../common-packer/provision/system-reseal.sh
+      become: true
index bf203f4533c3ca397b6232c4066d396997443ec5..85a70be34f726b0737c4665579670512df447c00 100644 (file)
@@ -1,5 +1,6 @@
 {
   "variables": {
+    "ansible_roles_path": ".galaxy",
     "base_image": null,
     "distro": null,
     "cloud_network": null,
   },
   "builders": [
     {
-      "type": "openstack",
-      "region": "ca-ymq-1",
-      "availability_zone": "ca-ymq-2",
-      "ssh_username": "{{user `ssh_user`}}",
-      "ssh_proxy_host": "{{user `ssh_proxy_host`}}",
+      "name": "vexxhost",
       "image_name": "ZZCI - {{user `distro`}} - mininet-ovs-26 - {{isotime \"20060102-150405.000\"}}",
       "instance_name": "{{user `distro`}}-mininet-ovs-26-{{uuid}}",
       "source_image_name": "{{user `base_image`}}",
-      "flavor": "v1-standard-1",
+      "type": "openstack",
+      "region": "ca-ymq-1",
+      "availability_zone": "ca-ymq-2",
       "networks": [
         "{{user `cloud_network`}}"
       ],
       "user_data_file": "{{user `cloud_user_data`}}",
+      "ssh_username": "{{user `ssh_user`}}",
+      "ssh_proxy_host": "{{user `ssh_proxy_host`}}",
+      "flavor": "v1-standard-1",
       "metadata": {
         "ci_managed": "yes"
       }
     {
       "type": "shell",
       "scripts": [
-        "provision/baseline.sh",
-        "provision/mininet-ovs-2.6.sh",
-        "provision/system_reseal_local_env.sh",
-        "provision/system_reseal.sh"
+        "common-packer/provision/install-python.sh"
       ],
       "execute_command": "chmod +x {{ .Path }}; if [ \"$UID\" == \"0\" ]; then {{ .Vars }} '{{ .Path }}'; else {{ .Vars }} sudo -E '{{ .Path }}'; fi"
+    },
+    {
+      "type": "shell-local",
+      "command": "./common-packer/ansible-galaxy.sh {{user `ansible_roles_path`}}"
+    },
+    {
+      "type": "ansible",
+      "playbook_file": "provision/mininet-ovs-2.6.yaml",
+      "ansible_env_vars": [
+        "ANSIBLE_NOCOWS=1",
+        "ANSIBLE_PIPELINING=True",
+        "ANSIBLE_ROLES_PATH={{user `ansible_roles_path`}}",
+        "ANSIBLE_CALLBACK_WHITELIST=profile_tasks",
+        "ANSIBLE_STDOUT_CALLBACK=yaml"
+      ]
     }
   ]
 }