blob: 5f599aebd77cb0d135f459b40e9122b30f05cc5c [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
Andy Bavierb146f7f2016-02-12 10:03:35 -050063 when: cloudlab is defined and cloudlab
Andy Bavier2ab9b002016-02-01 15:06:13 -050064
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
Andy Bavierb146f7f2016-02-12 10:03:35 -050079 script: scripts/create-vms-cord.sh
Andy Bavier2ab9b002016-02-01 15:06:13 -050080
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
Andy Bavier2ab9b002016-02-01 15:06:13 -0500118 tasks:
119 - name: Install package needed by Juju
120 apt: name=python-yaml state=present
121
Andy Bavierb146f7f2016-02-12 10:03:35 -0500122 - name: Add key for standard user
Andy Bavier2ab9b002016-02-01 15:06:13 -0500123 authorized_key: user="{{ ansible_env['SUDO_USER'] }}"
124 key="{{ hostvars['head']['sshkey']['stdout'] }}"
125
Andy Bavierb146f7f2016-02-12 10:03:35 -0500126 - name: Add key for root
127 authorized_key: user="root"
128 key="{{ hostvars['head']['sshkey']['stdout'] }}"
Andy Bavier2ab9b002016-02-01 15:06:13 -0500129
Andy Bavierb146f7f2016-02-12 10:03:35 -0500130 - name: Make sure that /var/lib/nova exists
Andy Bavier2ab9b002016-02-01 15:06:13 -0500131 file: path=/var/lib/nova state=directory
Andy Bavierb146f7f2016-02-12 10:03:35 -0500132 when: cloudlab is defined and cloudlab
Andy Bavier2ab9b002016-02-01 15:06:13 -0500133
134 - name: (CloudLab) Set up extra disk space
135 shell: /usr/testbed/bin/mkextrafs -f /var/lib/nova
136 creates=/var/lib/nova/lost+found
Andy Bavierb146f7f2016-02-12 10:03:35 -0500137 when: cloudlab is defined and cloudlab
Andy Bavier2ab9b002016-02-01 15:06:13 -0500138
139# Play: Install services using Juju
140- hosts: head
141 vars:
142 charm_src: /usr/local/src/charms/trusty
143 tasks:
144 - name: Initialize Juju
145 sudo: no
146 shell: juju generate-config
147 creates={{ ansible_env['PWD'] }}/.juju/environments.yaml
148
149 - shell: uvt-kvm ip juju
150 register: juju_ip
151
152 - name: Juju config file
153 sudo: no
154 template: src=templates/environments.yaml.j2
155 dest={{ ansible_env['PWD'] }}/.juju/environments.yaml
156
157 - name: Bootstrap Juju
158 sudo: no
159 shell: juju bootstrap
160 creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv
161
162 - name: Add virtual machines to Juju's control
163 script: scripts/juju-cord-setup.py
164
165 - name: Add compute nodes to Juju's control
166 shell: juju add-machine ssh:{{ item }}
167 with_items: "{{ groups['compute'] }}"
168
169 - name: Copy cord.yaml bundle
170 copy: src=cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml
171
172 - name: Deploy OpenStack services with Juju
173 shell: juju quickstart cord.yaml
Andy Bavierb146f7f2016-02-12 10:03:35 -0500174
175- hosts: head
176 sudo: no
177 tasks:
178
179 - name: Get Keystone IP
180 shell: uvt-kvm ip keystone
181 register: keystone_ip
182
183 - name: Create credentials
184 template: src=templates/admin-openrc-cord.sh.j2
185 dest={{ ansible_env['PWD'] }}/admin-openrc.sh
186
187 - name: Copy credentials to nova-cloud-controller
188 shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:"