Support for running install procedure on bare metal CloudLab nodes
diff --git a/cloudlab-compute.yml b/cloudlab-compute.yml
new file mode 100644
index 0000000..10713a0
--- /dev/null
+++ b/cloudlab-compute.yml
@@ -0,0 +1,65 @@
+---
+- hosts: cloudlab-head
+ sudo: no
+ tasks:
+ - pause: "Install nova-compute on all unused machines managed by Juju"
+
+ - name: Deploy nova-compute
+ script: scripts/juju-compute-setup.py
+
+ - name: Make sure we're using KVM
+ shell: juju set nova-compute virt-type=kvm
+
+ - pause: "Wait until services have started"
+
+ - name: Add nova-compute relations
+ script: scripts/juju-compute-relations.py
+
+ - pause: "Wait until relations are added"
+
+# Play: set up ansible-pull for OpenCloud-specific files on nova-compute nodes
+- hosts: cloudlab-compute
+ sudo: yes
+ vars:
+
+ # schedule is fed directly to cron
+ schedule: '*/15 * * * *'
+
+ # User to run ansible-pull as from cron
+ cron_user: root
+
+ # File that ansible will use for logs
+ logfile: /var/log/ansible-pull.log
+
+ # Directory to where repository will be cloned
+ workdir: /var/lib/ansible/local
+
+ # Repository to check out
+ # repo must contain a local.yml file at top level
+ #repo_url: git://github.com/sfromm/ansible-playbooks.git
+ repo_url: git://github.com/andybavier/opencloud-nova-compute-ansible.git
+
+ # Branch or tag to checkout
+ #repo_version: onlab
+
+ tasks:
+
+ - name: Set up extra space on CloudLab nodes
+ shell: /usr/testbed/bin/mkextrafs /var/lib/libvirt/images
+ creates=/var/lib/libvirt/images/lost+found
+
+ - name: Install ansible
+ apt: name=ansible state=installed
+
+ - name: Basic ansible inventory
+ template: src=templates/etc/ansible/hosts.j2
+ dest=/etc/ansible/hosts
+
+ - name: Create local directory to work from
+ file: path={{workdir}} state=directory owner=root group=root mode=0751
+
+ - name: Create crontab entry to clone/pull git repository
+ template: src=templates/etc/cron.d/ansible-pull.j2 dest=/etc/cron.d/ansible-pull owner=root group=root mode=0644
+
+ - name: Create logrotate entry for ansible-pull.log
+ template: src=templates/etc/logrotate.d/ansible-pull.j2 dest=/etc/logrotate.d/ansible-pull owner=root group=root mode=0644
diff --git a/cloudlab-hosts b/cloudlab-hosts
new file mode 100644
index 0000000..61919c9
--- /dev/null
+++ b/cloudlab-hosts
@@ -0,0 +1,5 @@
+[cloudlab-head]
+ctl.acb-qv8253.xos-pg0.clemson.cloudlab.us
+
+[cloudlab-compute]
+cp-1.acb-qv8253.xos-pg0.clemson.cloudlab.us
diff --git a/cloudlab-setup.yml b/cloudlab-setup.yml
new file mode 100644
index 0000000..d6a98c5
--- /dev/null
+++ b/cloudlab-setup.yml
@@ -0,0 +1,231 @@
+---
+# Play: set up head node
+# Assumes basic /etc/ansible/hosts file
+- hosts: cloudlab-head
+ sudo: yes
+ tasks:
+
+ - apt: name={{ item }}
+ with_items:
+ - python-pycurl
+ - software-properties-common
+
+ - name: Add Juju repository
+ apt_repository: repo="ppa:juju/stable"
+
+ - name: Add Ansible repository
+ apt_repository: repo="ppa:ansible/ansible"
+
+ - name: Install older version of Juju due to bug in 1.22
+ apt: name=juju-core
+
+ - name: Install packages
+ apt: name={{ item }} state=latest
+ with_items:
+ - ansible
+ - uvtool
+ - git
+ - bzr
+
+ - name: Get juju-ansible git repo
+ git: repo=https://github.com/cmars/juju-ansible.git
+ dest=/usr/local/src/juju-ansible
+
+ - name: Set up juju-ansible symlink
+ file: dest=/usr/local/bin/juju-ansible
+ src=/usr/local/src/juju-ansible/juju-ansible
+ state=link
+
+ - name: Set up juju-ansible-playbook symlink
+ file: dest=/usr/local/bin/juju-ansible-playbook
+ src=/usr/local/src/juju-ansible/juju-ansible
+ state=link
+
+ - name: Generate key to use in VMs
+ user: name={{ ansible_env['SUDO_USER'] }} generate_ssh_key=yes
+
+ - name: Set up extra space on CloudLab nodes
+ shell: /usr/testbed/bin/mkextrafs /var/lib/uvtool/libvirt/images
+ creates=/var/lib/uvtool/libvirt/images/lost+found
+
+ - name: Add myself to libvirtd group
+ shell: usermod -aG libvirtd {{ ansible_env['SUDO_USER'] }}
+
+ - name: Get trusty image for uvtool
+ shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64
+
+ - name: Create VMs to host OpenCloud services
+ sudo: no
+ script: scripts/create-vms.sh
+
+# - pause: prompt="Hit return when all VMs have IP addresses"
+
+ - include: tasks/vm-ips.yml
+
+ - name: Add VMs to /etc/hosts
+ template: src=templates/etc/hosts.j2
+ dest=/etc/hosts
+ notify:
+ - Reload dnsmasq
+
+ - name: Set up /etc/ansible/hosts
+ template: src=templates/etc/ansible/hosts.j2
+ dest=/etc/ansible/hosts
+
+ - name: Copy ansible.cfg to disable host key checking
+ sudo: no
+ copy: src=files/ansible.cfg
+ dest={{ ansible_env['PWD'] }}/.ansible.cfg
+
+ - name: Touch ~/.ssh/config
+ sudo: no
+ file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch
+
+ - name: Disable host key checking in SSH
+ sudo: no
+ lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config
+ line="StrictHostKeyChecking no"
+
+ - name: Test that we can log into every VM
+ sudo: no
+ shell: ansible services -m ping -u ubuntu
+
+ handlers:
+ - name: Reload dnsmasq
+ shell: killall -HUP dnsmasq
+
+# Play: Install services using Juju
+- hosts: cloudlab-head
+ vars:
+ charm_src: /usr/local/src/charms/trusty
+ tasks:
+ - name: Initialize Juju
+ sudo: no
+ shell: juju generate-config
+ creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
+
+ - shell: uvt-kvm ip juju
+ register: juju_ip
+
+ - name: Juju config file
+ sudo: no
+ template: src=templates/environments.yaml.j2
+ dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
+
+ - name: Bootstrap Juju
+ sudo: no
+ shell: juju bootstrap
+ creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
+
+ # - pause: Break here and try rebooting Juju VM
+
+ - name: Copy openstack.cfg for Juju
+ sudo: yes
+ copy: src=files/openstack.cfg
+ dest=/usr/local/src/openstack.cfg
+
+ - name: Check for /usr/local/src/charms/trusty
+ sudo: yes
+ file: path={{ charm_src }}
+ state=directory
+ mode=0755
+
+ - name: Deploy OpenStack services with Juju
+ script: scripts/juju-setup.py
+
+# - pause: prompt="Hit return when all services have started successfully"
+
+ - name: Set MTU for GRE tunneling
+ shell: "juju set quantum-gateway instance-mtu=1400"
+
+ - name: Use HTTPS for keystone authentication
+ shell: 'juju set keystone use-https=yes'
+
+ - name: Use HTTPS for all service endpoints
+ shell: 'juju set keystone https-service-endpoints=True'
+
+ - name: Use SSL for rabbitmq
+ shell: 'juju set rabbitmq-server ssl=on'
+
+ - name: Add all Juju relations between services
+ script: scripts/juju-relations.py
+
+ - pause: prompt="Wait for relations to be fully added"
+
+# Play: Use libvirt hooks to set up iptables
+- hosts: cloudlab-head
+ sudo: yes
+ tasks:
+ - name: Enable port forwarding for services
+ copy: src=files/{{ item }}
+ dest={{ item }}
+ mode=0755
+ notify:
+ - reload libvirt config
+ - run qemu hook
+ with_items:
+ - /etc/libvirt/hooks/daemon
+ - /etc/libvirt/hooks/qemu
+
+ handlers:
+ - name: reload libvirt config
+ shell: killall -HUP libvirtd
+
+ - name: run qemu hook
+ shell: /etc/libvirt/hooks/qemu start start
+
+# Play: Create credentials, set up some basic OpenStack
+- hosts: cloudlab-head
+ sudo: no
+ tasks:
+
+ - name: Get keystone admin password
+ shell: juju run --unit=keystone/0 "sudo cat /var/lib/keystone/keystone.passwd"
+ register: keystone_password
+
+ - shell: uvt-kvm ip keystone
+ register: keystone_ip
+
+ - name: Create credentials
+ template: src=templates/admin-openrc.sh.j2
+ dest={{ ansible_env['PWD'] }}/admin-openrc.sh
+
+ - name: Copy credentials to nova-cloud-controller
+ shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
+
+ - name: Copy network setup script
+ sudo: yes
+ copy: src=scripts/network-setup.sh
+ dest=/usr/local/src/network-setup.sh
+ mode=0644
+
+ - name: Run network setup script
+ shell: ansible nova-cloud-controller -m script -u ubuntu -a "/usr/local/src/network-setup.sh"
+
+ - name: Get public key
+ shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub
+ register: sshkey
+
+- hosts: cloudlab-compute
+ sudo: yes
+ vars:
+ control_net: 192.168.122.0/24
+ gateway: 130.127.133.105
+ tasks:
+ - name: Install package needed by Juju
+ apt: name=python-yaml state=present
+
+ - name: Add route via /etc/rc.local
+ template: src=templates/etc/rc.local.cloudlab
+ dest=/etc/rc.local
+ mode=0755
+ notify:
+ - run /etc/rc.local
+
+ - name: Add key
+ authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
+ key="{{ hostvars['ctl.acb-qv8253.xos-pg0.clemson.cloudlab.us']['sshkey']['stdout'] }}"
+
+ handlers:
+ - name: run /etc/rc.local
+ shell: /etc/rc.local
diff --git a/enable-virt-dell.yml b/enable-virt-dell.yml
new file mode 100644
index 0000000..2e84c05
--- /dev/null
+++ b/enable-virt-dell.yml
@@ -0,0 +1,21 @@
+# Enable virtualization on Dell R410s
+---
+- hosts: onlab-compute
+ sudo: yes
+ tasks:
+ - name: Update files
+ copy: src=files/etc/apt/sources.list.d/linux.dell.com.sources.list
+ dest=/etc/apt/sources.list.d/linux.dell.com.sources.list
+
+ - shell: gpg --keyserver pool.sks-keyservers.net --recv-key 1285491434D8786F
+
+ - shell: gpg -a --export 1285491434D8786F | sudo apt-key add -
+
+ - name: Update apt cache
+ apt: upgrade=yes update_cache=yes
+
+ - name: Install packages
+ apt: name=dtk-scripts state=present
+
+ - name: Enable virtualization in BIOS
+ shell: /opt/dell/toolkit/bin/syscfg --virtualization=enable
diff --git a/files/etc/apt/sources.list.d/linux.dell.com.sources.list b/files/etc/apt/sources.list.d/linux.dell.com.sources.list
new file mode 100644
index 0000000..25aba6a
--- /dev/null
+++ b/files/etc/apt/sources.list.d/linux.dell.com.sources.list
@@ -0,0 +1 @@
+deb http://linux.dell.com/repo/community/ubuntu trusty openmanage
diff --git a/scripts/create-vms.sh b/scripts/create-vms.sh
index eebd038..d56b043 100755
--- a/scripts/create-vms.sh
+++ b/scripts/create-vms.sh
@@ -9,6 +9,7 @@
if [ "$?" -ne "0" ]
then
uvt-kvm create $NAME --cpu=$CPU --memory=$MEM_MB --disk=$DISK_GB
+ uvt-kvm wait --insecure $NAME
fi
}
diff --git a/scripts/network-setup.sh b/scripts/network-setup.sh
index 6bacaa5..a7f4a06 100755
--- a/scripts/network-setup.sh
+++ b/scripts/network-setup.sh
@@ -2,25 +2,39 @@
source ~/admin-openrc.sh
-# Create nat-net network
-neutron net-show nat-net 2>&1 > /dev/null
-if [ "$?" -ne 0 ]
-then
- neutron net-create --provider:physical_network=nat --provider:network_type=flat --shared nat-net
-fi
+function create-flat-net {
+ NAME=$1
+ neutron net-show $NAME-net 2>&1 > /dev/null
+ if [ "$?" -ne 0 ]
+ then
+ neutron net-create --provider:physical_network=$NAME --provider:network_type=flat --shared $NAME-net
+ fi
+}
-# Create nat-net subnet
-neutron subnet-show nat-net 2>&1 > /dev/null
-if [ "$?" -ne 0 ]
-then
- neutron subnet-create nat-net --name nat-net 172.16.0.0/16 --gateway=172.16.0.1 --enable-dhcp=false
-fi
+function create-subnet {
+ NAME=$1
+ CIDR=$2
+ GW=$3
-# Create nat-net network
-neutron net-show ext-net 2>&1 > /dev/null
-if [ "$?" -ne 0 ]
-then
- neutron net-create --provider:physical_network=ext --provider:network_type=flat --shared ext-net
-fi
+ neutron subnet-show $NAME-net 2>&1 > /dev/null
+ if [ "$?" -ne 0 ]
+ then
+ neutron subnet-create $NAME-net --name $NAME-net $CIDR --gateway=$GW --enable-dhcp=false
+ fi
+}
+function create-subnet-no-gateway {
+ NAME=$1
+ CIDR=$2
+ neutron subnet-show $NAME-net 2>&1 > /dev/null
+ if [ "$?" -ne 0 ]
+ then
+ neutron subnet-create $NAME-net --name $NAME-net $CIDR --no-gateway --enable-dhcp=false
+ fi
+}
+
+create-flat-net nat
+create-subnet nat 172.16.0.0/16 172.16.0.1
+
+create-flat-net ext
diff --git a/templates/etc/rc.local.cloudlab b/templates/etc/rc.local.cloudlab
new file mode 100755
index 0000000..a28ab65
--- /dev/null
+++ b/templates/etc/rc.local.cloudlab
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# Copyright (c) 2004-2014 University of Utah and the Flux Group.
+#
+# This file is part of the Emulab network testbed software.
+#
+# This file is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or (at
+# your option) any later version.
+#
+# This file is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this file. If not, see <http://www.gnu.org/licenses/>.
+#
+
+#
+# This script will be executed *after* all the other init scripts.
+# You can put your own initialization stuff in here if you don't
+# want to do the full Sys V style init stuff.
+
+# XXX compat with RedHat feature
+if [ ! -d /var/lock/subsys ]; then
+ mkdir /var/lock/subsys
+fi
+
+# XXX serial console seems to be in raw mode, makes our messages ugly :-)
+if [ ! -e /dev/hvc0 -a -c /dev/ttyS0 ]; then
+ stty -F /dev/ttyS0 opost onlcr
+fi
+
+#
+# Testbed Setup.
+#
+if [ -f /usr/local/etc/emulab/rc/rc.testbed ] ; then
+ echo -n 'testbed config: '
+ /usr/local/etc/emulab/rc/rc.testbed
+ touch /var/lock/subsys/testbed
+fi
+
+route add -net {{ control_net }} gw {{ gateway }} || true
+
+echo "Boot Complete"
+
+exit 0