Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 1 | --- |
| 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 Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 18 | - name: Update apt cache |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 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 | |
ubuntu | 96a1203 | 2016-03-05 17:47:46 -0800 | [diff] [blame] | 35 | # 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 Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 41 | - 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 Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 66 | - 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 | |
ubuntu | 96a1203 | 2016-03-05 17:47:46 -0800 | [diff] [blame] | 72 | - 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 Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 79 | |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 80 | - 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 |
ubuntu | 96a1203 | 2016-03-05 17:47:46 -0800 | [diff] [blame] | 83 | when: is_cloudlab |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 84 | |
| 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 Bavier | 144f112 | 2016-02-23 11:48:16 -0500 | [diff] [blame] | 97 | |
| 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 Bavier | de2c03f | 2016-03-01 13:14:07 -0500 | [diff] [blame] | 105 | - 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 Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 115 | - name: Create VMs to host OpenCloud services on mgmtbr |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 116 | sudo: no |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 117 | script: scripts/create-vms-cord.sh |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 118 | when: test_setup is not defined |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 119 | |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 120 | - 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 Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 125 | - name: Set up /etc/ansible/hosts |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 126 | template: src=templates/etc/ansible/cord-hosts.j2 |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 127 | 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 Bavier | de2c03f | 2016-03-01 13:14:07 -0500 | [diff] [blame] | 138 | - name: Test that we can log into every VM using Ansible |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 139 | sudo: no |
| 140 | shell: ansible services -m ping -u ubuntu |
| 141 | |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 142 | # Play: prepare compute nodes for installation |
| 143 | - hosts: compute |
| 144 | sudo: yes |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 145 | tasks: |
| 146 | - name: Install package needed by Juju |
| 147 | apt: name=python-yaml state=present |
| 148 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 149 | - name: Add key for standard user |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 150 | authorized_key: user="{{ ansible_env['SUDO_USER'] }}" |
| 151 | key="{{ hostvars['head']['sshkey']['stdout'] }}" |
| 152 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 153 | - name: Add key for root |
| 154 | authorized_key: user="root" |
| 155 | key="{{ hostvars['head']['sshkey']['stdout'] }}" |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 156 | |
ubuntu | 96a1203 | 2016-03-05 17:47:46 -0800 | [diff] [blame] | 157 | - 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 Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 164 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 165 | - name: Make sure that /var/lib/nova exists |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 166 | file: path=/var/lib/nova state=directory |
ubuntu | 96a1203 | 2016-03-05 17:47:46 -0800 | [diff] [blame] | 167 | when: is_cloudlab |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 168 | |
| 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 |
ubuntu | 96a1203 | 2016-03-05 17:47:46 -0800 | [diff] [blame] | 172 | when: is_cloudlab |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 173 | |
| 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 Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 184 | - 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 Bavier | 144f112 | 2016-02-23 11:48:16 -0500 | [diff] [blame] | 194 | - name: Check that 'juju status' works |
| 195 | sudo: no |
Andy Bavier | 8cd85a2 | 2016-02-24 16:00:54 -0500 | [diff] [blame] | 196 | shell: juju status |
| 197 | |
| 198 | - name: Pause for 15 seconds (problem with mysql VM not being added to Juju) |
| 199 | pause: seconds=15 |
Andy Bavier | 144f112 | 2016-02-23 11:48:16 -0500 | [diff] [blame] | 200 | |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 201 | - name: Add virtual machines to Juju's control |
Andy Bavier | 144f112 | 2016-02-23 11:48:16 -0500 | [diff] [blame] | 202 | shell: juju add-machine ssh:{{ item }} |
| 203 | with_items: "{{ groups['openstack'] }}" |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 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 |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 210 | template: src=templates/cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 211 | |
David Bainbridge | e7f20e2 | 2016-05-01 19:51:43 -0400 | [diff] [blame] | 212 | - name: Update root certificate database |
| 213 | sudo: yes |
| 214 | command: update-ca-certificates |
| 215 | |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 216 | - name: Deploy OpenStack services with Juju |
David Bainbridge | e7f20e2 | 2016-05-01 19:51:43 -0400 | [diff] [blame] | 217 | shell: juju quickstart --no-browser cord.yaml |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 218 | |
| 219 | - hosts: head |
| 220 | sudo: no |
| 221 | tasks: |
| 222 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 223 | - name: Create credentials |
| 224 | template: src=templates/admin-openrc-cord.sh.j2 |
| 225 | dest={{ ansible_env['PWD'] }}/admin-openrc.sh |
| 226 | |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 227 | - name: Copy credentials to /tmp |
| 228 | shell: cp -f {{ ansible_env['PWD'] }}/admin-openrc.sh /tmp |
| 229 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 230 | - name: Copy credentials to nova-cloud-controller |
| 231 | shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:" |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 232 | |
| 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 |