Files
openstack-ansible/tests/get-ansible-role-requirements.yml
Logan V 303706708c Allow refspec in role fetcher
This allows specification in the ansible-role-requirements to pull
a role directly from a gerrit change.

Example:
- name: os_neutron
  scm: git
  src: https://git.openstack.org/openstack/openstack-ansible-os_neutron
  version: FETCH_HEAD
  refspec: '+refs/changes/24/391524/*:refs/remotes/origin/changes/24/391524/*'

This will pull the latest revision of change 391524.

Change-Id: I96666f349d6f0317d51735146e94c3bd12c7ef6f
2016-12-05 14:25:35 -06:00

46 lines
1.7 KiB
YAML

---
# 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(role_path_default) }}/{{ item.name | default(item.src | basename) }}/.git" ]]; then
rm -rf "{{ item.path | default(role_path_default) }}/{{ 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: "{{ item.path | default(role_path_default) }}/{{ item.name | 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: "{{ roles }}"
vars:
roles: "{{ lookup('file', role_file) | from_yaml }}"
role_file: '../ansible-role-requirements.yml'
role_path_default: '/etc/ansible/roles'