blob: c5c5ec1283922d161f67e04ce4854d1d755dbd14 [file] [log] [blame]
Andy Bavier2ab9b002016-02-01 15:06:13 -05001---
2# Play: set up head node
3- hosts: head
4 sudo: yes
5 tasks:
6
7 - apt: name={{ item }} update_cache=yes
8 with_items:
9 - python-pycurl
10 - software-properties-common
11
12 - name: Add Juju repository
13 apt_repository: repo="ppa:juju/stable"
14
15 - name: Add Ansible repository
16 apt_repository: repo="ppa:ansible/ansible"
17
Andy Bavier2c108de2016-02-18 16:55:00 -050018 - name: Update apt cache
Andy Bavier2ab9b002016-02-01 15:06:13 -050019 apt: update_cache=yes
20
21 - name: Install packages
22 apt: name={{ item }} state=latest
23 with_items:
24 - ansible
25 - uvtool
26 - git
27 - bzr
28 - juju-core
29 - juju-quickstart
30 - python-novaclient
31 - python-neutronclient
32 - python-keystoneclient
33 - python-glanceclient
34
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: Get public key
53 shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub
54 register: sshkey
55
56 - name: Add key
57 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
58 key="{{ sshkey.stdout }}"
59
Andy Bavier2c108de2016-02-18 16:55:00 -050060 - name: Copy keypair to /tmp
61 shell: cp -f {{ ansible_env['PWD'] }}/.ssh/{{ item }} /tmp; chmod +r /tmp/{{ item }}
62 with_items:
63 - id_rsa
64 - id_rsa.pub
65
66 - name: Check whether we're on CloudLab
67 shell: ls /usr/testbed/bin/mkextrafs
68 ignore_errors: true
69 register: is_cloudlab
70
Andy Bavier2ab9b002016-02-01 15:06:13 -050071 - name: (CloudLab) Set up extra disk space
72 shell: /usr/testbed/bin/mkextrafs -f /var/lib/uvtool/libvirt/images
73 creates=/var/lib/uvtool/libvirt/images/lost+found
Andy Bavier2c108de2016-02-18 16:55:00 -050074 when: is_cloudlab | success
Andy Bavier2ab9b002016-02-01 15:06:13 -050075
76 - name: Add myself to libvirtd group
77 user: name={{ ansible_env['SUDO_USER'] }}
78 groups=libvirtd
79 append=yes
80
81 - name: Get trusty image for uvtool
82 shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64
83
84# Play: create VMs to host OpenStack services
85- hosts: head
86 sudo: yes
87 tasks:
Andy Bavier2c108de2016-02-18 16:55:00 -050088 - name: Create VMs to host OpenCloud services on mgmtbr
Andy Bavier2ab9b002016-02-01 15:06:13 -050089 sudo: no
Andy Bavierb146f7f2016-02-12 10:03:35 -050090 script: scripts/create-vms-cord.sh
Andy Bavier2c108de2016-02-18 16:55:00 -050091 when: test_setup is not defined
Andy Bavier2ab9b002016-02-01 15:06:13 -050092
Andy Bavier2c108de2016-02-18 16:55:00 -050093 - name: Create VMs to host OpenCloud services on virbr0
94 sudo: no
95 script: scripts/create-vms-cord.sh --testing
96 when: test_setup is defined
97
98 - include: tasks/vm-ips-cord.yml
Andy Bavier2ab9b002016-02-01 15:06:13 -050099
100 - name: Add VMs to /etc/hosts
Andy Bavier2c108de2016-02-18 16:55:00 -0500101 template: src=templates/etc/cord-hosts.j2
Andy Bavier2ab9b002016-02-01 15:06:13 -0500102 dest=/etc/hosts
103 notify:
104 - Reload dnsmasq
105
106 - name: Set up /etc/ansible/hosts
Andy Bavier2c108de2016-02-18 16:55:00 -0500107 template: src=templates/etc/ansible/cord-hosts.j2
Andy Bavier2ab9b002016-02-01 15:06:13 -0500108 dest=/etc/ansible/hosts
109
110 - name: Copy ansible.cfg to disable host key checking
111 sudo: no
112 copy: src=files/ansible.cfg
113 dest={{ ansible_env['PWD'] }}/.ansible.cfg
114
115 - name: Touch ~/.ssh/config
116 sudo: no
117 file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch
118
119 - name: Disable host key checking in SSH
120 sudo: no
121 lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config
122 line="StrictHostKeyChecking no"
123
124 - name: Test that we can log into every VM
125 sudo: no
126 shell: ansible services -m ping -u ubuntu
127
128 handlers:
129 - name: Reload dnsmasq
130 shell: killall -HUP dnsmasq
131
132# Play: prepare compute nodes for installation
133- hosts: compute
134 sudo: yes
Andy Bavier2ab9b002016-02-01 15:06:13 -0500135 tasks:
136 - name: Install package needed by Juju
137 apt: name=python-yaml state=present
138
Andy Bavierb146f7f2016-02-12 10:03:35 -0500139 - name: Add key for standard user
Andy Bavier2ab9b002016-02-01 15:06:13 -0500140 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
141 key="{{ hostvars['head']['sshkey']['stdout'] }}"
142
Andy Bavierb146f7f2016-02-12 10:03:35 -0500143 - name: Add key for root
144 authorized_key: user="root"
145 key="{{ hostvars['head']['sshkey']['stdout'] }}"
Andy Bavier2ab9b002016-02-01 15:06:13 -0500146
Andy Bavier2c108de2016-02-18 16:55:00 -0500147 - name: Check whether we're on CloudLab
148 shell: ls /usr/testbed/bin/mkextrafs
149 ignore_errors: true
150 register: is_cloudlab
151
Andy Bavierb146f7f2016-02-12 10:03:35 -0500152 - name: Make sure that /var/lib/nova exists
Andy Bavier2ab9b002016-02-01 15:06:13 -0500153 file: path=/var/lib/nova state=directory
Andy Bavier2c108de2016-02-18 16:55:00 -0500154 when: is_cloudlab | success
Andy Bavier2ab9b002016-02-01 15:06:13 -0500155
156 - name: (CloudLab) Set up extra disk space
157 shell: /usr/testbed/bin/mkextrafs -f /var/lib/nova
158 creates=/var/lib/nova/lost+found
Andy Bavier2c108de2016-02-18 16:55:00 -0500159 when: is_cloudlab | success
Andy Bavier2ab9b002016-02-01 15:06:13 -0500160
161# Play: Install services using Juju
162- hosts: head
163 vars:
164 charm_src: /usr/local/src/charms/trusty
165 tasks:
166 - name: Initialize Juju
167 sudo: no
168 shell: juju generate-config
169 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
170
171 - shell: uvt-kvm ip juju
172 register: juju_ip
173
174 - name: Juju config file
175 sudo: no
176 template: src=templates/environments.yaml.j2
177 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
178
179 - name: Bootstrap Juju
180 sudo: no
181 shell: juju bootstrap
182 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
183
184 - name: Add virtual machines to Juju's control
185 script: scripts/juju-cord-setup.py
186
187 - name: Add compute nodes to Juju's control
188 shell: juju add-machine ssh:{{ item }}
189 with_items: "{{ groups['compute'] }}"
190
Andy Bavier2c108de2016-02-18 16:55:00 -0500191 - name: Get onos-cord IP
192 shell: uvt-kvm ip onos-cord
193 register: onos_cord_ip
194
Andy Bavier2ab9b002016-02-01 15:06:13 -0500195 - name: Copy cord.yaml bundle
Andy Bavier2c108de2016-02-18 16:55:00 -0500196 template: src=templates/cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml
Andy Bavier2ab9b002016-02-01 15:06:13 -0500197
198 - name: Deploy OpenStack services with Juju
199 shell: juju quickstart cord.yaml
Andy Bavierb146f7f2016-02-12 10:03:35 -0500200
201- hosts: head
202 sudo: no
203 tasks:
204
205 - name: Get Keystone IP
206 shell: uvt-kvm ip keystone
207 register: keystone_ip
208
209 - name: Create credentials
210 template: src=templates/admin-openrc-cord.sh.j2
211 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
212
Andy Bavier2c108de2016-02-18 16:55:00 -0500213 - name: Copy credentials to /tmp
214 shell: cp -f {{ ansible_env['PWD'] }}/admin-openrc.sh /tmp
215
Andy Bavierb146f7f2016-02-12 10:03:35 -0500216 - name: Copy credentials to nova-cloud-controller
217 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
Andy Bavier2c108de2016-02-18 16:55:00 -0500218
219- hosts: head
220 sudo: no
221 tasks:
222
223 - name: Copy over VM setup files
224 copy: src=files/tmp/{{ item }}
225 dest=/tmp
226 with_items:
227 - set-up-xos.yml
228 - set-up-onos.yml
229
230 - name: Copy over ONOS docker-compose.yml
231 copy: src=files/onos/docker-compose.yml
232 dest=/tmp
233
234 - name: Set up xos VM
235 shell: ansible-playbook /tmp/set-up-xos.yml
236
237 - name: Set up onos-cord VM
238 shell: ansible-playbook /tmp/set-up-onos.yml