---
# Common ONOS setup
- hosts: onos-cord-1:onos-fabric-1
  remote_user: ubuntu

  tasks:
    - name: Include configuration vars
      include_vars: onos-setup-vars.yml

    - name: Create CORD directory
      file:
        path: "{{ ansible_user_dir }}/cord"
        state: directory

    - name: Pull docker image for ONOS
      become: yes
      command: "docker pull {{ onos_docker_image }}"
      tags:
        - skip_ansible_lint # Should replace with http://docs.ansible.com/ansible/docker_module.html, when replacements are stable

# Setup specific for onos-cord VM
- hosts: onos-cord-1
  remote_user: ubuntu

  tasks:
    - name: Copy over SSH key
      copy:
        src: "{{ node_private_key }}"
        dest: "{{ ansible_user_dir }}/cord/node_key"
        owner: "{{ ansible_user_id }}"
        mode: 0600

    - name: Copy over files to build XOS variant of ONOS
      copy:
        src: "~/{{ item }}"
        dest: "{{ ansible_user_dir }}/cord/{{ item }}"
      with_items:
       - Dockerfile.xos-onos
       - onos-service

    - name: Copy over & rename docker-compose file
      copy:
        src: "~/onos-docker-compose.yml"
        dest: "{{ ansible_user_dir }}/cord/docker-compose.yml"

- hosts: onos-fabric-1
  remote_user: ubuntu

  tasks:
    - name: Copy over & rename docker-compose file
      copy:
        src: "~/fabric-docker-compose.yml"
        dest: "{{ ansible_user_dir }}/cord/docker-compose.yml"
