bifrost/playbooks/roles/bifrost-prep-for-install/tasks/main.yml
Pavlo Shchelokovskyy aa38052400 DRY when installing components
collect source/git info into a list and use it via `with_items` when
cloning/local copying sources.

Also, use git module with appropriate arguments instead of calling
git 4 times through command module.

Change-Id: Ia0be4b64b849cac1c32da02b2492ce026233d8b7
2016-12-05 15:14:51 +00:00

38 lines
1.3 KiB
YAML

# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# 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: ensure installation root folder exists
file:
state: directory
dest: "{{ git_root }}"
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_gid }}"
- name: "Download via GIT"
git:
dest: "{{ item.git_folder }}"
force: yes
repo: "{{ item.git_url }}"
version: "{{ item.git_branch }}"
update: yes
clone: yes
with_items: "{{ bifrost_install_sources }}"
when: ci_testing_zuul | bool == false and copy_from_local_path | bool == false
- name: "Copy from local path"
command: cp -a {{ item.git_url }} {{ item.git_folder }} creates={{ item.git_folder }}
with_items: "{{ bifrost_install_sources }}"
when: ci_testing_zuul | bool == true or copy_from_local_path | bool == true