Allow role path override in fetch play

Allow a var override to the default role destination path when
none is specified for the role in the requirements file.

Change-Id: Ib063db808eabae4bfd3e6016e83ec5347b478185
This commit is contained in:
Logan V 2016-11-09 22:15:54 -06:00 committed by Jesse Pretorius (odyssey4me)
parent b70a0276f4
commit f34df8320d

View File

@ -20,8 +20,8 @@
tasks: tasks:
- name: Remove target directory if required - name: Remove target directory if required
shell: | shell: |
if [[ ! -d "{{ item.path | default('/etc/ansible/roles') }}/{{ item.name | default(item.src | basename) }}/.git" ]]; then if [[ ! -d "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}/.git" ]]; then
rm -rf "{{ item.path | default('/etc/ansible/roles') }}/{{ item.name | default(item.src | basename) }}" rm -rf "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}"
fi fi
args: args:
executable: /bin/bash executable: /bin/bash
@ -31,7 +31,7 @@
- name: Clone git repos - name: Clone git repos
git: git:
repo: "{{ item.src }}" repo: "{{ item.src }}"
dest: "{{ item.path | default('/etc/ansible/roles') }}/{{ item.name | default(item.src | basename) }}" dest: "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}"
version: "{{ item.version | default('master') }}" version: "{{ item.version | default('master') }}"
update: true update: true
force: true force: true
@ -40,4 +40,5 @@
with_items: "{{ roles }}" with_items: "{{ roles }}"
vars: vars:
roles: "{{ lookup('file', role_file) | from_yaml }}" roles: "{{ lookup('file', role_file) | from_yaml }}"
role_file: '../ansible-role-requirements.yml' role_file: '../ansible-role-requirements.yml'
role_path_default: '/etc/ansible/roles'