blob: 994fc41b371de63f28eabdd49f682012d40bfb0a [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
ubuntu96a12032016-03-05 17:47:46 -080035 # On some systems ansible complains that the "/usr/share/ansible/source_control/git directory
36 # does not exist when there is an attempt to get juju-ansible. To work around this issue
37 # we precreate the directory
38 - name: Work Around - source_control directory creation
39 file: path="/usr/share/ansible/source_control/git" state=directory
40
Andy Bavier2ab9b002016-02-01 15:06:13 -050041 - name: Get juju-ansible git repo
42 git: repo=https://github.com/cmars/juju-ansible.git
43 dest=/usr/local/src/juju-ansible
44
45 - name: Set up juju-ansible symlink
46 file: dest=/usr/local/bin/juju-ansible
47 src=/usr/local/src/juju-ansible/juju-ansible
48 state=link
49
50 - name: Set up juju-ansible-playbook symlink
51 file: dest=/usr/local/bin/juju-ansible-playbook
52 src=/usr/local/src/juju-ansible/juju-ansible
53 state=link
54
55 - name: Generate key to use in VMs
56 user: name={{ ansible_env['SUDO_USER'] }} generate_ssh_key=yes
57
58 - name: Get public key
59 shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub
60 register: sshkey
61
62 - name: Add key
63 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
64 key="{{ sshkey.stdout }}"
65
Andy Bavier2c108de2016-02-18 16:55:00 -050066 - name: Copy keypair to /tmp
67 shell: cp -f {{ ansible_env['PWD'] }}/.ssh/{{ item }} /tmp; chmod +r /tmp/{{ item }}
68 with_items:
69 - id_rsa
70 - id_rsa.pub
71
ubuntu96a12032016-03-05 17:47:46 -080072 - name: Stat mkextrafs
73 stat: path="/usr/testbed/bin/mkextrafs"
74 register: is_mkextrafs
75
76 - name: Check whether we're on Cloudlab
77 set_fact:
78 is_cloudlab : "{{ is_mkextrafs.stat.exists }}"
Andy Bavier2c108de2016-02-18 16:55:00 -050079
Andy Bavier2ab9b002016-02-01 15:06:13 -050080 - name: (CloudLab) Set up extra disk space
81 shell: /usr/testbed/bin/mkextrafs -f /var/lib/uvtool/libvirt/images
82 creates=/var/lib/uvtool/libvirt/images/lost+found
ubuntu96a12032016-03-05 17:47:46 -080083 when: is_cloudlab
Andy Bavier2ab9b002016-02-01 15:06:13 -050084
85 - name: Add myself to libvirtd group
86 user: name={{ ansible_env['SUDO_USER'] }}
87 groups=libvirtd
88 append=yes
89
90 - name: Get trusty image for uvtool
91 shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64
92
93# Play: create VMs to host OpenStack services
94- hosts: head
95 sudo: yes
96 tasks:
Andy Bavier144f1122016-02-23 11:48:16 -050097
98 # Yes I know
99 - name: Add local resolver to /etc/resolv.conf
100 lineinfile: dest=/etc/resolv.conf
101 insertafter=".*DO NOT EDIT THIS FILE.*"
102 line="nameserver 192.168.122.1"
103 when: test_setup is defined
104
Andy Bavierde2c03f2016-03-01 13:14:07 -0500105 - name: Touch .ssh/config
106 sudo: no
107 file: path={{ ansible_env['PWD'] }}/.ssh/config
108 state=touch
109
110 - name: Disable host key checking in SSH
111 sudo: no
112 lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config
113 line="StrictHostKeyChecking no"
114
Andy Bavier2c108de2016-02-18 16:55:00 -0500115 - name: Create VMs to host OpenCloud services on mgmtbr
Andy Bavier2ab9b002016-02-01 15:06:13 -0500116 sudo: no
Andy Bavierb146f7f2016-02-12 10:03:35 -0500117 script: scripts/create-vms-cord.sh
Andy Bavier2c108de2016-02-18 16:55:00 -0500118 when: test_setup is not defined
Andy Bavier2ab9b002016-02-01 15:06:13 -0500119
Andy Bavier2c108de2016-02-18 16:55:00 -0500120 - name: Create VMs to host OpenCloud services on virbr0
121 sudo: no
122 script: scripts/create-vms-cord.sh --testing
123 when: test_setup is defined
124
Andy Bavier2ab9b002016-02-01 15:06:13 -0500125 - name: Set up /etc/ansible/hosts
Andy Bavier2c108de2016-02-18 16:55:00 -0500126 template: src=templates/etc/ansible/cord-hosts.j2
Andy Bavier2ab9b002016-02-01 15:06:13 -0500127 dest=/etc/ansible/hosts
128
129 - name: Copy ansible.cfg to disable host key checking
130 sudo: no
131 copy: src=files/ansible.cfg
132 dest={{ ansible_env['PWD'] }}/.ansible.cfg
133
134 - name: Touch ~/.ssh/config
135 sudo: no
136 file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch
137
Andy Bavierde2c03f2016-03-01 13:14:07 -0500138 - name: Test that we can log into every VM using Ansible
Andy Bavier2ab9b002016-02-01 15:06:13 -0500139 sudo: no
140 shell: ansible services -m ping -u ubuntu
141
Andy Bavier2ab9b002016-02-01 15:06:13 -0500142# Play: prepare compute nodes for installation
143- hosts: compute
144 sudo: yes
Andy Bavier2ab9b002016-02-01 15:06:13 -0500145 tasks:
146 - name: Install package needed by Juju
147 apt: name=python-yaml state=present
148
Andy Bavierb146f7f2016-02-12 10:03:35 -0500149 - name: Add key for standard user
Andy Bavier2ab9b002016-02-01 15:06:13 -0500150 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
151 key="{{ hostvars['head']['sshkey']['stdout'] }}"
152
Andy Bavierb146f7f2016-02-12 10:03:35 -0500153 - name: Add key for root
154 authorized_key: user="root"
155 key="{{ hostvars['head']['sshkey']['stdout'] }}"
Andy Bavier2ab9b002016-02-01 15:06:13 -0500156
ubuntu96a12032016-03-05 17:47:46 -0800157 - name: Stat mkextrafs
158 stat: path="/usr/testbed/bin/mkextrafs"
159 register: is_mkextrafs
160
161 - name: Check whether we're on Cloudlab
162 set_fact:
163 is_cloudlab : "{{ is_mkextrafs.stat.exists }}"
Andy Bavier2c108de2016-02-18 16:55:00 -0500164
Andy Bavierb146f7f2016-02-12 10:03:35 -0500165 - name: Make sure that /var/lib/nova exists
Andy Bavier2ab9b002016-02-01 15:06:13 -0500166 file: path=/var/lib/nova state=directory
ubuntu96a12032016-03-05 17:47:46 -0800167 when: is_cloudlab
Andy Bavier2ab9b002016-02-01 15:06:13 -0500168
169 - name: (CloudLab) Set up extra disk space
170 shell: /usr/testbed/bin/mkextrafs -f /var/lib/nova
171 creates=/var/lib/nova/lost+found
ubuntu96a12032016-03-05 17:47:46 -0800172 when: is_cloudlab
Andy Bavier2ab9b002016-02-01 15:06:13 -0500173
174# Play: Install services using Juju
175- hosts: head
176 vars:
177 charm_src: /usr/local/src/charms/trusty
178 tasks:
179 - name: Initialize Juju
180 sudo: no
181 shell: juju generate-config
182 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
183
Andy Bavier2ab9b002016-02-01 15:06:13 -0500184 - name: Juju config file
185 sudo: no
186 template: src=templates/environments.yaml.j2
187 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
188
189 - name: Bootstrap Juju
190 sudo: no
191 shell: juju bootstrap
192 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
193
Andy Bavier144f1122016-02-23 11:48:16 -0500194 - name: Check that 'juju status' works
195 sudo: no
Andy Bavier8cd85a22016-02-24 16:00:54 -0500196 shell: juju status
197
198 - name: Pause for 15 seconds (problem with mysql VM not being added to Juju)
199 pause: seconds=15
Andy Bavier144f1122016-02-23 11:48:16 -0500200
Andy Bavier2ab9b002016-02-01 15:06:13 -0500201 - name: Add virtual machines to Juju's control
Andy Bavier144f1122016-02-23 11:48:16 -0500202 shell: juju add-machine ssh:{{ item }}
203 with_items: "{{ groups['openstack'] }}"
Andy Bavier2ab9b002016-02-01 15:06:13 -0500204
205 - name: Add compute nodes to Juju's control
206 shell: juju add-machine ssh:{{ item }}
207 with_items: "{{ groups['compute'] }}"
208
209 - name: Copy cord.yaml bundle
Andy Bavier2c108de2016-02-18 16:55:00 -0500210 template: src=templates/cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml
Andy Bavier2ab9b002016-02-01 15:06:13 -0500211
David Bainbridgee7f20e22016-05-01 19:51:43 -0400212 - name: Update root certificate database
213 sudo: yes
214 command: update-ca-certificates
215
Andy Bavier2ab9b002016-02-01 15:06:13 -0500216 - name: Deploy OpenStack services with Juju
David Bainbridgee7f20e22016-05-01 19:51:43 -0400217 shell: juju quickstart --no-browser cord.yaml
Andy Bavierb146f7f2016-02-12 10:03:35 -0500218
219- hosts: head
220 sudo: no
221 tasks:
222
Andy Bavierb146f7f2016-02-12 10:03:35 -0500223 - name: Create credentials
224 template: src=templates/admin-openrc-cord.sh.j2
225 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
226
Andy Bavier2c108de2016-02-18 16:55:00 -0500227 - name: Copy credentials to /tmp
228 shell: cp -f {{ ansible_env['PWD'] }}/admin-openrc.sh /tmp
229
Andy Bavierb146f7f2016-02-12 10:03:35 -0500230 - name: Copy credentials to nova-cloud-controller
231 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
Andy Bavier2c108de2016-02-18 16:55:00 -0500232
233- hosts: head
234 sudo: no
235 tasks:
236
237 - name: Copy over VM setup files
238 copy: src=files/tmp/{{ item }}
239 dest=/tmp
240 with_items:
241 - set-up-xos.yml
242 - set-up-onos.yml
243
244 - name: Copy over ONOS docker-compose.yml
245 copy: src=files/onos/docker-compose.yml
246 dest=/tmp
247
248 - name: Set up xos VM
249 shell: ansible-playbook /tmp/set-up-xos.yml
250
251 - name: Set up onos-cord VM
252 shell: ansible-playbook /tmp/set-up-onos.yml