blob: 30305562f41e10cd3cf815a61649463a37a9cc4c [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
Andy Baviera08061a2015-10-05 08:24:59 -040052 - name: (CloudLab) Set up extra disk space
Andy Baviercccf27b2015-08-17 14:48:29 -040053 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
Andy Bavierc1dfb882015-10-07 16:20:24 -040064 - name: Change the subnet of virbr0 to 192.168.100.0/24
65 shell: sed -i 's/192.168.122/192.168.100/g' /etc/libvirt/qemu/networks/default.xml
66
Andy Baviercccf27b2015-08-17 14:48:29 -040067 - name: Create VMs to host OpenCloud services
68 sudo: no
69 script: scripts/create-vms.sh
70
Andy Baviercccf27b2015-08-17 14:48:29 -040071 - include: tasks/vm-ips.yml
72
73 - name: Add VMs to /etc/hosts
74 template: src=templates/etc/hosts.j2
75 dest=/etc/hosts
76 notify:
77 - Reload dnsmasq
78
79 - name: Set up /etc/ansible/hosts
80 template: src=templates/etc/ansible/hosts.j2
81 dest=/etc/ansible/hosts
82
83 - name: Copy ansible.cfg to disable host key checking
84 sudo: no
85 copy: src=files/ansible.cfg
86 dest={{ ansible_env['PWD'] }}/.ansible.cfg
87
88 - name: Touch ~/.ssh/config
89 sudo: no
90 file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch
91
92 - name: Disable host key checking in SSH
93 sudo: no
94 lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config
95 line="StrictHostKeyChecking no"
96
97 - name: Test that we can log into every VM
98 sudo: no
99 shell: ansible services -m ping -u ubuntu
100
101 handlers:
102 - name: Reload dnsmasq
103 shell: killall -HUP dnsmasq
104
105# Play: Install services using Juju
106- hosts: cloudlab-head
107 vars:
108 charm_src: /usr/local/src/charms/trusty
109 tasks:
110 - name: Initialize Juju
111 sudo: no
112 shell: juju generate-config
113 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
114
115 - shell: uvt-kvm ip juju
116 register: juju_ip
117
118 - name: Juju config file
119 sudo: no
120 template: src=templates/environments.yaml.j2
121 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
122
123 - name: Bootstrap Juju
124 sudo: no
125 shell: juju bootstrap
126 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
127
Andy Baviercccf27b2015-08-17 14:48:29 -0400128 - name: Copy openstack.cfg for Juju
129 sudo: yes
130 copy: src=files/openstack.cfg
131 dest=/usr/local/src/openstack.cfg
132
133 - name: Check for /usr/local/src/charms/trusty
134 sudo: yes
135 file: path={{ charm_src }}
136 state=directory
137 mode=0755
138
139 - name: Deploy OpenStack services with Juju
140 script: scripts/juju-setup.py
141
Andy Baviercccf27b2015-08-17 14:48:29 -0400142 - name: Add all Juju relations between services
143 script: scripts/juju-relations.py
144
Andy Bavier52017142015-10-05 15:01:36 -0400145 - name: Wait for relations to be fully added
146 script: scripts/wait-for-services.sh
Andy Baviercccf27b2015-08-17 14:48:29 -0400147
148# Play: Use libvirt hooks to set up iptables
149- hosts: cloudlab-head
150 sudo: yes
151 tasks:
152 - name: Enable port forwarding for services
153 copy: src=files/{{ item }}
154 dest={{ item }}
155 mode=0755
156 notify:
157 - reload libvirt config
158 - run qemu hook
159 with_items:
160 - /etc/libvirt/hooks/daemon
161 - /etc/libvirt/hooks/qemu
162
163 handlers:
164 - name: reload libvirt config
165 shell: killall -HUP libvirtd
166
167 - name: run qemu hook
168 shell: /etc/libvirt/hooks/qemu start start
169
170# Play: Create credentials, set up some basic OpenStack
171- hosts: cloudlab-head
172 sudo: no
173 tasks:
174
175 - name: Get keystone admin password
176 shell: juju run --unit=keystone/0 "sudo cat /var/lib/keystone/keystone.passwd"
177 register: keystone_password
178
179 - shell: uvt-kvm ip keystone
180 register: keystone_ip
181
182 - name: Create credentials
183 template: src=templates/admin-openrc.sh.j2
184 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
185
Andy Baviera08061a2015-10-05 08:24:59 -0400186 - name: (CloudLab) Make sure that /root/setup exists
Andy Bavier8da6df12015-10-02 12:33:48 -0400187 file: path=/root/setup state=directory
188 sudo: yes
189
Andy Baviera08061a2015-10-05 08:24:59 -0400190 - name: (CloudLab) Copy credentials to /root/setup
Andy Bavier8da6df12015-10-02 12:33:48 -0400191 shell: scp admin-openrc.sh /root/setup
192 sudo: yes
193
Andy Baviercccf27b2015-08-17 14:48:29 -0400194 - name: Copy credentials to nova-cloud-controller
195 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
196
197 - name: Copy network setup script
198 sudo: yes
199 copy: src=scripts/network-setup.sh
200 dest=/usr/local/src/network-setup.sh
201 mode=0644
202
Andy Bavier4e7762e2015-08-27 14:36:34 -0400203 - name: Run network setup script
204 shell: ansible nova-cloud-controller -m script -u ubuntu -a "/usr/local/src/network-setup.sh"
Andy Baviercccf27b2015-08-17 14:48:29 -0400205
206 - name: Get public key
207 shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub
208 register: sshkey
209
Andy Bavier8da6df12015-10-02 12:33:48 -0400210 - name: Copy CA certificate
Andy Bavier52017142015-10-05 15:01:36 -0400211 shell: sudo juju scp nova-cloud-controller/0:/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt /usr/local/share/ca-certificates
Andy Bavier8da6df12015-10-02 12:33:48 -0400212 creates=/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt
Andy Bavier8da6df12015-10-02 12:33:48 -0400213
214 - name: Update CA ca-certificates
215 shell: update-ca-certificates
216 sudo: yes
217
Andy Baviercccf27b2015-08-17 14:48:29 -0400218- hosts: cloudlab-compute
219 sudo: yes
220 vars:
221 control_net: 192.168.122.0/24
Andy Bavier093e6a82015-08-21 13:31:31 -0400222 gateway: "{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['ansible_default_ipv4']['address'] }}"
Andy Baviercccf27b2015-08-17 14:48:29 -0400223 tasks:
224 - name: Install package needed by Juju
225 apt: name=python-yaml state=present
226
Andy Bavier093e6a82015-08-21 13:31:31 -0400227 - name: Add key
228 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
229 key="{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['sshkey']['stdout'] }}"
230
Andy Baviercccf27b2015-08-17 14:48:29 -0400231 - name: Add route via /etc/rc.local
232 template: src=templates/etc/rc.local.cloudlab
233 dest=/etc/rc.local
234 mode=0755
235 notify:
236 - run /etc/rc.local
237
Andy Bavier093e6a82015-08-21 13:31:31 -0400238 - name: Touch ~/.ssh/config
239 file: path=/var/lib/nova state=directory
240
Andy Baviera08061a2015-10-05 08:24:59 -0400241 - name: (CloudLab) Set up extra disk space
Andy Bavier093e6a82015-08-21 13:31:31 -0400242 shell: /usr/testbed/bin/mkextrafs /var/lib/nova
243 creates=/var/lib/nova/lost+found
Andy Baviercccf27b2015-08-17 14:48:29 -0400244
245 handlers:
246 - name: run /etc/rc.local
247 shell: /etc/rc.local