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 | |
| 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 Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 60 | - 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 Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 71 | - 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 Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 74 | when: is_cloudlab | success |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 75 | |
| 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 Bavier | 144f112 | 2016-02-23 11:48:16 -0500 | [diff] [blame] | 88 | |
| 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 Bavier | de2c03f | 2016-03-01 13:14:07 -0500 | [diff] [blame] | 96 | - 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 Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 106 | - name: Create VMs to host OpenCloud services on mgmtbr |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 107 | sudo: no |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 108 | script: scripts/create-vms-cord.sh |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 109 | when: test_setup is not defined |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 110 | |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 111 | - 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 Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 116 | - name: Set up /etc/ansible/hosts |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 117 | template: src=templates/etc/ansible/cord-hosts.j2 |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 118 | 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 Bavier | de2c03f | 2016-03-01 13:14:07 -0500 | [diff] [blame] | 129 | - name: Test that we can log into every VM using Ansible |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 130 | sudo: no |
| 131 | shell: ansible services -m ping -u ubuntu |
| 132 | |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 133 | # Play: prepare compute nodes for installation |
| 134 | - hosts: compute |
| 135 | sudo: yes |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 136 | tasks: |
| 137 | - name: Install package needed by Juju |
| 138 | apt: name=python-yaml state=present |
| 139 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 140 | - name: Add key for standard user |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 141 | authorized_key: user="{{ ansible_env['SUDO_USER'] }}" |
| 142 | key="{{ hostvars['head']['sshkey']['stdout'] }}" |
| 143 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 144 | - name: Add key for root |
| 145 | authorized_key: user="root" |
| 146 | key="{{ hostvars['head']['sshkey']['stdout'] }}" |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 147 | |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 148 | - name: Check whether we're on CloudLab |
| 149 | shell: ls /usr/testbed/bin/mkextrafs |
| 150 | ignore_errors: true |
| 151 | register: is_cloudlab |
| 152 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 153 | - name: Make sure that /var/lib/nova exists |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 154 | file: path=/var/lib/nova state=directory |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 155 | when: is_cloudlab | success |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 156 | |
| 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 Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 160 | when: is_cloudlab | success |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 161 | |
| 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 Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 172 | - 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 Bavier | 144f112 | 2016-02-23 11:48:16 -0500 | [diff] [blame] | 182 | - name: Check that 'juju status' works |
| 183 | sudo: no |
Andy Bavier | 8cd85a2 | 2016-02-24 16:00:54 -0500 | [diff] [blame] | 184 | shell: juju status |
| 185 | |
| 186 | - name: Pause for 15 seconds (problem with mysql VM not being added to Juju) |
| 187 | pause: seconds=15 |
Andy Bavier | 144f112 | 2016-02-23 11:48:16 -0500 | [diff] [blame] | 188 | |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 189 | - name: Add virtual machines to Juju's control |
Andy Bavier | 144f112 | 2016-02-23 11:48:16 -0500 | [diff] [blame] | 190 | shell: juju add-machine ssh:{{ item }} |
| 191 | with_items: "{{ groups['openstack'] }}" |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 192 | |
| 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 Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 198 | template: src=templates/cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 199 | |
| 200 | - name: Deploy OpenStack services with Juju |
| 201 | shell: juju quickstart cord.yaml |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 202 | |
| 203 | - hosts: head |
| 204 | sudo: no |
| 205 | tasks: |
| 206 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 207 | - name: Create credentials |
| 208 | template: src=templates/admin-openrc-cord.sh.j2 |
| 209 | dest={{ ansible_env['PWD'] }}/admin-openrc.sh |
| 210 | |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 211 | - name: Copy credentials to /tmp |
| 212 | shell: cp -f {{ ansible_env['PWD'] }}/admin-openrc.sh /tmp |
| 213 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 214 | - name: Copy credentials to nova-cloud-controller |
| 215 | shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:" |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 216 | |
| 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 |