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 | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 96 | - name: Create VMs to host OpenCloud services on mgmtbr |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 97 | sudo: no |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 98 | script: scripts/create-vms-cord.sh |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 99 | when: test_setup is not defined |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 100 | |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 101 | - name: Create VMs to host OpenCloud services on virbr0 |
| 102 | sudo: no |
| 103 | script: scripts/create-vms-cord.sh --testing |
| 104 | when: test_setup is defined |
| 105 | |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 106 | - name: Set up /etc/ansible/hosts |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 107 | template: src=templates/etc/ansible/cord-hosts.j2 |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 108 | dest=/etc/ansible/hosts |
| 109 | |
| 110 | - name: Copy ansible.cfg to disable host key checking |
| 111 | sudo: no |
| 112 | copy: src=files/ansible.cfg |
| 113 | dest={{ ansible_env['PWD'] }}/.ansible.cfg |
| 114 | |
| 115 | - name: Touch ~/.ssh/config |
| 116 | sudo: no |
| 117 | file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch |
| 118 | |
| 119 | - name: Disable host key checking in SSH |
| 120 | sudo: no |
| 121 | lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config |
| 122 | line="StrictHostKeyChecking no" |
| 123 | |
| 124 | - name: Test that we can log into every VM |
| 125 | sudo: no |
| 126 | shell: ansible services -m ping -u ubuntu |
| 127 | |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 128 | # Play: prepare compute nodes for installation |
| 129 | - hosts: compute |
| 130 | sudo: yes |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 131 | tasks: |
| 132 | - name: Install package needed by Juju |
| 133 | apt: name=python-yaml state=present |
| 134 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 135 | - name: Add key for standard user |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 136 | authorized_key: user="{{ ansible_env['SUDO_USER'] }}" |
| 137 | key="{{ hostvars['head']['sshkey']['stdout'] }}" |
| 138 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 139 | - name: Add key for root |
| 140 | authorized_key: user="root" |
| 141 | key="{{ hostvars['head']['sshkey']['stdout'] }}" |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 142 | |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 143 | - name: Check whether we're on CloudLab |
| 144 | shell: ls /usr/testbed/bin/mkextrafs |
| 145 | ignore_errors: true |
| 146 | register: is_cloudlab |
| 147 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 148 | - name: Make sure that /var/lib/nova exists |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 149 | file: path=/var/lib/nova state=directory |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 150 | when: is_cloudlab | success |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 151 | |
| 152 | - name: (CloudLab) Set up extra disk space |
| 153 | shell: /usr/testbed/bin/mkextrafs -f /var/lib/nova |
| 154 | creates=/var/lib/nova/lost+found |
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 | # Play: Install services using Juju |
| 158 | - hosts: head |
| 159 | vars: |
| 160 | charm_src: /usr/local/src/charms/trusty |
| 161 | tasks: |
| 162 | - name: Initialize Juju |
| 163 | sudo: no |
| 164 | shell: juju generate-config |
| 165 | creates={{ ansible_env['PWD'] }}/.juju/environments.yaml |
| 166 | |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 167 | - name: Juju config file |
| 168 | sudo: no |
| 169 | template: src=templates/environments.yaml.j2 |
| 170 | dest={{ ansible_env['PWD'] }}/.juju/environments.yaml |
| 171 | |
| 172 | - name: Bootstrap Juju |
| 173 | sudo: no |
| 174 | shell: juju bootstrap |
| 175 | creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv |
| 176 | |
Andy Bavier | 144f112 | 2016-02-23 11:48:16 -0500 | [diff] [blame] | 177 | - name: Check that 'juju status' works |
| 178 | sudo: no |
| 179 | shell: juju status |
| 180 | |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 181 | - name: Add virtual machines to Juju's control |
Andy Bavier | 144f112 | 2016-02-23 11:48:16 -0500 | [diff] [blame] | 182 | shell: juju add-machine ssh:{{ item }} |
| 183 | with_items: "{{ groups['openstack'] }}" |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 184 | |
| 185 | - name: Add compute nodes to Juju's control |
| 186 | shell: juju add-machine ssh:{{ item }} |
| 187 | with_items: "{{ groups['compute'] }}" |
| 188 | |
| 189 | - name: Copy cord.yaml bundle |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 190 | template: src=templates/cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml |
Andy Bavier | 2ab9b00 | 2016-02-01 15:06:13 -0500 | [diff] [blame] | 191 | |
| 192 | - name: Deploy OpenStack services with Juju |
| 193 | shell: juju quickstart cord.yaml |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 194 | |
| 195 | - hosts: head |
| 196 | sudo: no |
| 197 | tasks: |
| 198 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 199 | - name: Create credentials |
| 200 | template: src=templates/admin-openrc-cord.sh.j2 |
| 201 | dest={{ ansible_env['PWD'] }}/admin-openrc.sh |
| 202 | |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 203 | - name: Copy credentials to /tmp |
| 204 | shell: cp -f {{ ansible_env['PWD'] }}/admin-openrc.sh /tmp |
| 205 | |
Andy Bavier | b146f7f | 2016-02-12 10:03:35 -0500 | [diff] [blame] | 206 | - name: Copy credentials to nova-cloud-controller |
| 207 | shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:" |
Andy Bavier | 2c108de | 2016-02-18 16:55:00 -0500 | [diff] [blame] | 208 | |
| 209 | - hosts: head |
| 210 | sudo: no |
| 211 | tasks: |
| 212 | |
| 213 | - name: Copy over VM setup files |
| 214 | copy: src=files/tmp/{{ item }} |
| 215 | dest=/tmp |
| 216 | with_items: |
| 217 | - set-up-xos.yml |
| 218 | - set-up-onos.yml |
| 219 | |
| 220 | - name: Copy over ONOS docker-compose.yml |
| 221 | copy: src=files/onos/docker-compose.yml |
| 222 | dest=/tmp |
| 223 | |
| 224 | - name: Set up xos VM |
| 225 | shell: ansible-playbook /tmp/set-up-xos.yml |
| 226 | |
| 227 | - name: Set up onos-cord VM |
| 228 | shell: ansible-playbook /tmp/set-up-onos.yml |