Use template, recreate default network
diff --git a/cloudlab-setup.yml b/cloudlab-setup.yml
index e32969b..c83ff64 100644
--- a/cloudlab-setup.yml
+++ b/cloudlab-setup.yml
@@ -3,6 +3,9 @@
# Assumes basic /etc/ansible/hosts file
- hosts: head
sudo: yes
+ vars:
+ # Each OpenCloud cluster needs a unique mgmt_net_prefix
+ mgmt_net_prefix: 192.168.100
tasks:
- apt: name={{ item }} update_cache=yes
@@ -61,9 +64,20 @@
- name: Get trusty image for uvtool
shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64
- - name: Change the subnet of virbr0 to 192.168.100.0/24
- shell: sed -i 's/192.168.122/192.168.100/g' /etc/libvirt/qemu/networks/default.xml
+ - name: Change the virbr0 subnet to {{ mgmt_net_prefix }}.0/24
+ template: src=templates/etc/libvirt/qemu/networks/default.xml.j2
+ dest=/etc/libvirt/qemu/networks/default.xml
+ notify:
+ - recreate default net
+ handlers:
+ - name: recreate default net
+ shell: virsh net-destroy default; virsh net-create /etc/libvirt/qemu/networks/default.xml
+
+# Play: create VMs to host OpenStack services
+- hosts: head
+ sudo: yes
+ tasks:
- name: Create VMs to host OpenCloud services
sudo: no
script: scripts/create-vms.sh
diff --git a/templates/etc/libvirt/qemu/networks/default.xml.j2 b/templates/etc/libvirt/qemu/networks/default.xml.j2
new file mode 100644
index 0000000..64b88c3
--- /dev/null
+++ b/templates/etc/libvirt/qemu/networks/default.xml.j2
@@ -0,0 +1,10 @@
+<network>
+ <name>default</name>
+ <bridge name="virbr0"/>
+ <forward/>
+ <ip address="{{ mgmt_net_prefix }}.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="{{ mgmt_net_prefix }}.2" end="{{ mgmt_net_prefix }}.254"/>
+ </dhcp>
+ </ip>
+</network>