blob: 8c3ae3f0767dad0f1f6266b194595f615402b59d [file] [log] [blame]
Andy Baviercccf27b2015-08-17 14:48:29 -04001---
2# Play: set up head node
3# Assumes basic /etc/ansible/hosts file
4- hosts: cloudlab-head
5 sudo: yes
6 tasks:
7
8 - apt: name={{ item }}
9 with_items:
10 - python-pycurl
11 - software-properties-common
12
13 - name: Add Juju repository
14 apt_repository: repo="ppa:juju/stable"
15
16 - name: Add Ansible repository
17 apt_repository: repo="ppa:ansible/ansible"
18
Andy Bavier093e6a82015-08-21 13:31:31 -040019 - name: Update Ansible cache
20 apt: update_cache=yes
Andy Baviercccf27b2015-08-17 14:48:29 -040021
22 - name: Install packages
23 apt: name={{ item }} state=latest
24 with_items:
25 - ansible
26 - uvtool
27 - git
28 - bzr
Andy Bavier093e6a82015-08-21 13:31:31 -040029 - juju-core
Andy Baviercccf27b2015-08-17 14:48:29 -040030
31 - name: Get juju-ansible git repo
32 git: repo=https://github.com/cmars/juju-ansible.git
33 dest=/usr/local/src/juju-ansible
34
35 - name: Set up juju-ansible symlink
36 file: dest=/usr/local/bin/juju-ansible
37 src=/usr/local/src/juju-ansible/juju-ansible
38 state=link
39
40 - name: Set up juju-ansible-playbook symlink
41 file: dest=/usr/local/bin/juju-ansible-playbook
42 src=/usr/local/src/juju-ansible/juju-ansible
43 state=link
44
45 - name: Generate key to use in VMs
46 user: name={{ ansible_env['SUDO_USER'] }} generate_ssh_key=yes
47
48 - name: Set up extra space on CloudLab nodes
49 shell: /usr/testbed/bin/mkextrafs /var/lib/uvtool/libvirt/images
50 creates=/var/lib/uvtool/libvirt/images/lost+found
51
52 - name: Add myself to libvirtd group
53 shell: usermod -aG libvirtd {{ ansible_env['SUDO_USER'] }}
54
55 - name: Get trusty image for uvtool
56 shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64
57
58 - name: Create VMs to host OpenCloud services
59 sudo: no
60 script: scripts/create-vms.sh
61
Andy Baviercccf27b2015-08-17 14:48:29 -040062 - include: tasks/vm-ips.yml
63
64 - name: Add VMs to /etc/hosts
65 template: src=templates/etc/hosts.j2
66 dest=/etc/hosts
67 notify:
68 - Reload dnsmasq
69
70 - name: Set up /etc/ansible/hosts
71 template: src=templates/etc/ansible/hosts.j2
72 dest=/etc/ansible/hosts
73
74 - name: Copy ansible.cfg to disable host key checking
75 sudo: no
76 copy: src=files/ansible.cfg
77 dest={{ ansible_env['PWD'] }}/.ansible.cfg
78
79 - name: Touch ~/.ssh/config
80 sudo: no
81 file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch
82
83 - name: Disable host key checking in SSH
84 sudo: no
85 lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config
86 line="StrictHostKeyChecking no"
87
88 - name: Test that we can log into every VM
89 sudo: no
90 shell: ansible services -m ping -u ubuntu
91
92 handlers:
93 - name: Reload dnsmasq
94 shell: killall -HUP dnsmasq
95
96# Play: Install services using Juju
97- hosts: cloudlab-head
98 vars:
99 charm_src: /usr/local/src/charms/trusty
100 tasks:
101 - name: Initialize Juju
102 sudo: no
103 shell: juju generate-config
104 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
105
106 - shell: uvt-kvm ip juju
107 register: juju_ip
108
109 - name: Juju config file
110 sudo: no
111 template: src=templates/environments.yaml.j2
112 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
113
114 - name: Bootstrap Juju
115 sudo: no
116 shell: juju bootstrap
117 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
118
119 # - pause: Break here and try rebooting Juju VM
120
121 - name: Copy openstack.cfg for Juju
122 sudo: yes
123 copy: src=files/openstack.cfg
124 dest=/usr/local/src/openstack.cfg
125
126 - name: Check for /usr/local/src/charms/trusty
127 sudo: yes
128 file: path={{ charm_src }}
129 state=directory
130 mode=0755
131
132 - name: Deploy OpenStack services with Juju
133 script: scripts/juju-setup.py
134
Andy Baviercccf27b2015-08-17 14:48:29 -0400135 - name: Add all Juju relations between services
136 script: scripts/juju-relations.py
137
138 - pause: prompt="Wait for relations to be fully added"
139
140# Play: Use libvirt hooks to set up iptables
141- hosts: cloudlab-head
142 sudo: yes
143 tasks:
144 - name: Enable port forwarding for services
145 copy: src=files/{{ item }}
146 dest={{ item }}
147 mode=0755
148 notify:
149 - reload libvirt config
150 - run qemu hook
151 with_items:
152 - /etc/libvirt/hooks/daemon
153 - /etc/libvirt/hooks/qemu
154
155 handlers:
156 - name: reload libvirt config
157 shell: killall -HUP libvirtd
158
159 - name: run qemu hook
160 shell: /etc/libvirt/hooks/qemu start start
161
162# Play: Create credentials, set up some basic OpenStack
163- hosts: cloudlab-head
164 sudo: no
165 tasks:
166
167 - name: Get keystone admin password
168 shell: juju run --unit=keystone/0 "sudo cat /var/lib/keystone/keystone.passwd"
169 register: keystone_password
170
171 - shell: uvt-kvm ip keystone
172 register: keystone_ip
173
174 - name: Create credentials
175 template: src=templates/admin-openrc.sh.j2
176 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
177
178 - name: Copy credentials to nova-cloud-controller
179 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
180
181 - name: Copy network setup script
182 sudo: yes
183 copy: src=scripts/network-setup.sh
184 dest=/usr/local/src/network-setup.sh
185 mode=0644
186
Andy Bavier4e7762e2015-08-27 14:36:34 -0400187 - name: Run network setup script
188 shell: ansible nova-cloud-controller -m script -u ubuntu -a "/usr/local/src/network-setup.sh"
Andy Baviercccf27b2015-08-17 14:48:29 -0400189
190 - name: Get public key
191 shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub
192 register: sshkey
193
194- hosts: cloudlab-compute
195 sudo: yes
196 vars:
197 control_net: 192.168.122.0/24
Andy Bavier093e6a82015-08-21 13:31:31 -0400198 gateway: "{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['ansible_default_ipv4']['address'] }}"
Andy Baviercccf27b2015-08-17 14:48:29 -0400199 tasks:
200 - name: Install package needed by Juju
201 apt: name=python-yaml state=present
202
Andy Bavier093e6a82015-08-21 13:31:31 -0400203 - name: Add key
204 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
205 key="{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['sshkey']['stdout'] }}"
206
Andy Baviercccf27b2015-08-17 14:48:29 -0400207 - name: Add route via /etc/rc.local
208 template: src=templates/etc/rc.local.cloudlab
209 dest=/etc/rc.local
210 mode=0755
211 notify:
212 - run /etc/rc.local
213
Andy Bavier093e6a82015-08-21 13:31:31 -0400214 - name: Touch ~/.ssh/config
215 file: path=/var/lib/nova state=directory
216
217 - name: Set up extra space on CloudLab nodes
218 shell: /usr/testbed/bin/mkextrafs /var/lib/nova
219 creates=/var/lib/nova/lost+found
Andy Baviercccf27b2015-08-17 14:48:29 -0400220
221 handlers:
222 - name: run /etc/rc.local
223 shell: /etc/rc.local