blob: 6d83063c1efd9722aa43b4cc2456086f8fa5f958 [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 Bavierde2c03f2016-03-01 13:14:07 -050096 - name: Touch .ssh/config
97 sudo: no
98 file: path={{ ansible_env['PWD'] }}/.ssh/config
99 state=touch
100
101 - name: Disable host key checking in SSH
102 sudo: no
103 lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config
104 line="StrictHostKeyChecking no"
105
Andy Bavier2c108de2016-02-18 16:55:00 -0500106 - name: Create VMs to host OpenCloud services on mgmtbr
Andy Bavier2ab9b002016-02-01 15:06:13 -0500107 sudo: no
Andy Bavierb146f7f2016-02-12 10:03:35 -0500108 script: scripts/create-vms-cord.sh
Andy Bavier2c108de2016-02-18 16:55:00 -0500109 when: test_setup is not defined
Andy Bavier2ab9b002016-02-01 15:06:13 -0500110
Andy Bavier2c108de2016-02-18 16:55:00 -0500111 - name: Create VMs to host OpenCloud services on virbr0
112 sudo: no
113 script: scripts/create-vms-cord.sh --testing
114 when: test_setup is defined
115
Andy Bavier2ab9b002016-02-01 15:06:13 -0500116 - name: Set up /etc/ansible/hosts
Andy Bavier2c108de2016-02-18 16:55:00 -0500117 template: src=templates/etc/ansible/cord-hosts.j2
Andy Bavier2ab9b002016-02-01 15:06:13 -0500118 dest=/etc/ansible/hosts
119
120 - name: Copy ansible.cfg to disable host key checking
121 sudo: no
122 copy: src=files/ansible.cfg
123 dest={{ ansible_env['PWD'] }}/.ansible.cfg
124
125 - name: Touch ~/.ssh/config
126 sudo: no
127 file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch
128
Andy Bavierde2c03f2016-03-01 13:14:07 -0500129 - name: Test that we can log into every VM using Ansible
Andy Bavier2ab9b002016-02-01 15:06:13 -0500130 sudo: no
131 shell: ansible services -m ping -u ubuntu
132
Andy Bavier2ab9b002016-02-01 15:06:13 -0500133# Play: prepare compute nodes for installation
134- hosts: compute
135 sudo: yes
Andy Bavier2ab9b002016-02-01 15:06:13 -0500136 tasks:
137 - name: Install package needed by Juju
138 apt: name=python-yaml state=present
139
Andy Bavierb146f7f2016-02-12 10:03:35 -0500140 - name: Add key for standard user
Andy Bavier2ab9b002016-02-01 15:06:13 -0500141 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
142 key="{{ hostvars['head']['sshkey']['stdout'] }}"
143
Andy Bavierb146f7f2016-02-12 10:03:35 -0500144 - name: Add key for root
145 authorized_key: user="root"
146 key="{{ hostvars['head']['sshkey']['stdout'] }}"
Andy Bavier2ab9b002016-02-01 15:06:13 -0500147
Andy Bavier2c108de2016-02-18 16:55:00 -0500148 - name: Check whether we're on CloudLab
149 shell: ls /usr/testbed/bin/mkextrafs
150 ignore_errors: true
151 register: is_cloudlab
152
Andy Bavierb146f7f2016-02-12 10:03:35 -0500153 - name: Make sure that /var/lib/nova exists
Andy Bavier2ab9b002016-02-01 15:06:13 -0500154 file: path=/var/lib/nova state=directory
Andy Bavier2c108de2016-02-18 16:55:00 -0500155 when: is_cloudlab | success
Andy Bavier2ab9b002016-02-01 15:06:13 -0500156
157 - name: (CloudLab) Set up extra disk space
158 shell: /usr/testbed/bin/mkextrafs -f /var/lib/nova
159 creates=/var/lib/nova/lost+found
Andy Bavier2c108de2016-02-18 16:55:00 -0500160 when: is_cloudlab | success
Andy Bavier2ab9b002016-02-01 15:06:13 -0500161
162# Play: Install services using Juju
163- hosts: head
164 vars:
165 charm_src: /usr/local/src/charms/trusty
166 tasks:
167 - name: Initialize Juju
168 sudo: no
169 shell: juju generate-config
170 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
171
Andy Bavier2ab9b002016-02-01 15:06:13 -0500172 - name: Juju config file
173 sudo: no
174 template: src=templates/environments.yaml.j2
175 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
176
177 - name: Bootstrap Juju
178 sudo: no
179 shell: juju bootstrap
180 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
181
Andy Bavier144f1122016-02-23 11:48:16 -0500182 - name: Check that 'juju status' works
183 sudo: no
Andy Bavier8cd85a22016-02-24 16:00:54 -0500184 shell: juju status
185
186 - name: Pause for 15 seconds (problem with mysql VM not being added to Juju)
187 pause: seconds=15
Andy Bavier144f1122016-02-23 11:48:16 -0500188
Andy Bavier2ab9b002016-02-01 15:06:13 -0500189 - name: Add virtual machines to Juju's control
Andy Bavier144f1122016-02-23 11:48:16 -0500190 shell: juju add-machine ssh:{{ item }}
191 with_items: "{{ groups['openstack'] }}"
Andy Bavier2ab9b002016-02-01 15:06:13 -0500192
193 - name: Add compute nodes to Juju's control
194 shell: juju add-machine ssh:{{ item }}
195 with_items: "{{ groups['compute'] }}"
196
197 - name: Copy cord.yaml bundle
Andy Bavier2c108de2016-02-18 16:55:00 -0500198 template: src=templates/cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml
Andy Bavier2ab9b002016-02-01 15:06:13 -0500199
200 - name: Deploy OpenStack services with Juju
201 shell: juju quickstart cord.yaml
Andy Bavierb146f7f2016-02-12 10:03:35 -0500202
203- hosts: head
204 sudo: no
205 tasks:
206
Andy Bavierb146f7f2016-02-12 10:03:35 -0500207 - name: Create credentials
208 template: src=templates/admin-openrc-cord.sh.j2
209 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
210
Andy Bavier2c108de2016-02-18 16:55:00 -0500211 - name: Copy credentials to /tmp
212 shell: cp -f {{ ansible_env['PWD'] }}/admin-openrc.sh /tmp
213
Andy Bavierb146f7f2016-02-12 10:03:35 -0500214 - name: Copy credentials to nova-cloud-controller
215 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"
Andy Bavier2c108de2016-02-18 16:55:00 -0500216
217- hosts: head
218 sudo: no
219 tasks:
220
221 - name: Copy over VM setup files
222 copy: src=files/tmp/{{ item }}
223 dest=/tmp
224 with_items:
225 - set-up-xos.yml
226 - set-up-onos.yml
227
228 - name: Copy over ONOS docker-compose.yml
229 copy: src=files/onos/docker-compose.yml
230 dest=/tmp
231
232 - name: Set up xos VM
233 shell: ansible-playbook /tmp/set-up-xos.yml
234
235 - name: Set up onos-cord VM
236 shell: ansible-playbook /tmp/set-up-onos.yml