summaryrefslogtreecommitdiffstats
path: root/xci/playbooks/get-opnfv-scenario-requirements.yml
blob: c59c18f1e87a3527f406bcd3aa7e2093b028df03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
# Copyright 2016, Rackspace US, Inc.
# Copyright 2017, SUSE LINUX GmbH.
#
# 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.

- name: Clone the scenario requirements
  hosts: localhost
  connection: local
  gather_facts: true
  vars_files:
    - ../var/opnfv.yml
  tasks:
    - name: Remove target directory
      file:
        path: "{{ item.path | default(scenario_path_default) + '/' + item.scenario }}"
        state: absent
      when:
        - item.scm == "git" or item.scm is undefined
      with_items: "{{ scenarios }}"

    - name: Clone git repos (with git)
      git:
        repo: "{{ item.src }}"
        dest: "{{ item.path | default(scenario_path_default) }}/{{ item.scenario | default(item.src | basename) }}"
        version: "{{ item.version | default('master') }}"
        refspec: "{{ item.refspec | default(omit) }}"
        update: true
        force: true
      when:
        - item.scm == "git" or item.scm is undefined
      with_items: "{{ scenarios }}"
      register: git_clone
      until: git_clone | success
      retries: "{{ git_clone_retries }}"
      delay: "{{ git_clone_retry_delay }}"

    - name: Plug in the roles to XCI
      shell: >-
          cp -a {{ item.path | default(scenario_path_default) }}/{{ item.scenario | default(item.src | basename) }}/{{ item.role }}
          {{ role_path_default }}/{{ item.scenario }}
      with_items: "{{ scenarios }}"

  vars:
    ansible_python_interpreter: "/usr/bin/python"
    scenarios: "{{ lookup('file', scenario_file) | from_yaml }}"
    scenario_file: '../opnfv-scenario-requirements.yml'
    scenario_path_default: "{{ XCI_SCENARIOS_CACHE }}"
    role_path_default: "{{ playbook_dir }}/roles"
    git_clone_retries: 2
    git_clone_retry_delay: 5