blob: 076580d72a86cdae7b744b8313c0df17339b9ab5 [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
Andy Bavier58c8c522015-09-30 16:24:28 -04008 - apt: name={{ item }} update_cache=yes
Andy Baviercccf27b2015-08-17 14:48:29 -04009 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 Bavier8da6df12015-10-02 12:33:48 -040030 - python-novaclient
31 - python-neutronclient
32 - python-keystoneclient
33 - python-glanceclient
Andy Baviercccf27b2015-08-17 14:48:29 -040034
35 - name: Get juju-ansible git repo
36 git: repo=https://github.com/cmars/juju-ansible.git
37 dest=/usr/local/src/juju-ansible
38
39 - name: Set up juju-ansible symlink
40 file: dest=/usr/local/bin/juju-ansible
41 src=/usr/local/src/juju-ansible/juju-ansible
42 state=link
43
44 - name: Set up juju-ansible-playbook symlink
45 file: dest=/usr/local/bin/juju-ansible-playbook
46 src=/usr/local/src/juju-ansible/juju-ansible
47 state=link
48
49 - name: Generate key to use in VMs
50 user: name={{ ansible_env['SUDO_USER'] }} generate_ssh_key=yes
51
52 - name: Set up extra space on CloudLab nodes
53 shell: /usr/testbed/bin/mkextrafs /var/lib/uvtool/libvirt/images
54 creates=/var/lib/uvtool/libvirt/images/lost+found
55
56 - name: Add myself to libvirtd group
Andy Bavierb1ae26e2015-09-17 16:20:46 -040057 user: name={{ ansible_env['SUDO_USER'] }}
58 groups=libvirtd
59 append=yes
Andy Baviercccf27b2015-08-17 14:48:29 -040060
61 - name: Get trusty image for uvtool
62 shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64
63
64 - name: Create VMs to host OpenCloud services
65 sudo: no
66 script: scripts/create-vms.sh
67
Andy Baviercccf27b2015-08-17 14:48:29 -040068 - include: tasks/vm-ips.yml
69
70 - name: Add VMs to /etc/hosts
71 template: src=templates/etc/hosts.j2
72 dest=/etc/hosts
73 notify:
74 - Reload dnsmasq
75
76 - name: Set up /etc/ansible/hosts
77 template: src=templates/etc/ansible/hosts.j2
78 dest=/etc/ansible/hosts
79
80 - name: Copy ansible.cfg to disable host key checking
81 sudo: no
82 copy: src=files/ansible.cfg
83 dest={{ ansible_env['PWD'] }}/.ansible.cfg
84
85 - name: Touch ~/.ssh/config
86 sudo: no
87 file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch
88
89 - name: Disable host key checking in SSH
90 sudo: no
91 lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config
92 line="StrictHostKeyChecking no"
93
94 - name: Test that we can log into every VM
95 sudo: no
96 shell: ansible services -m ping -u ubuntu
97
98 handlers:
99 - name: Reload dnsmasq
100 shell: killall -HUP dnsmasq
101
102# Play: Install services using Juju
103- hosts: cloudlab-head
104 vars:
105 charm_src: /usr/local/src/charms/trusty
106 tasks:
107 - name: Initialize Juju
108 sudo: no
109 shell: juju generate-config
110 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
111
112 - shell: uvt-kvm ip juju
113 register: juju_ip
114
115 - name: Juju config file
116 sudo: no
117 template: src=templates/environments.yaml.j2
118 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
119
120 - name: Bootstrap Juju
121 sudo: no
122 shell: juju bootstrap
123 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
124
125 # - pause: Break here and try rebooting Juju VM
126
127 - name: Copy openstack.cfg for Juju
128 sudo: yes
129 copy: src=files/openstack.cfg
130 dest=/usr/local/src/openstack.cfg
131
132 - name: Check for /usr/local/src/charms/trusty
133 sudo: yes
134 file: path={{ charm_src }}
135 state=directory
136 mode=0755
137
138 - name: Deploy OpenStack services with Juju
139 script: scripts/juju-setup.py
140
Andy Baviercccf27b2015-08-17 14:48:29 -0400141 - name: Add all Juju relations between services
142 script: scripts/juju-relations.py
143
144 - pause: prompt="Wait for relations to be fully added"
145
146# Play: Use libvirt hooks to set up iptables
147- hosts: cloudlab-head
148 sudo: yes
149 tasks:
150 - name: Enable port forwarding for services
151 copy: src=files/{{ item }}
152 dest={{ item }}
153 mode=0755
154 notify:
155 - reload libvirt config
156 - run qemu hook
157 with_items:
158 - /etc/libvirt/hooks/daemon
159 - /etc/libvirt/hooks/qemu
160
161 handlers:
162 - name: reload libvirt config
163 shell: killall -HUP libvirtd
164
165 - name: run qemu hook
166 shell: /etc/libvirt/hooks/qemu start start
167
168# Play: Create credentials, set up some basic OpenStack
169- hosts: cloudlab-head
170 sudo: no
171 tasks:
172
173 - name: Get keystone admin password
174 shell: juju run --unit=keystone/0 "sudo cat /var/lib/keystone/keystone.passwd"
175 register: keystone_password
176
177 - shell: uvt-kvm ip keystone
178 register: keystone_ip
179
180 - name: Create credentials
181 template: src=templates/admin-openrc.sh.j2
182 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
183
Andy Bavier8da6df12015-10-02 12:33:48 -0400184 - name: CloudLab: Make sure that /root/setup exists
185 file: path=/root/setup state=directory
186 sudo: yes
187
188 - name: CloudLab: Copy credentials to /root/setup
189 shell: scp admin-openrc.sh /root/setup
190 sudo: yes
191
Andy Baviercccf27b2015-08-17 14:48:29 -0400192 - name: Copy credentials to nova-cloud-controller
193 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
194
195 - name: Copy network setup script
196 sudo: yes
197 copy: src=scripts/network-setup.sh
198 dest=/usr/local/src/network-setup.sh
199 mode=0644
200
Andy Bavier4e7762e2015-08-27 14:36:34 -0400201 - name: Run network setup script
202 shell: ansible nova-cloud-controller -m script -u ubuntu -a "/usr/local/src/network-setup.sh"
Andy Baviercccf27b2015-08-17 14:48:29 -0400203
204 - name: Get public key
205 shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub
206 register: sshkey
207
Andy Bavier8da6df12015-10-02 12:33:48 -0400208 - name: Copy CA certificate
209 shell: juju scp nova-cloud-controller/0:/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt /usr/local/share/ca-certificates
210 creates=/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt
211 sudo: yes
212
213 - name: Update CA ca-certificates
214 shell: update-ca-certificates
215 sudo: yes
216
Andy Baviercccf27b2015-08-17 14:48:29 -0400217- hosts: cloudlab-compute
218 sudo: yes
219 vars:
220 control_net: 192.168.122.0/24
Andy Bavier093e6a82015-08-21 13:31:31 -0400221 gateway: "{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['ansible_default_ipv4']['address'] }}"
Andy Baviercccf27b2015-08-17 14:48:29 -0400222 tasks:
223 - name: Install package needed by Juju
224 apt: name=python-yaml state=present
225
Andy Bavier093e6a82015-08-21 13:31:31 -0400226 - name: Add key
227 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
228 key="{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['sshkey']['stdout'] }}"
229
Andy Baviercccf27b2015-08-17 14:48:29 -0400230 - name: Add route via /etc/rc.local
231 template: src=templates/etc/rc.local.cloudlab
232 dest=/etc/rc.local
233 mode=0755
234 notify:
235 - run /etc/rc.local
236
Andy Bavier093e6a82015-08-21 13:31:31 -0400237 - name: Touch ~/.ssh/config
238 file: path=/var/lib/nova state=directory
239
240 - name: Set up extra space on CloudLab nodes
241 shell: /usr/testbed/bin/mkextrafs /var/lib/nova
242 creates=/var/lib/nova/lost+found
Andy Baviercccf27b2015-08-17 14:48:29 -0400243
244 handlers:
245 - name: run /etc/rc.local
246 shell: /etc/rc.local