blob: c2fb8e0667334d98f1ae30e18148c48551a01781 [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
Andy Bavierae1e4932016-02-22 12:07:49 -050035 - name: Patch uvt-kvm
36 copy: src=files/usr/lib/python2.7/dist-packages/uvtool/libvirt/__init__.py
37 dest=/usr/lib/python2.7/dist-packages/uvtool/libvirt/__init__.py
38
Andy Bavier2ab9b002016-02-01 15:06:13 -050039 - name: Get juju-ansible git repo
40 git: repo=https://github.com/cmars/juju-ansible.git
41 dest=/usr/local/src/juju-ansible
42
43 - name: Set up juju-ansible symlink
44 file: dest=/usr/local/bin/juju-ansible
45 src=/usr/local/src/juju-ansible/juju-ansible
46 state=link
47
48 - name: Set up juju-ansible-playbook symlink
49 file: dest=/usr/local/bin/juju-ansible-playbook
50 src=/usr/local/src/juju-ansible/juju-ansible
51 state=link
52
53 - name: Generate key to use in VMs
54 user: name={{ ansible_env['SUDO_USER'] }} generate_ssh_key=yes
55
56 - name: Get public key
57 shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub
58 register: sshkey
59
60 - name: Add key
61 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
62 key="{{ sshkey.stdout }}"
63
Andy Bavier2c108de2016-02-18 16:55:00 -050064 - name: Copy keypair to /tmp
65 shell: cp -f {{ ansible_env['PWD'] }}/.ssh/{{ item }} /tmp; chmod +r /tmp/{{ item }}
66 with_items:
67 - id_rsa
68 - id_rsa.pub
69
70 - name: Check whether we're on CloudLab
71 shell: ls /usr/testbed/bin/mkextrafs
72 ignore_errors: true
73 register: is_cloudlab
74
Andy Bavier2ab9b002016-02-01 15:06:13 -050075 - name: (CloudLab) Set up extra disk space
76 shell: /usr/testbed/bin/mkextrafs -f /var/lib/uvtool/libvirt/images
77 creates=/var/lib/uvtool/libvirt/images/lost+found
Andy Bavier2c108de2016-02-18 16:55:00 -050078 when: is_cloudlab | success
Andy Bavier2ab9b002016-02-01 15:06:13 -050079
80 - name: Add myself to libvirtd group
81 user: name={{ ansible_env['SUDO_USER'] }}
82 groups=libvirtd
83 append=yes
84
85 - name: Get trusty image for uvtool
86 shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64
87
88# Play: create VMs to host OpenStack services
89- hosts: head
90 sudo: yes
91 tasks:
Andy Bavier2c108de2016-02-18 16:55:00 -050092 - name: Create VMs to host OpenCloud services on mgmtbr
Andy Bavier2ab9b002016-02-01 15:06:13 -050093 sudo: no
Andy Bavierb146f7f2016-02-12 10:03:35 -050094 script: scripts/create-vms-cord.sh
Andy Bavier2c108de2016-02-18 16:55:00 -050095 when: test_setup is not defined
Andy Bavier2ab9b002016-02-01 15:06:13 -050096
Andy Bavier2c108de2016-02-18 16:55:00 -050097 - name: Create VMs to host OpenCloud services on virbr0
98 sudo: no
99 script: scripts/create-vms-cord.sh --testing
100 when: test_setup is defined
101
102 - include: tasks/vm-ips-cord.yml
Andy Bavier2ab9b002016-02-01 15:06:13 -0500103
104 - name: Add VMs to /etc/hosts
Andy Bavier2c108de2016-02-18 16:55:00 -0500105 template: src=templates/etc/cord-hosts.j2
Andy Bavier2ab9b002016-02-01 15:06:13 -0500106 dest=/etc/hosts
107 notify:
108 - Reload dnsmasq
109
110 - name: Set up /etc/ansible/hosts
Andy Bavier2c108de2016-02-18 16:55:00 -0500111 template: src=templates/etc/ansible/cord-hosts.j2
Andy Bavier2ab9b002016-02-01 15:06:13 -0500112 dest=/etc/ansible/hosts
113
114 - name: Copy ansible.cfg to disable host key checking
115 sudo: no
116 copy: src=files/ansible.cfg
117 dest={{ ansible_env['PWD'] }}/.ansible.cfg
118
119 - name: Touch ~/.ssh/config
120 sudo: no
121 file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch
122
123 - name: Disable host key checking in SSH
124 sudo: no
125 lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config
126 line="StrictHostKeyChecking no"
127
128 - name: Test that we can log into every VM
129 sudo: no
130 shell: ansible services -m ping -u ubuntu
131
132 handlers:
133 - name: Reload dnsmasq
134 shell: killall -HUP dnsmasq
135
136# Play: prepare compute nodes for installation
137- hosts: compute
138 sudo: yes
Andy Bavier2ab9b002016-02-01 15:06:13 -0500139 tasks:
140 - name: Install package needed by Juju
141 apt: name=python-yaml state=present
142
Andy Bavierb146f7f2016-02-12 10:03:35 -0500143 - name: Add key for standard user
Andy Bavier2ab9b002016-02-01 15:06:13 -0500144 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
145 key="{{ hostvars['head']['sshkey']['stdout'] }}"
146
Andy Bavierb146f7f2016-02-12 10:03:35 -0500147 - name: Add key for root
148 authorized_key: user="root"
149 key="{{ hostvars['head']['sshkey']['stdout'] }}"
Andy Bavier2ab9b002016-02-01 15:06:13 -0500150
Andy Bavier2c108de2016-02-18 16:55:00 -0500151 - name: Check whether we're on CloudLab
152 shell: ls /usr/testbed/bin/mkextrafs
153 ignore_errors: true
154 register: is_cloudlab
155
Andy Bavierb146f7f2016-02-12 10:03:35 -0500156 - name: Make sure that /var/lib/nova exists
Andy Bavier2ab9b002016-02-01 15:06:13 -0500157 file: path=/var/lib/nova state=directory
Andy Bavier2c108de2016-02-18 16:55:00 -0500158 when: is_cloudlab | success
Andy Bavier2ab9b002016-02-01 15:06:13 -0500159
160 - name: (CloudLab) Set up extra disk space
161 shell: /usr/testbed/bin/mkextrafs -f /var/lib/nova
162 creates=/var/lib/nova/lost+found
Andy Bavier2c108de2016-02-18 16:55:00 -0500163 when: is_cloudlab | success
Andy Bavier2ab9b002016-02-01 15:06:13 -0500164
165# Play: Install services using Juju
166- hosts: head
167 vars:
168 charm_src: /usr/local/src/charms/trusty
169 tasks:
170 - name: Initialize Juju
171 sudo: no
172 shell: juju generate-config
173 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
174
175 - shell: uvt-kvm ip juju
176 register: juju_ip
177
178 - name: Juju config file
179 sudo: no
180 template: src=templates/environments.yaml.j2
181 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
182
183 - name: Bootstrap Juju
184 sudo: no
185 shell: juju bootstrap
186 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
187
188 - name: Add virtual machines to Juju's control
189 script: scripts/juju-cord-setup.py
190
191 - name: Add compute nodes to Juju's control
192 shell: juju add-machine ssh:{{ item }}
193 with_items: "{{ groups['compute'] }}"
194
Andy Bavier2c108de2016-02-18 16:55:00 -0500195 - name: Get onos-cord IP
196 shell: uvt-kvm ip onos-cord
197 register: onos_cord_ip
198
Andy Bavier2ab9b002016-02-01 15:06:13 -0500199 - name: Copy cord.yaml bundle
Andy Bavier2c108de2016-02-18 16:55:00 -0500200 template: src=templates/cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml
Andy Bavier2ab9b002016-02-01 15:06:13 -0500201
202 - name: Deploy OpenStack services with Juju
203 shell: juju quickstart cord.yaml
Andy Bavierb146f7f2016-02-12 10:03:35 -0500204
205- hosts: head
206 sudo: no
207 tasks:
208
209 - name: Get Keystone IP
210 shell: uvt-kvm ip keystone
211 register: keystone_ip
212
213 - name: Create credentials
214 template: src=templates/admin-openrc-cord.sh.j2
215 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
216
Andy Bavier2c108de2016-02-18 16:55:00 -0500217 - name: Copy credentials to /tmp
218 shell: cp -f {{ ansible_env['PWD'] }}/admin-openrc.sh /tmp
219
Andy Bavierb146f7f2016-02-12 10:03:35 -0500220 - name: Copy credentials to nova-cloud-controller
221 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
Andy Bavier2c108de2016-02-18 16:55:00 -0500222
223- hosts: head
224 sudo: no
225 tasks:
226
227 - name: Copy over VM setup files
228 copy: src=files/tmp/{{ item }}
229 dest=/tmp
230 with_items:
231 - set-up-xos.yml
232 - set-up-onos.yml
233
234 - name: Copy over ONOS docker-compose.yml
235 copy: src=files/onos/docker-compose.yml
236 dest=/tmp
237
238 - name: Set up xos VM
239 shell: ansible-playbook /tmp/set-up-xos.yml
240
241 - name: Set up onos-cord VM
242 shell: ansible-playbook /tmp/set-up-onos.yml