blob: d6a98c595298edb26c72a2b045dc5ec00a77afdc [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
19 - name: Install older version of Juju due to bug in 1.22
20 apt: name=juju-core
21
22 - name: Install packages
23 apt: name={{ item }} state=latest
24 with_items:
25 - ansible
26 - uvtool
27 - git
28 - bzr
29
30 - name: Get juju-ansible git repo
31 git: repo=https://github.com/cmars/juju-ansible.git
32 dest=/usr/local/src/juju-ansible
33
34 - name: Set up juju-ansible symlink
35 file: dest=/usr/local/bin/juju-ansible
36 src=/usr/local/src/juju-ansible/juju-ansible
37 state=link
38
39 - name: Set up juju-ansible-playbook symlink
40 file: dest=/usr/local/bin/juju-ansible-playbook
41 src=/usr/local/src/juju-ansible/juju-ansible
42 state=link
43
44 - name: Generate key to use in VMs
45 user: name={{ ansible_env['SUDO_USER'] }} generate_ssh_key=yes
46
47 - name: Set up extra space on CloudLab nodes
48 shell: /usr/testbed/bin/mkextrafs /var/lib/uvtool/libvirt/images
49 creates=/var/lib/uvtool/libvirt/images/lost+found
50
51 - name: Add myself to libvirtd group
52 shell: usermod -aG libvirtd {{ ansible_env['SUDO_USER'] }}
53
54 - name: Get trusty image for uvtool
55 shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64
56
57 - name: Create VMs to host OpenCloud services
58 sudo: no
59 script: scripts/create-vms.sh
60
61# - pause: prompt="Hit return when all VMs have IP addresses"
62
63 - include: tasks/vm-ips.yml
64
65 - name: Add VMs to /etc/hosts
66 template: src=templates/etc/hosts.j2
67 dest=/etc/hosts
68 notify:
69 - Reload dnsmasq
70
71 - name: Set up /etc/ansible/hosts
72 template: src=templates/etc/ansible/hosts.j2
73 dest=/etc/ansible/hosts
74
75 - name: Copy ansible.cfg to disable host key checking
76 sudo: no
77 copy: src=files/ansible.cfg
78 dest={{ ansible_env['PWD'] }}/.ansible.cfg
79
80 - name: Touch ~/.ssh/config
81 sudo: no
82 file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch
83
84 - name: Disable host key checking in SSH
85 sudo: no
86 lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config
87 line="StrictHostKeyChecking no"
88
89 - name: Test that we can log into every VM
90 sudo: no
91 shell: ansible services -m ping -u ubuntu
92
93 handlers:
94 - name: Reload dnsmasq
95 shell: killall -HUP dnsmasq
96
97# Play: Install services using Juju
98- hosts: cloudlab-head
99 vars:
100 charm_src: /usr/local/src/charms/trusty
101 tasks:
102 - name: Initialize Juju
103 sudo: no
104 shell: juju generate-config
105 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
106
107 - shell: uvt-kvm ip juju
108 register: juju_ip
109
110 - name: Juju config file
111 sudo: no
112 template: src=templates/environments.yaml.j2
113 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
114
115 - name: Bootstrap Juju
116 sudo: no
117 shell: juju bootstrap
118 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
119
120 # - pause: Break here and try rebooting Juju VM
121
122 - name: Copy openstack.cfg for Juju
123 sudo: yes
124 copy: src=files/openstack.cfg
125 dest=/usr/local/src/openstack.cfg
126
127 - name: Check for /usr/local/src/charms/trusty
128 sudo: yes
129 file: path={{ charm_src }}
130 state=directory
131 mode=0755
132
133 - name: Deploy OpenStack services with Juju
134 script: scripts/juju-setup.py
135
136# - pause: prompt="Hit return when all services have started successfully"
137
138 - name: Set MTU for GRE tunneling
139 shell: "juju set quantum-gateway instance-mtu=1400"
140
141 - name: Use HTTPS for keystone authentication
142 shell: 'juju set keystone use-https=yes'
143
144 - name: Use HTTPS for all service endpoints
145 shell: 'juju set keystone https-service-endpoints=True'
146
147 - name: Use SSL for rabbitmq
148 shell: 'juju set rabbitmq-server ssl=on'
149
150 - name: Add all Juju relations between services
151 script: scripts/juju-relations.py
152
153 - pause: prompt="Wait for relations to be fully added"
154
155# Play: Use libvirt hooks to set up iptables
156- hosts: cloudlab-head
157 sudo: yes
158 tasks:
159 - name: Enable port forwarding for services
160 copy: src=files/{{ item }}
161 dest={{ item }}
162 mode=0755
163 notify:
164 - reload libvirt config
165 - run qemu hook
166 with_items:
167 - /etc/libvirt/hooks/daemon
168 - /etc/libvirt/hooks/qemu
169
170 handlers:
171 - name: reload libvirt config
172 shell: killall -HUP libvirtd
173
174 - name: run qemu hook
175 shell: /etc/libvirt/hooks/qemu start start
176
177# Play: Create credentials, set up some basic OpenStack
178- hosts: cloudlab-head
179 sudo: no
180 tasks:
181
182 - name: Get keystone admin password
183 shell: juju run --unit=keystone/0 "sudo cat /var/lib/keystone/keystone.passwd"
184 register: keystone_password
185
186 - shell: uvt-kvm ip keystone
187 register: keystone_ip
188
189 - name: Create credentials
190 template: src=templates/admin-openrc.sh.j2
191 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
192
193 - name: Copy credentials to nova-cloud-controller
194 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
195
196 - name: Copy network setup script
197 sudo: yes
198 copy: src=scripts/network-setup.sh
199 dest=/usr/local/src/network-setup.sh
200 mode=0644
201
202 - name: Run network setup script
203 shell: ansible nova-cloud-controller -m script -u ubuntu -a "/usr/local/src/network-setup.sh"
204
205 - name: Get public key
206 shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub
207 register: sshkey
208
209- hosts: cloudlab-compute
210 sudo: yes
211 vars:
212 control_net: 192.168.122.0/24
213 gateway: 130.127.133.105
214 tasks:
215 - name: Install package needed by Juju
216 apt: name=python-yaml state=present
217
218 - name: Add route via /etc/rc.local
219 template: src=templates/etc/rc.local.cloudlab
220 dest=/etc/rc.local
221 mode=0755
222 notify:
223 - run /etc/rc.local
224
225 - name: Add key
226 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
227 key="{{ hostvars['ctl.acb-qv8253.xos-pg0.clemson.cloudlab.us']['sshkey']['stdout'] }}"
228
229 handlers:
230 - name: run /etc/rc.local
231 shell: /etc/rc.local