blob: 80e5a53920039357a5645177c480bb3b85fb40b1 [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
18 - name: Update Ansible cache
19 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
60 - name: (CloudLab) Set up extra disk space
61 shell: /usr/testbed/bin/mkextrafs -f /var/lib/uvtool/libvirt/images
62 creates=/var/lib/uvtool/libvirt/images/lost+found
63 when: cloudlab
64
65 - name: Add myself to libvirtd group
66 user: name={{ ansible_env['SUDO_USER'] }}
67 groups=libvirtd
68 append=yes
69
70 - name: Get trusty image for uvtool
71 shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64
72
73# Play: create VMs to host OpenStack services
74- hosts: head
75 sudo: yes
76 tasks:
77 - name: Create VMs to host OpenCloud services
78 sudo: no
79 script: scripts/create-vms.sh
80
81 - include: tasks/vm-ips.yml
82
83 - name: Add VMs to /etc/hosts
84 template: src=templates/etc/hosts.j2
85 dest=/etc/hosts
86 notify:
87 - Reload dnsmasq
88
89 - name: Set up /etc/ansible/hosts
90 template: src=templates/etc/ansible/hosts.j2
91 dest=/etc/ansible/hosts
92
93 - name: Copy ansible.cfg to disable host key checking
94 sudo: no
95 copy: src=files/ansible.cfg
96 dest={{ ansible_env['PWD'] }}/.ansible.cfg
97
98 - name: Touch ~/.ssh/config
99 sudo: no
100 file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch
101
102 - name: Disable host key checking in SSH
103 sudo: no
104 lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config
105 line="StrictHostKeyChecking no"
106
107 - name: Test that we can log into every VM
108 sudo: no
109 shell: ansible services -m ping -u ubuntu
110
111 handlers:
112 - name: Reload dnsmasq
113 shell: killall -HUP dnsmasq
114
115# Play: prepare compute nodes for installation
116- hosts: compute
117 sudo: yes
118 vars:
119 control_net: "{{ hostvars['head']['ansible_virbr0']['ipv4']['network'] }}/24"
120 gateway: "{{ hostvars['head']['ansible_default_ipv4']['address'] }}"
121 tasks:
122 - name: Install package needed by Juju
123 apt: name=python-yaml state=present
124
125 - name: Add key
126 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
127 key="{{ hostvars['head']['sshkey']['stdout'] }}"
128
129 - name: Add route via /etc/rc.local
130 template: src=templates/etc/rc.local.cloudlab
131 dest=/etc/rc.local
132 mode=0755
133 when: cloudlab
134 notify:
135 - run /etc/rc.local
136
137 - name: Add route via /etc/rc.local
138 template: src=templates/etc/rc.local
139 dest=/etc/rc.local
140 mode=0755
141 when: not cloudlab
142 notify:
143 - run /etc/rc.local
144
145 - name: Touch ~/.ssh/config
146 file: path=/var/lib/nova state=directory
147
148 - name: (CloudLab) Set up extra disk space
149 shell: /usr/testbed/bin/mkextrafs -f /var/lib/nova
150 creates=/var/lib/nova/lost+found
151 when: cloudlab
152
153 handlers:
154 - name: run /etc/rc.local
155 shell: /etc/rc.local
156
157# Play: Use libvirt hooks to set up iptables
158- hosts: head
159 sudo: yes
160 tasks:
161 - name: Enable port forwarding for services
162 copy: src=files/{{ item }}
163 dest={{ item }}
164 mode=0755
165 notify:
166 - reload libvirt config
167 - run qemu hook
168 with_items:
169# - /etc/libvirt/hooks/daemon
170 - /etc/libvirt/hooks/qemu
171
172 handlers:
173 - name: reload libvirt config
174 shell: killall -HUP libvirtd
175
176 - name: run qemu hook
177 shell: /etc/libvirt/hooks/qemu start start
178
179# Play: Install services using Juju
180- hosts: head
181 vars:
182 charm_src: /usr/local/src/charms/trusty
183 tasks:
184 - name: Initialize Juju
185 sudo: no
186 shell: juju generate-config
187 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
188
189 - shell: uvt-kvm ip juju
190 register: juju_ip
191
192 - name: Juju config file
193 sudo: no
194 template: src=templates/environments.yaml.j2
195 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
196
197 - name: Bootstrap Juju
198 sudo: no
199 shell: juju bootstrap
200 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
201
202 - name: Add virtual machines to Juju's control
203 script: scripts/juju-cord-setup.py
204
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
210 copy: src=cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml
211
212 - name: Deploy OpenStack services with Juju
213 shell: juju quickstart cord.yaml