blob: 6182ce149cf303608f0a0582cd44fecaaa909a9a [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 Bavier144f1122016-02-23 11:48:16 -050088
89 # Yes I know
90 - name: Add local resolver to /etc/resolv.conf
91 lineinfile: dest=/etc/resolv.conf
92 insertafter=".*DO NOT EDIT THIS FILE.*"
93 line="nameserver 192.168.122.1"
94 when: test_setup is defined
95
Andy Bavier2c108de2016-02-18 16:55:00 -050096 - name: Create VMs to host OpenCloud services on mgmtbr
Andy Bavier2ab9b002016-02-01 15:06:13 -050097 sudo: no
Andy Bavierb146f7f2016-02-12 10:03:35 -050098 script: scripts/create-vms-cord.sh
Andy Bavier2c108de2016-02-18 16:55:00 -050099 when: test_setup is not defined
Andy Bavier2ab9b002016-02-01 15:06:13 -0500100
Andy Bavier2c108de2016-02-18 16:55:00 -0500101 - name: Create VMs to host OpenCloud services on virbr0
102 sudo: no
103 script: scripts/create-vms-cord.sh --testing
104 when: test_setup is defined
105
Andy Bavier2ab9b002016-02-01 15:06:13 -0500106 - 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
Andy Bavier2ab9b002016-02-01 15:06:13 -0500128# Play: prepare compute nodes for installation
129- hosts: compute
130 sudo: yes
Andy Bavier2ab9b002016-02-01 15:06:13 -0500131 tasks:
132 - name: Install package needed by Juju
133 apt: name=python-yaml state=present
134
Andy Bavierb146f7f2016-02-12 10:03:35 -0500135 - name: Add key for standard user
Andy Bavier2ab9b002016-02-01 15:06:13 -0500136 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
137 key="{{ hostvars['head']['sshkey']['stdout'] }}"
138
Andy Bavierb146f7f2016-02-12 10:03:35 -0500139 - name: Add key for root
140 authorized_key: user="root"
141 key="{{ hostvars['head']['sshkey']['stdout'] }}"
Andy Bavier2ab9b002016-02-01 15:06:13 -0500142
Andy Bavier2c108de2016-02-18 16:55:00 -0500143 - name: Check whether we're on CloudLab
144 shell: ls /usr/testbed/bin/mkextrafs
145 ignore_errors: true
146 register: is_cloudlab
147
Andy Bavierb146f7f2016-02-12 10:03:35 -0500148 - name: Make sure that /var/lib/nova exists
Andy Bavier2ab9b002016-02-01 15:06:13 -0500149 file: path=/var/lib/nova state=directory
Andy Bavier2c108de2016-02-18 16:55:00 -0500150 when: is_cloudlab | success
Andy Bavier2ab9b002016-02-01 15:06:13 -0500151
152 - name: (CloudLab) Set up extra disk space
153 shell: /usr/testbed/bin/mkextrafs -f /var/lib/nova
154 creates=/var/lib/nova/lost+found
Andy Bavier2c108de2016-02-18 16:55:00 -0500155 when: is_cloudlab | success
Andy Bavier2ab9b002016-02-01 15:06:13 -0500156
157# Play: Install services using Juju
158- hosts: head
159 vars:
160 charm_src: /usr/local/src/charms/trusty
161 tasks:
162 - name: Initialize Juju
163 sudo: no
164 shell: juju generate-config
165 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
166
Andy Bavier2ab9b002016-02-01 15:06:13 -0500167 - name: Juju config file
168 sudo: no
169 template: src=templates/environments.yaml.j2
170 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
171
172 - name: Bootstrap Juju
173 sudo: no
174 shell: juju bootstrap
175 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
176
Andy Bavier144f1122016-02-23 11:48:16 -0500177 - name: Check that 'juju status' works
178 sudo: no
Andy Bavier8cd85a22016-02-24 16:00:54 -0500179 shell: juju status
180
181 - name: Pause for 15 seconds (problem with mysql VM not being added to Juju)
182 pause: seconds=15
Andy Bavier144f1122016-02-23 11:48:16 -0500183
Andy Bavier2ab9b002016-02-01 15:06:13 -0500184 - name: Add virtual machines to Juju's control
Andy Bavier144f1122016-02-23 11:48:16 -0500185 shell: juju add-machine ssh:{{ item }}
186 with_items: "{{ groups['openstack'] }}"
Andy Bavier2ab9b002016-02-01 15:06:13 -0500187
188 - name: Add compute nodes to Juju's control
189 shell: juju add-machine ssh:{{ item }}
190 with_items: "{{ groups['compute'] }}"
191
192 - name: Copy cord.yaml bundle
Andy Bavier2c108de2016-02-18 16:55:00 -0500193 template: src=templates/cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml
Andy Bavier2ab9b002016-02-01 15:06:13 -0500194
195 - name: Deploy OpenStack services with Juju
196 shell: juju quickstart cord.yaml
Andy Bavierb146f7f2016-02-12 10:03:35 -0500197
198- hosts: head
199 sudo: no
200 tasks:
201
Andy Bavierb146f7f2016-02-12 10:03:35 -0500202 - name: Create credentials
203 template: src=templates/admin-openrc-cord.sh.j2
204 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
205
Andy Bavier2c108de2016-02-18 16:55:00 -0500206 - name: Copy credentials to /tmp
207 shell: cp -f {{ ansible_env['PWD'] }}/admin-openrc.sh /tmp
208
Andy Bavierb146f7f2016-02-12 10:03:35 -0500209 - name: Copy credentials to nova-cloud-controller
210 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
Andy Bavier2c108de2016-02-18 16:55:00 -0500211
212- hosts: head
213 sudo: no
214 tasks:
215
216 - name: Copy over VM setup files
217 copy: src=files/tmp/{{ item }}
218 dest=/tmp
219 with_items:
220 - set-up-xos.yml
221 - set-up-onos.yml
222
223 - name: Copy over ONOS docker-compose.yml
224 copy: src=files/onos/docker-compose.yml
225 dest=/tmp
226
227 - name: Set up xos VM
228 shell: ansible-playbook /tmp/set-up-xos.yml
229
230 - name: Set up onos-cord VM
231 shell: ansible-playbook /tmp/set-up-onos.yml