Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
164 lines (137 sloc) 4.41 KB
---
- name: update apt
action: shell apt-get update
tags:
- build
- name: install required software defined networking packages
action: apt pkg=$item state=installed
with_items:
# - auto-install
- openvswitch-datapath-source
- bridge-utils
- module-assistant
# - openvswitch-datapath
- openvswitch-brcompat
- openvswitch-common
- openvswitch-switch
#- linux-headers-3.2.0-23-generic
#- linux-headers-generic-pae
- git
- python-zdaemon
- kvm
- wget
- dnsmasq
tags:
- build
- name: install linux linux-headers
action: shell apt-get install -y linux-headers-$(uname -r)
ignore_errors: True
tags:
- build
- name: check if the openvswitch-switch module is already built and installed
action: shell lsmod | grep openvswitch_mod > /dev/null; echo $?
ignore_errors: True
register: openvswitch_module_installed
tags:
- build
- name: build openvswitch-switch module
action: shell module-assistant -t -q auto-install openvswitch-datapath
only_if: '${openvswitch_module_installed} > 0'
tags:
- build
# TODO: Should only reboot if the module build actually suceeded
- name: reboot
action: command reboot
only_if: '${openvswitch_module_installed} > 0'
tags:
- reboot
- name: wait for the server to come back up after a reboot
action: pause seconds=30
only_if: '${openvswitch_module_installed} > 0'
tags:
- reboot
#
# WAIT_FOR not working...???
#
#- name: wait for ssh to stop
# action: wait_for delay=5 host=192.168.33.10 port=22 state=stopped
#- name: wait for server to reboot and ssh to start again
# action: wait_for delay=20 host=192.168.33.10 port=22 state=started
# delegate_to: 127.0.0.2
- name: configure /etc/default/openvswitch-switch
action: copy src=files/openvswitch-switch dest=/etc/default/openvswitch-switch
tags:
- configure
# notify: restart ovs
- name: restart openvswitch-switch
action: shell service openvswitch-switch restart
tags:
- configure
# only try to start if we just build the module
- name: ensure openvswitch-switch service is running
action: service name=openvswitch-switch state=started
only_if: '${openvswitch_module_installed} > 0'
tags:
- configure
# TODO -- make br-int a variable
- name: see if br-int is already running
action: shell brctl show | grep br-int > /dev/null; echo $?
register: bridge_up
ignore_errors: True
tags:
- configure
- name: add a bridge-utils
action: shell ovs-vsctl add-br br-int
only_if: '${bridge_up} > 0'
tags:
- configure
# TODO -- pull this info from ansible
- name: add a physical interface to the virtual bridge-utils
action: shell ovs-vsctl add-port br-int eth2; ifconfig eth2 0; ifconfig br-int 192.168.100.10 netmask 255.255.255.0
only_if: '${bridge_up} > 0'
tags:
- configure
#- name: add a default route
# action: shell route del default gw 10.0.2.2 eth0; route add default gw 192.168.33.1 br-int;
# when_unset: $bridge_up
- name: check if we have already cloned the pox repository
action: file path=/usr/local/src/pox state=directory
register: pox_installed
tags:
- build
# Only bring in pox if it's not already there
- name: clone pox repository
action: shell cd /usr/local/src; git clone http://github.com/noxrepo/pox
only_if: '${pox_installed.changed}'
tags:
- build
# maybe don't need to do this with zdaemon, it'll say it's already running..
#- name: check is pox is running
# action: shell pgrep -f pox > /dev/null; echo $?
# ignore_errors: True
# register: pox_running
- name: start pox if it isn't running already
action: shell zdaemon -p 'python /usr/local/src/pox/pox.py --no-cli forwarding.l2_learning' -d start
tags:
- configure
# only_if: "$pox_running > 0"
- name: attach openswitch to the controller
action: shell ovs-vsctl set-controller br-int tcp:192.168.33.10:6633
tags:
- configure
- name: copy over ovs-ifup script
action: copy src=files/ovs-ifup dest=/sbin/ovs-ifup owner=root group=root mode=0755
tags:
- configure
- name: copy over ovs-ipdown script
action: copy src=files/ovs-ifdown dest=/sbin/ovs-ifdown owner=root group=root mode=0755
tags:
- configure
- name: download the linux-0.2.img.bz2 qemu testing image
action: get_url url=http://wiki.qemu.org/download/linux-0.2.img.bz2 dest=/root/linux-0.2.img.bz2
tags:
- configure
- name: unzip linux-0.2.img.bz2 file
action: shell bunzip2 /root/linux-0.2.img.bz2
tags:
- configure