blob: 09839e751df7bb3b11af076018ed73167acd140d [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
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
Andy Baviercccf27b2015-08-17 14:48:29 -0400125 - name: Copy openstack.cfg for Juju
126 sudo: yes
127 copy: src=files/openstack.cfg
128 dest=/usr/local/src/openstack.cfg
129
130 - name: Check for /usr/local/src/charms/trusty
131 sudo: yes
132 file: path={{ charm_src }}
133 state=directory
134 mode=0755
135
136 - name: Deploy OpenStack services with Juju
137 script: scripts/juju-setup.py
138
Andy Baviercccf27b2015-08-17 14:48:29 -0400139 - name: Add all Juju relations between services
140 script: scripts/juju-relations.py
141
Andy Bavier52017142015-10-05 15:01:36 -0400142 - name: Wait for relations to be fully added
143 script: scripts/wait-for-services.sh
Andy Baviercccf27b2015-08-17 14:48:29 -0400144
145# Play: Use libvirt hooks to set up iptables
146- hosts: cloudlab-head
147 sudo: yes
148 tasks:
149 - name: Enable port forwarding for services
150 copy: src=files/{{ item }}
151 dest={{ item }}
152 mode=0755
153 notify:
154 - reload libvirt config
155 - run qemu hook
156 with_items:
157 - /etc/libvirt/hooks/daemon
158 - /etc/libvirt/hooks/qemu
159
160 handlers:
161 - name: reload libvirt config
162 shell: killall -HUP libvirtd
163
164 - name: run qemu hook
165 shell: /etc/libvirt/hooks/qemu start start
166
167# Play: Create credentials, set up some basic OpenStack
168- hosts: cloudlab-head
169 sudo: no
170 tasks:
171
172 - name: Get keystone admin password
173 shell: juju run --unit=keystone/0 "sudo cat /var/lib/keystone/keystone.passwd"
174 register: keystone_password
175
176 - shell: uvt-kvm ip keystone
177 register: keystone_ip
178
179 - name: Create credentials
180 template: src=templates/admin-openrc.sh.j2
181 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
182
Andy Baviera08061a2015-10-05 08:24:59 -0400183 - name: (CloudLab) Make sure that /root/setup exists
Andy Bavier8da6df12015-10-02 12:33:48 -0400184 file: path=/root/setup state=directory
185 sudo: yes
186
Andy Baviera08061a2015-10-05 08:24:59 -0400187 - name: (CloudLab) Copy credentials to /root/setup
Andy Bavier8da6df12015-10-02 12:33:48 -0400188 shell: scp admin-openrc.sh /root/setup
189 sudo: yes
190
Andy Baviercccf27b2015-08-17 14:48:29 -0400191 - name: Copy credentials to nova-cloud-controller
192 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
193
194 - name: Copy network setup script
195 sudo: yes
196 copy: src=scripts/network-setup.sh
197 dest=/usr/local/src/network-setup.sh
198 mode=0644
199
Andy Bavier4e7762e2015-08-27 14:36:34 -0400200 - name: Run network setup script
201 shell: ansible nova-cloud-controller -m script -u ubuntu -a "/usr/local/src/network-setup.sh"
Andy Baviercccf27b2015-08-17 14:48:29 -0400202
203 - name: Get public key
204 shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub
205 register: sshkey
206
Andy Bavier8da6df12015-10-02 12:33:48 -0400207 - name: Copy CA certificate
Andy Bavier52017142015-10-05 15:01:36 -0400208 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 -0400209 creates=/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt
Andy Bavier8da6df12015-10-02 12:33:48 -0400210
211 - name: Update CA ca-certificates
212 shell: update-ca-certificates
213 sudo: yes
214
Andy Baviercccf27b2015-08-17 14:48:29 -0400215- hosts: cloudlab-compute
216 sudo: yes
217 vars:
218 control_net: 192.168.122.0/24
Andy Bavier093e6a82015-08-21 13:31:31 -0400219 gateway: "{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['ansible_default_ipv4']['address'] }}"
Andy Baviercccf27b2015-08-17 14:48:29 -0400220 tasks:
221 - name: Install package needed by Juju
222 apt: name=python-yaml state=present
223
Andy Bavier093e6a82015-08-21 13:31:31 -0400224 - name: Add key
225 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
226 key="{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['sshkey']['stdout'] }}"
227
Andy Baviercccf27b2015-08-17 14:48:29 -0400228 - name: Add route via /etc/rc.local
229 template: src=templates/etc/rc.local.cloudlab
230 dest=/etc/rc.local
231 mode=0755
232 notify:
233 - run /etc/rc.local
234
Andy Bavier093e6a82015-08-21 13:31:31 -0400235 - name: Touch ~/.ssh/config
236 file: path=/var/lib/nova state=directory
237
Andy Baviera08061a2015-10-05 08:24:59 -0400238 - name: (CloudLab) Set up extra disk space
Andy Bavier093e6a82015-08-21 13:31:31 -0400239 shell: /usr/testbed/bin/mkextrafs /var/lib/nova
240 creates=/var/lib/nova/lost+found
Andy Baviercccf27b2015-08-17 14:48:29 -0400241
242 handlers:
243 - name: run /etc/rc.local
244 shell: /etc/rc.local