
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


---
# 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: "{{ config_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: "{{ config_cord_dir }}"
    creates: "{{ config_cord_dir }}/.repo"

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

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

