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 | |
| 8 | - apt: name={{ item }} |
| 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 | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 30 | |
| 31 | - name: Get juju-ansible git repo |
| 32 | git: repo=https://github.com/cmars/juju-ansible.git |
| 33 | dest=/usr/local/src/juju-ansible |
| 34 | |
| 35 | - name: Set up juju-ansible symlink |
| 36 | file: dest=/usr/local/bin/juju-ansible |
| 37 | src=/usr/local/src/juju-ansible/juju-ansible |
| 38 | state=link |
| 39 | |
| 40 | - name: Set up juju-ansible-playbook symlink |
| 41 | file: dest=/usr/local/bin/juju-ansible-playbook |
| 42 | src=/usr/local/src/juju-ansible/juju-ansible |
| 43 | state=link |
| 44 | |
| 45 | - name: Generate key to use in VMs |
| 46 | user: name={{ ansible_env['SUDO_USER'] }} generate_ssh_key=yes |
| 47 | |
| 48 | - name: Set up extra space on CloudLab nodes |
| 49 | shell: /usr/testbed/bin/mkextrafs /var/lib/uvtool/libvirt/images |
| 50 | creates=/var/lib/uvtool/libvirt/images/lost+found |
| 51 | |
| 52 | - name: Add myself to libvirtd group |
Andy Bavier | b1ae26e | 2015-09-17 16:20:46 -0400 | [diff] [blame] | 53 | user: name={{ ansible_env['SUDO_USER'] }} |
| 54 | groups=libvirtd |
| 55 | append=yes |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 56 | |
| 57 | - name: Get trusty image for uvtool |
| 58 | shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64 |
| 59 | |
| 60 | - name: Create VMs to host OpenCloud services |
| 61 | sudo: no |
| 62 | script: scripts/create-vms.sh |
| 63 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 64 | - include: tasks/vm-ips.yml |
| 65 | |
| 66 | - name: Add VMs to /etc/hosts |
| 67 | template: src=templates/etc/hosts.j2 |
| 68 | dest=/etc/hosts |
| 69 | notify: |
| 70 | - Reload dnsmasq |
| 71 | |
| 72 | - name: Set up /etc/ansible/hosts |
| 73 | template: src=templates/etc/ansible/hosts.j2 |
| 74 | dest=/etc/ansible/hosts |
| 75 | |
| 76 | - name: Copy ansible.cfg to disable host key checking |
| 77 | sudo: no |
| 78 | copy: src=files/ansible.cfg |
| 79 | dest={{ ansible_env['PWD'] }}/.ansible.cfg |
| 80 | |
| 81 | - name: Touch ~/.ssh/config |
| 82 | sudo: no |
| 83 | file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch |
| 84 | |
| 85 | - name: Disable host key checking in SSH |
| 86 | sudo: no |
| 87 | lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config |
| 88 | line="StrictHostKeyChecking no" |
| 89 | |
| 90 | - name: Test that we can log into every VM |
| 91 | sudo: no |
| 92 | shell: ansible services -m ping -u ubuntu |
| 93 | |
| 94 | handlers: |
| 95 | - name: Reload dnsmasq |
| 96 | shell: killall -HUP dnsmasq |
| 97 | |
| 98 | # Play: Install services using Juju |
| 99 | - hosts: cloudlab-head |
| 100 | vars: |
| 101 | charm_src: /usr/local/src/charms/trusty |
| 102 | tasks: |
| 103 | - name: Initialize Juju |
| 104 | sudo: no |
| 105 | shell: juju generate-config |
| 106 | creates={{ ansible_env['PWD'] }}/.juju/environments.yaml |
| 107 | |
| 108 | - shell: uvt-kvm ip juju |
| 109 | register: juju_ip |
| 110 | |
| 111 | - name: Juju config file |
| 112 | sudo: no |
| 113 | template: src=templates/environments.yaml.j2 |
| 114 | dest={{ ansible_env['PWD'] }}/.juju/environments.yaml |
| 115 | |
| 116 | - name: Bootstrap Juju |
| 117 | sudo: no |
| 118 | shell: juju bootstrap |
| 119 | creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv |
| 120 | |
| 121 | # - pause: Break here and try rebooting Juju VM |
| 122 | |
| 123 | - name: Copy openstack.cfg for Juju |
| 124 | sudo: yes |
| 125 | copy: src=files/openstack.cfg |
| 126 | dest=/usr/local/src/openstack.cfg |
| 127 | |
| 128 | - name: Check for /usr/local/src/charms/trusty |
| 129 | sudo: yes |
| 130 | file: path={{ charm_src }} |
| 131 | state=directory |
| 132 | mode=0755 |
| 133 | |
| 134 | - name: Deploy OpenStack services with Juju |
| 135 | script: scripts/juju-setup.py |
| 136 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 137 | - name: Add all Juju relations between services |
| 138 | script: scripts/juju-relations.py |
| 139 | |
| 140 | - pause: prompt="Wait for relations to be fully added" |
| 141 | |
| 142 | # Play: Use libvirt hooks to set up iptables |
| 143 | - hosts: cloudlab-head |
| 144 | sudo: yes |
| 145 | tasks: |
| 146 | - name: Enable port forwarding for services |
| 147 | copy: src=files/{{ item }} |
| 148 | dest={{ item }} |
| 149 | mode=0755 |
| 150 | notify: |
| 151 | - reload libvirt config |
| 152 | - run qemu hook |
| 153 | with_items: |
| 154 | - /etc/libvirt/hooks/daemon |
| 155 | - /etc/libvirt/hooks/qemu |
| 156 | |
| 157 | handlers: |
| 158 | - name: reload libvirt config |
| 159 | shell: killall -HUP libvirtd |
| 160 | |
| 161 | - name: run qemu hook |
| 162 | shell: /etc/libvirt/hooks/qemu start start |
| 163 | |
| 164 | # Play: Create credentials, set up some basic OpenStack |
| 165 | - hosts: cloudlab-head |
| 166 | sudo: no |
| 167 | tasks: |
| 168 | |
| 169 | - name: Get keystone admin password |
| 170 | shell: juju run --unit=keystone/0 "sudo cat /var/lib/keystone/keystone.passwd" |
| 171 | register: keystone_password |
| 172 | |
| 173 | - shell: uvt-kvm ip keystone |
| 174 | register: keystone_ip |
| 175 | |
| 176 | - name: Create credentials |
| 177 | template: src=templates/admin-openrc.sh.j2 |
| 178 | dest={{ ansible_env['PWD'] }}/admin-openrc.sh |
| 179 | |
| 180 | - name: Copy credentials to nova-cloud-controller |
| 181 | shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:" |
| 182 | |
| 183 | - name: Copy network setup script |
| 184 | sudo: yes |
| 185 | copy: src=scripts/network-setup.sh |
| 186 | dest=/usr/local/src/network-setup.sh |
| 187 | mode=0644 |
| 188 | |
Andy Bavier | 4e7762e | 2015-08-27 14:36:34 -0400 | [diff] [blame] | 189 | - name: Run network setup script |
| 190 | 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] | 191 | |
| 192 | - name: Get public key |
| 193 | shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub |
| 194 | register: sshkey |
| 195 | |
| 196 | - hosts: cloudlab-compute |
| 197 | sudo: yes |
| 198 | vars: |
| 199 | control_net: 192.168.122.0/24 |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame] | 200 | 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] | 201 | tasks: |
| 202 | - name: Install package needed by Juju |
| 203 | apt: name=python-yaml state=present |
| 204 | |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame] | 205 | - name: Add key |
| 206 | authorized_key: user="{{ ansible_env['SUDO_USER'] }}" |
| 207 | key="{{ hostvars['ctl.install.xos-pg0.clemson.cloudlab.us']['sshkey']['stdout'] }}" |
| 208 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 209 | - name: Add route via /etc/rc.local |
| 210 | template: src=templates/etc/rc.local.cloudlab |
| 211 | dest=/etc/rc.local |
| 212 | mode=0755 |
| 213 | notify: |
| 214 | - run /etc/rc.local |
| 215 | |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame] | 216 | - name: Touch ~/.ssh/config |
| 217 | file: path=/var/lib/nova state=directory |
| 218 | |
| 219 | - name: Set up extra space on CloudLab nodes |
| 220 | shell: /usr/testbed/bin/mkextrafs /var/lib/nova |
| 221 | creates=/var/lib/nova/lost+found |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 222 | |
| 223 | handlers: |
| 224 | - name: run /etc/rc.local |
| 225 | shell: /etc/rc.local |