Updated repo cloner for zuulv3

With the new job layout we need to update the
`get-ansible-role-requirements.yml` playbook to support the new system.

Change-Id: Ib582f2a5596c5b41fac976f7a03bc62cece7b0f2
This commit is contained in:
Logan V 2017-09-29 08:19:39 -05:00
parent 1b1dc14297
commit 67bea88f60

View File

@ -18,16 +18,6 @@
connection: local
user: root
tasks:
- name: Check whether zuul-cloner is installed and provide the path to it
shell: |
which zuul-cloner || { [[ -x /usr/zuul-env/bin/zuul-cloner ]] && echo '/usr/zuul-env/bin/zuul-cloner'; }
args:
executable: /bin/bash
changed_when: false
failed_when: false
register: _zuul_cloner_check
- name: Remove target directory if required
shell: |
if [[ ! -d "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}/.git" ]]; then
@ -39,73 +29,32 @@
- item.scm == "git" or item.scm is undefined
with_items: "{{ roles }}"
- name: Prepare zuul changes clone list
set_fact:
zuul_changes: >
{%- set filtered_repo_list = [] %}
{%- set repo_list = lookup('env', 'ZUUL_CHANGES').split('^') %}
{%- for repo in repo_list %}
{%- set repo_cleaned = repo | regex_replace(':.*$', '') %}
{%- set _ = filtered_repo_list.append(repo_cleaned) %}
{%- endfor %}
{{- filtered_repo_list -}}
when:
- _zuul_cloner_check.rc == 0
- name: Ensure the default roles directory exists
file:
path: "{{ role_path_default }}"
state: directory
- name: Prepare zuul/git clone list
set_fact:
zuul_roles: >
{%- set filtered_role_list = [] %}
{%- for role in roles %}
{%- if role.src | match(".*git.openstack.org.*") %}
{%- set role_src_cleaned = role.src | regex_replace('https://git.openstack.org/', '') %}
{%- if role_src_cleaned not in zuul_changes %}
{%- set _ = filtered_role_list.append(role_src_cleaned) %}
{%- endif %}
{%- endif %}
{%- endfor %}
{{- filtered_role_list -}}
git_roles: >
{%- set filtered_role_list = [] %}
{%- for role in roles %}
{%- set role_src_cleaned = role.src | regex_replace('https://git.openstack.org/', '') %}
{%- if role_src_cleaned not in zuul_changes %}
{%- set _ = filtered_role_list.append(role) %}
{%- endif %}
{%- endfor %}
{{- filtered_role_list -}}
- name: Use Zuul provided sources in Zuul environment
block:
- name: Check the Zuul src dir for cloned roles
stat:
path: "/home/zuul/src/{{ item.src.split('/')[-3:] | join('/') }}"
register: zuul_roles
when:
- _zuul_cloner_check.rc == 0
- name: Create clone map
copy:
content: |
clonemap:
- name: 'openstack/ansible-hardening'
dest: '{{ role_path_default }}/ansible-hardening'
- name: 'openstack/openstack-ansible-(.*)'
dest: '{{ role_path_default }}/\1'
- name: 'openstack/(?!(openstack-ansible|ansible-hardening))(.*)'
dest: '/tmp/openstack/\2'
dest: "/tmp/zuul-clonemap.yml"
- item.scm == "git" or item.scm is undefined
with_items: "{{ roles }}"
- name: Link the Zuul provided roles
file:
src: "/home/zuul/src/{{ item.item.src.split('/')[-3:] | join('/') }}"
dest: "{{ item.item.path | default(role_path_default) }}/{{ item.item.name | default(item.item.src | basename) }}"
state: link
owner: root
group: root
with_items: "{{ zuul_roles.results
| selectattr('stat.exists')
| list }}"
when:
- _zuul_cloner_check.rc == 0
- name: Clone git repos (with zuul-cloner)
shell: |
{{ _zuul_cloner_check.stdout }} \
--map /tmp/zuul-clonemap.yml \
--cache-dir /opt/git \
git://git.openstack.org \
{% for repo in zuul_roles + zuul_changes %}
{{ repo }} \
{% endfor %}
when:
- _zuul_cloner_check.rc == 0
register: zuul_clone
until: zuul_clone | success
retries: "{{ git_clone_retries }}"
delay: "{{ git_clone_retry_delay }}"
- "lookup('env', 'ZUUL_PROJECT') != ''"
- name: Clone git repos (with git)
git:
@ -117,7 +66,11 @@
force: true
when:
- item.scm == "git" or item.scm is undefined
with_items: "{{ git_roles | default(roles) }}"
with_items: "{{ (zuul_roles.results | default([]) |
selectattr('stat', 'defined') |
rejectattr('stat.exists') |
map(attribute='item') | list)
| default(roles, True) }}"
register: git_clone
until: git_clone | success
retries: "{{ git_clone_retries }}"