---
# repo/tasks/main.yml

- name: Download and install repo tool
  become: yes
  get_url:
    url: "{{ repo_dl_url }}"
    checksum: "{{ repo_checksum }}"
    dest: "/usr/local/bin/repo"
    owner: root
    group: root
    mode: 0755

- name: Create CORD directory
  file:
    dest: "{{ cord_dir }}"
    state: directory

- name: Init CORD repos (master branch) using repo
  command: "/usr/local/bin/repo init -u {{ repo_manifest_url }} -b master -g build,onos,orchestration"
  args:
    chdir: "{{ cord_dir }}"
    creates: "{{ cord_dir }}/.repo"

- name: Synchronize CORD repos using repo
  command: "repo sync"
  args:
    chdir: "{{ cord_dir }}"
    creates: "{{ cord_dir }}/build"

- name: Download specific gerrit changesets using repo
  command: "/usr/local/bin/repo download {{ item.path }} {{ item.revision }}"
  args:
    chdir: "{{ cord_dir }}"
  with_items: "{{ gerrit_changesets }}"
  tags:
    - skip_ansible_lint # usually won't be run, except during dev

