Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 1 | --- |
| 2 | # Play: set up head node |
| 3 | # Assumes basic /etc/ansible/hosts file |
| 4 | - hosts: cloudlab-head |
| 5 | sudo: yes |
| 6 | tasks: |
| 7 | |
Andy Bavier | 58c8c52 | 2015-09-30 16:24:28 -0400 | [diff] [blame] | 8 | - apt: name={{ item }} update_cache=yes |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 9 | with_items: |
| 10 | - python-pycurl |
| 11 | - software-properties-common |
| 12 | |
| 13 | - name: Add Juju repository |
| 14 | apt_repository: repo="ppa:juju/stable" |
| 15 | |
| 16 | - name: Add Ansible repository |
| 17 | apt_repository: repo="ppa:ansible/ansible" |
| 18 | |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame] | 19 | - name: Update Ansible cache |
| 20 | apt: update_cache=yes |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 21 | |
| 22 | - name: Install packages |
| 23 | apt: name={{ item }} state=latest |
| 24 | with_items: |
| 25 | - ansible |
| 26 | - uvtool |
| 27 | - git |
| 28 | - bzr |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame] | 29 | - juju-core |
Andy Bavier | 8da6df1 | 2015-10-02 12:33:48 -0400 | [diff] [blame] | 30 | - python-novaclient |
| 31 | - python-neutronclient |
| 32 | - python-keystoneclient |
| 33 | - python-glanceclient |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 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 | |
Andy Bavier | a08061a | 2015-10-05 08:24:59 -0400 | [diff] [blame] | 52 | - name: (CloudLab) Set up extra disk space |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 53 | shell: /usr/testbed/bin/mkextrafs /var/lib/uvtool/libvirt/images |
| 54 | creates=/var/lib/uvtool/libvirt/images/lost+found |
| 55 | |
| 56 | - name: Add myself to libvirtd group |
Andy Bavier | b1ae26e | 2015-09-17 16:20:46 -0400 | [diff] [blame] | 57 | user: name={{ ansible_env['SUDO_USER'] }} |
| 58 | groups=libvirtd |
| 59 | append=yes |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 60 | |
| 61 | - name: Get trusty image for uvtool |
| 62 | shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64 |
| 63 | |
Andy Bavier | c1dfb88 | 2015-10-07 16:20:24 -0400 | [diff] [blame] | 64 | - name: Change the subnet of virbr0 to 192.168.100.0/24 |
| 65 | shell: sed -i 's/192.168.122/192.168.100/g' /etc/libvirt/qemu/networks/default.xml |
| 66 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 67 | - name: Create VMs to host OpenCloud services |
| 68 | sudo: no |
| 69 | script: scripts/create-vms.sh |
| 70 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 71 | - include: tasks/vm-ips.yml |
| 72 | |
| 73 | - name: Add VMs to /etc/hosts |
| 74 | template: src=templates/etc/hosts.j2 |
| 75 | dest=/etc/hosts |
| 76 | notify: |
| 77 | - Reload dnsmasq |
| 78 | |
| 79 | - name: Set up /etc/ansible/hosts |
| 80 | template: src=templates/etc/ansible/hosts.j2 |
| 81 | dest=/etc/ansible/hosts |
| 82 | |
| 83 | - name: Copy ansible.cfg to disable host key checking |
| 84 | sudo: no |
| 85 | copy: src=files/ansible.cfg |
| 86 | dest={{ ansible_env['PWD'] }}/.ansible.cfg |
| 87 | |
| 88 | - name: Touch ~/.ssh/config |
| 89 | sudo: no |
| 90 | file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch |
| 91 | |
| 92 | - name: Disable host key checking in SSH |
| 93 | sudo: no |
| 94 | lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config |
| 95 | line="StrictHostKeyChecking no" |
| 96 | |
| 97 | - name: Test that we can log into every VM |
| 98 | sudo: no |
| 99 | shell: ansible services -m ping -u ubuntu |
| 100 | |
| 101 | handlers: |
| 102 | - name: Reload dnsmasq |
| 103 | shell: killall -HUP dnsmasq |
| 104 | |
| 105 | # Play: Install services using Juju |
| 106 | - hosts: cloudlab-head |
| 107 | vars: |
| 108 | charm_src: /usr/local/src/charms/trusty |
| 109 | tasks: |
| 110 | - name: Initialize Juju |
| 111 | sudo: no |
| 112 | shell: juju generate-config |
| 113 | creates={{ ansible_env['PWD'] }}/.juju/environments.yaml |
| 114 | |
| 115 | - shell: uvt-kvm ip juju |
| 116 | register: juju_ip |
| 117 | |
| 118 | - name: Juju config file |
| 119 | sudo: no |
| 120 | template: src=templates/environments.yaml.j2 |
| 121 | dest={{ ansible_env['PWD'] }}/.juju/environments.yaml |
| 122 | |
| 123 | - name: Bootstrap Juju |
| 124 | sudo: no |
| 125 | shell: juju bootstrap |
| 126 | creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv |
| 127 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 128 | - name: Copy openstack.cfg for Juju |
| 129 | sudo: yes |
| 130 | copy: src=files/openstack.cfg |
| 131 | dest=/usr/local/src/openstack.cfg |
| 132 | |
| 133 | - name: Check for /usr/local/src/charms/trusty |
| 134 | sudo: yes |
| 135 | file: path={{ charm_src }} |
| 136 | state=directory |
| 137 | mode=0755 |
| 138 | |
| 139 | - name: Deploy OpenStack services with Juju |
| 140 | script: scripts/juju-setup.py |
| 141 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 142 | - name: Add all Juju relations between services |
| 143 | script: scripts/juju-relations.py |
| 144 | |
Andy Bavier | 5201714 | 2015-10-05 15:01:36 -0400 | [diff] [blame] | 145 | - name: Wait for relations to be fully added |
| 146 | script: scripts/wait-for-services.sh |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 147 | |
| 148 | # Play: Use libvirt hooks to set up iptables |
| 149 | - hosts: cloudlab-head |
| 150 | sudo: yes |
| 151 | tasks: |
| 152 | - name: Enable port forwarding for services |
| 153 | copy: src=files/{{ item }} |
| 154 | dest={{ item }} |
| 155 | mode=0755 |
| 156 | notify: |
| 157 | - reload libvirt config |
| 158 | - run qemu hook |
| 159 | with_items: |
| 160 | - /etc/libvirt/hooks/daemon |
| 161 | - /etc/libvirt/hooks/qemu |
| 162 | |
| 163 | handlers: |
| 164 | - name: reload libvirt config |
| 165 | shell: killall -HUP libvirtd |
| 166 | |
| 167 | - name: run qemu hook |
| 168 | shell: /etc/libvirt/hooks/qemu start start |
| 169 | |
| 170 | # Play: Create credentials, set up some basic OpenStack |
| 171 | - hosts: cloudlab-head |
| 172 | sudo: no |
| 173 | tasks: |
| 174 | |
| 175 | - name: Get keystone admin password |
| 176 | shell: juju run --unit=keystone/0 "sudo cat /var/lib/keystone/keystone.passwd" |
| 177 | register: keystone_password |
| 178 | |
| 179 | - shell: uvt-kvm ip keystone |
| 180 | register: keystone_ip |
| 181 | |
| 182 | - name: Create credentials |
| 183 | template: src=templates/admin-openrc.sh.j2 |
| 184 | dest={{ ansible_env['PWD'] }}/admin-openrc.sh |
| 185 | |
Andy Bavier | a08061a | 2015-10-05 08:24:59 -0400 | [diff] [blame] | 186 | - name: (CloudLab) Make sure that /root/setup exists |
Andy Bavier | 8da6df1 | 2015-10-02 12:33:48 -0400 | [diff] [blame] | 187 | file: path=/root/setup state=directory |
| 188 | sudo: yes |
| 189 | |
Andy Bavier | a08061a | 2015-10-05 08:24:59 -0400 | [diff] [blame] | 190 | - name: (CloudLab) Copy credentials to /root/setup |
Andy Bavier | 8da6df1 | 2015-10-02 12:33:48 -0400 | [diff] [blame] | 191 | shell: scp admin-openrc.sh /root/setup |
| 192 | sudo: yes |
| 193 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 194 | - name: Copy credentials to nova-cloud-controller |
| 195 | shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:" |
| 196 | |
| 197 | - name: Copy network setup script |
| 198 | sudo: yes |
| 199 | copy: src=scripts/network-setup.sh |
| 200 | dest=/usr/local/src/network-setup.sh |
| 201 | mode=0644 |
| 202 | |
Andy Bavier | 4e7762e | 2015-08-27 14:36:34 -0400 | [diff] [blame] | 203 | - name: Run network setup script |
| 204 | shell: ansible nova-cloud-controller -m script -u ubuntu -a "/usr/local/src/network-setup.sh" |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 205 | |
| 206 | - name: Get public key |
| 207 | shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub |
| 208 | register: sshkey |
| 209 | |
Andy Bavier | 8da6df1 | 2015-10-02 12:33:48 -0400 | [diff] [blame] | 210 | - name: Copy CA certificate |
Andy Bavier | 5201714 | 2015-10-05 15:01:36 -0400 | [diff] [blame] | 211 | shell: sudo juju scp nova-cloud-controller/0:/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt /usr/local/share/ca-certificates |
Andy Bavier | 8da6df1 | 2015-10-02 12:33:48 -0400 | [diff] [blame] | 212 | creates=/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt |
Andy Bavier | 8da6df1 | 2015-10-02 12:33:48 -0400 | [diff] [blame] | 213 | |
| 214 | - name: Update CA ca-certificates |
| 215 | shell: update-ca-certificates |
| 216 | sudo: yes |
| 217 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 218 | - hosts: cloudlab-compute |
| 219 | sudo: yes |
| 220 | vars: |
| 221 | control_net: 192.168.122.0/24 |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame] | 222 | gateway: "{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['ansible_default_ipv4']['address'] }}" |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 223 | tasks: |
| 224 | - name: Install package needed by Juju |
| 225 | apt: name=python-yaml state=present |
| 226 | |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame] | 227 | - name: Add key |
| 228 | authorized_key: user="{{ ansible_env['SUDO_USER'] }}" |
| 229 | key="{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['sshkey']['stdout'] }}" |
| 230 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 231 | - name: Add route via /etc/rc.local |
| 232 | template: src=templates/etc/rc.local.cloudlab |
| 233 | dest=/etc/rc.local |
| 234 | mode=0755 |
| 235 | notify: |
| 236 | - run /etc/rc.local |
| 237 | |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame] | 238 | - name: Touch ~/.ssh/config |
| 239 | file: path=/var/lib/nova state=directory |
| 240 | |
Andy Bavier | a08061a | 2015-10-05 08:24:59 -0400 | [diff] [blame] | 241 | - name: (CloudLab) Set up extra disk space |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame] | 242 | shell: /usr/testbed/bin/mkextrafs /var/lib/nova |
| 243 | creates=/var/lib/nova/lost+found |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 244 | |
| 245 | handlers: |
| 246 | - name: run /etc/rc.local |
| 247 | shell: /etc/rc.local |