Implement git clone of roles
Added get-ansible-role-requirements.yml to a testing repo that uses git clone to download the roles instead of downloading the roles using ansible-galaxy. Closes-Bug: 1626113 Change-Id: I241de348310a7a3beba6181a271f5351c9460318
This commit is contained in:
parent
882f325053
commit
00902d8120
43
get-ansible-role-requirements.yml
Normal file
43
get-ansible-role-requirements.yml
Normal file
@ -0,0 +1,43 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, Inc.
|
||||
#
|
||||
# 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 role ansible-role-requirements
|
||||
hosts: localhost
|
||||
connection: local
|
||||
user: root
|
||||
tasks:
|
||||
- name: Remove target directory if required
|
||||
shell: |
|
||||
if [[ ! -d "{{ item.path | default('/etc/ansible/roles') }}/{{ item.name | default(item.src | basename) }}/.git" ]]; then
|
||||
rm -rf "{{ item.path | default('/etc/ansible/roles') }}/{{ item.name | default(item.src | basename) }}"
|
||||
fi
|
||||
args:
|
||||
executable: /bin/bash
|
||||
when:
|
||||
- item.scm == "git" or item.scm is undefined
|
||||
with_items: "{{ roles }}"
|
||||
- name: Clone git repos
|
||||
git:
|
||||
repo: "{{ item.src }}"
|
||||
dest: "{{ homedir }}/.ansible/roles/{{ item.name | default(item.src | basename) }}"
|
||||
version: "{{ item.version | default('master') }}"
|
||||
update: true
|
||||
force: true
|
||||
when:
|
||||
- item.scm == "git" or item.scm is undefined
|
||||
with_items: "{{ roles }}"
|
||||
vars:
|
||||
role_file: "{{ toxinidir }}/tests/ansible-role-requirements.yml"
|
||||
roles: "{{ lookup('file', role_file) | from_yaml }}"
|
@ -61,10 +61,9 @@ fi
|
||||
# Download the Ansible role repositories if they are not present on the host.
|
||||
# This is ignored if there is no ansible-role-requirements file.
|
||||
if [ ! -d "${ANSIBLE_ROLE_DIR}" ] && [ -f "${ANSIBLE_ROLE_REQUIREMENTS_PATH}" ]; then
|
||||
ansible-galaxy install \
|
||||
--role-file="${ANSIBLE_ROLE_REQUIREMENTS_PATH}" \
|
||||
--roles-path "${ANSIBLE_ROLE_DIR}" \
|
||||
--force
|
||||
ansible-playbook -i "localhost ansible-connection=local," \
|
||||
${COMMON_TESTS_PATH}/get-ansible-role-requirements.yml \
|
||||
-e "toxinidir=${WORKING_DIR} homedir=${TESTING_HOME}"
|
||||
fi
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user