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:
parent
1b1dc14297
commit
67bea88f60
@ -18,16 +18,6 @@
|
|||||||
connection: local
|
connection: local
|
||||||
user: root
|
user: root
|
||||||
tasks:
|
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
|
- name: Remove target directory if required
|
||||||
shell: |
|
shell: |
|
||||||
if [[ ! -d "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}/.git" ]]; then
|
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
|
- item.scm == "git" or item.scm is undefined
|
||||||
with_items: "{{ roles }}"
|
with_items: "{{ roles }}"
|
||||||
|
|
||||||
- name: Prepare zuul changes clone list
|
- name: Ensure the default roles directory exists
|
||||||
set_fact:
|
file:
|
||||||
zuul_changes: >
|
path: "{{ role_path_default }}"
|
||||||
{%- set filtered_repo_list = [] %}
|
state: directory
|
||||||
{%- 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: Prepare zuul/git clone list
|
- name: Use Zuul provided sources in Zuul environment
|
||||||
set_fact:
|
block:
|
||||||
zuul_roles: >
|
- name: Check the Zuul src dir for cloned roles
|
||||||
{%- set filtered_role_list = [] %}
|
stat:
|
||||||
{%- for role in roles %}
|
path: "/home/zuul/src/{{ item.src.split('/')[-3:] | join('/') }}"
|
||||||
{%- if role.src | match(".*git.openstack.org.*") %}
|
register: zuul_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_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 -}}
|
|
||||||
when:
|
when:
|
||||||
- _zuul_cloner_check.rc == 0
|
- item.scm == "git" or item.scm is undefined
|
||||||
|
with_items: "{{ roles }}"
|
||||||
- name: Create clone map
|
- name: Link the Zuul provided roles
|
||||||
copy:
|
file:
|
||||||
content: |
|
src: "/home/zuul/src/{{ item.item.src.split('/')[-3:] | join('/') }}"
|
||||||
clonemap:
|
dest: "{{ item.item.path | default(role_path_default) }}/{{ item.item.name | default(item.item.src | basename) }}"
|
||||||
- name: 'openstack/ansible-hardening'
|
state: link
|
||||||
dest: '{{ role_path_default }}/ansible-hardening'
|
owner: root
|
||||||
- name: 'openstack/openstack-ansible-(.*)'
|
group: root
|
||||||
dest: '{{ role_path_default }}/\1'
|
with_items: "{{ zuul_roles.results
|
||||||
- name: 'openstack/(?!(openstack-ansible|ansible-hardening))(.*)'
|
| selectattr('stat.exists')
|
||||||
dest: '/tmp/openstack/\2'
|
| list }}"
|
||||||
dest: "/tmp/zuul-clonemap.yml"
|
|
||||||
when:
|
when:
|
||||||
- _zuul_cloner_check.rc == 0
|
- "lookup('env', 'ZUUL_PROJECT') != ''"
|
||||||
|
|
||||||
- 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 }}"
|
|
||||||
|
|
||||||
- name: Clone git repos (with git)
|
- name: Clone git repos (with git)
|
||||||
git:
|
git:
|
||||||
@ -117,7 +66,11 @@
|
|||||||
force: true
|
force: true
|
||||||
when:
|
when:
|
||||||
- item.scm == "git" or item.scm is undefined
|
- 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
|
register: git_clone
|
||||||
until: git_clone | success
|
until: git_clone | success
|
||||||
retries: "{{ git_clone_retries }}"
|
retries: "{{ git_clone_retries }}"
|
||||||
|
Loading…
Reference in New Issue
Block a user