| --- |
| # Play: set up head node |
| - hosts: head |
| sudo: yes |
| tasks: |
| |
| - apt: name={{ item }} update_cache=yes |
| with_items: |
| - python-pycurl |
| - software-properties-common |
| |
| - name: Add Juju repository |
| apt_repository: repo="ppa:juju/stable" |
| |
| - name: Add Ansible repository |
| apt_repository: repo="ppa:ansible/ansible" |
| |
| - name: Update apt cache |
| apt: update_cache=yes |
| |
| - name: Install packages |
| apt: name={{ item }} state=latest |
| with_items: |
| - ansible |
| - uvtool |
| - git |
| - bzr |
| - juju-core |
| - juju-quickstart |
| - python-novaclient |
| - python-neutronclient |
| - python-keystoneclient |
| - python-glanceclient |
| |
| - name: Get juju-ansible git repo |
| git: repo=https://github.com/cmars/juju-ansible.git |
| dest=/usr/local/src/juju-ansible |
| |
| - name: Set up juju-ansible symlink |
| file: dest=/usr/local/bin/juju-ansible |
| src=/usr/local/src/juju-ansible/juju-ansible |
| state=link |
| |
| - name: Set up juju-ansible-playbook symlink |
| file: dest=/usr/local/bin/juju-ansible-playbook |
| src=/usr/local/src/juju-ansible/juju-ansible |
| state=link |
| |
| - name: Generate key to use in VMs |
| user: name={{ ansible_env['SUDO_USER'] }} generate_ssh_key=yes |
| |
| - name: Get public key |
| shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub |
| register: sshkey |
| |
| - name: Add key |
| authorized_key: user="{{ ansible_env['SUDO_USER'] }}" |
| key="{{ sshkey.stdout }}" |
| |
| - name: Copy keypair to /tmp |
| shell: cp -f {{ ansible_env['PWD'] }}/.ssh/{{ item }} /tmp; chmod +r /tmp/{{ item }} |
| with_items: |
| - id_rsa |
| - id_rsa.pub |
| |
| - name: Check whether we're on CloudLab |
| shell: ls /usr/testbed/bin/mkextrafs |
| ignore_errors: true |
| register: is_cloudlab |
| |
| - name: (CloudLab) Set up extra disk space |
| shell: /usr/testbed/bin/mkextrafs -f /var/lib/uvtool/libvirt/images |
| creates=/var/lib/uvtool/libvirt/images/lost+found |
| when: is_cloudlab | success |
| |
| - name: Add myself to libvirtd group |
| user: name={{ ansible_env['SUDO_USER'] }} |
| groups=libvirtd |
| append=yes |
| |
| - name: Get trusty image for uvtool |
| shell: uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=trusty arch=amd64 |
| |
| # Play: create VMs to host OpenStack services |
| - hosts: head |
| sudo: yes |
| tasks: |
| |
| # Yes I know |
| - name: Add local resolver to /etc/resolv.conf |
| lineinfile: dest=/etc/resolv.conf |
| insertafter=".*DO NOT EDIT THIS FILE.*" |
| line="nameserver 192.168.122.1" |
| when: test_setup is defined |
| |
| - name: Create VMs to host OpenCloud services on mgmtbr |
| sudo: no |
| script: scripts/create-vms-cord.sh |
| when: test_setup is not defined |
| |
| - name: Create VMs to host OpenCloud services on virbr0 |
| sudo: no |
| script: scripts/create-vms-cord.sh --testing |
| when: test_setup is defined |
| |
| - name: Set up /etc/ansible/hosts |
| template: src=templates/etc/ansible/cord-hosts.j2 |
| dest=/etc/ansible/hosts |
| |
| - name: Copy ansible.cfg to disable host key checking |
| sudo: no |
| copy: src=files/ansible.cfg |
| dest={{ ansible_env['PWD'] }}/.ansible.cfg |
| |
| - name: Touch ~/.ssh/config |
| sudo: no |
| file: path={{ ansible_env['PWD'] }}/.ssh/config state=touch |
| |
| - name: Disable host key checking in SSH |
| sudo: no |
| lineinfile: dest={{ ansible_env['PWD'] }}/.ssh/config |
| line="StrictHostKeyChecking no" |
| |
| - name: Test that we can log into every VM |
| sudo: no |
| shell: ansible services -m ping -u ubuntu |
| |
| # Play: prepare compute nodes for installation |
| - hosts: compute |
| sudo: yes |
| tasks: |
| - name: Install package needed by Juju |
| apt: name=python-yaml state=present |
| |
| - name: Add key for standard user |
| authorized_key: user="{{ ansible_env['SUDO_USER'] }}" |
| key="{{ hostvars['head']['sshkey']['stdout'] }}" |
| |
| - name: Add key for root |
| authorized_key: user="root" |
| key="{{ hostvars['head']['sshkey']['stdout'] }}" |
| |
| - name: Check whether we're on CloudLab |
| shell: ls /usr/testbed/bin/mkextrafs |
| ignore_errors: true |
| register: is_cloudlab |
| |
| - name: Make sure that /var/lib/nova exists |
| file: path=/var/lib/nova state=directory |
| when: is_cloudlab | success |
| |
| - name: (CloudLab) Set up extra disk space |
| shell: /usr/testbed/bin/mkextrafs -f /var/lib/nova |
| creates=/var/lib/nova/lost+found |
| when: is_cloudlab | success |
| |
| # Play: Install services using Juju |
| - hosts: head |
| vars: |
| charm_src: /usr/local/src/charms/trusty |
| tasks: |
| - name: Initialize Juju |
| sudo: no |
| shell: juju generate-config |
| creates={{ ansible_env['PWD'] }}/.juju/environments.yaml |
| |
| - name: Juju config file |
| sudo: no |
| template: src=templates/environments.yaml.j2 |
| dest={{ ansible_env['PWD'] }}/.juju/environments.yaml |
| |
| - name: Bootstrap Juju |
| sudo: no |
| shell: juju bootstrap |
| creates={{ ansible_env['PWD'] }}/.juju/environments/manual.jenv |
| |
| - name: Check that 'juju status' works |
| sudo: no |
| shell: juju status |
| |
| - name: Add virtual machines to Juju's control |
| shell: juju add-machine ssh:{{ item }} |
| with_items: "{{ groups['openstack'] }}" |
| |
| - name: Add compute nodes to Juju's control |
| shell: juju add-machine ssh:{{ item }} |
| with_items: "{{ groups['compute'] }}" |
| |
| - name: Copy cord.yaml bundle |
| template: src=templates/cord.yaml dest={{ ansible_env['PWD'] }}/cord.yaml |
| |
| - name: Deploy OpenStack services with Juju |
| shell: juju quickstart cord.yaml |
| |
| - hosts: head |
| sudo: no |
| tasks: |
| |
| - name: Create credentials |
| template: src=templates/admin-openrc-cord.sh.j2 |
| dest={{ ansible_env['PWD'] }}/admin-openrc.sh |
| |
| - name: Copy credentials to /tmp |
| shell: cp -f {{ ansible_env['PWD'] }}/admin-openrc.sh /tmp |
| |
| - name: Copy credentials to nova-cloud-controller |
| shell: "scp admin-openrc.sh ubuntu@nova-cloud-controller:" |
| |
| - hosts: head |
| sudo: no |
| tasks: |
| |
| - name: Copy over VM setup files |
| copy: src=files/tmp/{{ item }} |
| dest=/tmp |
| with_items: |
| - set-up-xos.yml |
| - set-up-onos.yml |
| |
| - name: Copy over ONOS docker-compose.yml |
| copy: src=files/onos/docker-compose.yml |
| dest=/tmp |
| |
| - name: Set up xos VM |
| shell: ansible-playbook /tmp/set-up-xos.yml |
| |
| - name: Set up onos-cord VM |
| shell: ansible-playbook /tmp/set-up-onos.yml |