Fix project name mapping to DLRN project name (v2)

This fixes failures produced when project name
doesn't starts with 'openstack/'

This is intended to unblock the use of tripleo-ci
that is now failing with projects that are not
hosted under the 'openstack/' prefix (like for
example x/tobiko).

Note: removed set -u because this can break source activate on old
versions of virtualenv.

The role should not fail when it fails to find a mapping, so it was
refactored to assured that.

Also assures that the html report of Ansible is colored, making it
easier to read.

Change-Id: Ibb562f818419373700177f3b2e665cd4eb5e32ef
Partial-Bug: #1859167
Partial-Bug: #1858890
This commit is contained in:
Sorin Sbarnea 2020-01-09 15:38:20 +01:00
parent cfb5d862d2
commit 5795847107
6 changed files with 56 additions and 22 deletions

View File

@ -6,6 +6,7 @@ artg_dlrn_repo_url: "https://github.com/openstack-packages/DLRN.git"
artg_rdoinfo_repo_url: "https://github.com/redhat-openstack/rdoinfo"
artg_compressed_gating_repo: "/home/stack/gating_repo.tar.gz"
artg_build_one: true
artg_rdo_packages: []
dlrn_target: >-
{%- if ansible_distribution == "RedHat" -%}
redhat

View File

@ -1,3 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: Include role
include_role:
name: build-test-packages

View File

@ -30,27 +30,26 @@
loop_control:
loop_var: project_item
- name: Map project name to DLRN project name
register: project_name_mapped
shell: >
set -euo pipefail;
source {{ build_repo_dir }}/dlrn-venv/bin/activate;
export PROJECT_NAME=$(echo {{ artg_change.project }} | sed "s|openstack/||");
rdopkg findpkg -s $PROJECT_NAME -l rdoinfo | grep ^name | awk '{print $2}'
args:
chdir: '{{ build_repo_dir }}/DLRN'
changed_when: false
- block:
- name: Map project name to DLRN project name
register: project_name_mapped
shell: >
set -exo pipefail;
source {{ build_repo_dir }}/dlrn-venv/bin/activate;
rdopkg findpkg -s {{ artg_change.project | basename }} -l rdoinfo | grep ^name | awk '{print $2}'
args:
chdir: '{{ build_repo_dir }}/DLRN'
changed_when: false
- debug:
msg: "WARNING: Unable to build {{ artg_change.project }}. No pkg found."
when: project_name_mapped.stdout == ''
rescue:
- debug:
msg: |
WARNING: Unable to build {{ artg_change.project }}
{{ project_name_mapped }}
- name: Ensure artg_rdo_packages is defined
set_fact:
artg_rdo_packages: []
when: artg_rdo_packages is not defined
- when: project_name_mapped.stdout != ''
- when:
- project_name_mapped is success
- project_name_mapped.stdout != '' # noqa 602
block:
- name: Append project name to package list
set_fact:
@ -82,7 +81,9 @@
refspec: '{{ artg_change.distgit.refspec }}'
version: 'FETCH_HEAD'
accept_hostkey: true
when: artg_change.distgit is defined and (artg_repos_dir is not defined or copy_dir is failed)
when:
- artg_change.distgit is defined
- artg_repos_dir is not defined or copy_dir is failed
- name: Run DLRN
shell: >
@ -107,3 +108,8 @@
chdir: '{{ build_repo_dir }}/DLRN'
register: repo_built
when: artg_build_one|bool
- name: Ensure artg_rdo_packages is defined
set_fact:
artg_rdo_packages: []
when: artg_rdo_packages is not defined

View File

@ -173,6 +173,7 @@
register: old_dlrn
- name: Remove DLRN RPM install test
# noqa 303
shell: >
sed -i -e 's%--postinstall%%'
{{ build_repo_dir }}/DLRN/scripts/build_rpm.sh
@ -191,7 +192,7 @@
change_id: "{{ lookup('env', 'GERRIT_CHANGE_ID') }}"
branch: "{{ lookup('env', 'GERRIT_BRANCH') }}"
patchset_rev: "{{ lookup('env', 'GERRIT_PATCHSET_REVISION') }}"
when: gerrit_host != ""
when: gerrit_host != "" # noqa 602
- name: Add Jenkins changes to the change list
set_fact:
@ -203,7 +204,7 @@
host: "{{ lookup('env', 'ZUUL_URL')|default('https://review.opendev.org', true) }}"
changes: "{{ lookup('env', 'ZUUL_CHANGES') }}"
branch: "{{ lookup('env', 'ZUUL_BRANCH') }}"
when: zuul_changes != ""
when: zuul_changes != "" # noqa 602
- name: Add Zuul changes to the change list
set_fact:
@ -261,9 +262,11 @@
chdir: '{{ build_repo_dir }}'
- name: Compress the repo
# noqa 303
command: 'tar czf {{ artg_compressed_gating_repo }} gating_repo'
args:
chdir: '{{ build_repo_dir }}'
- name: Trigger repo injection for quickstart
set_fact:
compressed_gating_repo: "{{ artg_compressed_gating_repo }}"

View File

@ -1,3 +1,21 @@
---
dependencies:
- common
galaxy_info:
author: Red Hat
description: |
This Ansible role contains defaults for variables used in more than 2 roles
throughout the tripleo-quickstart-extras repository. All other roles in this
repository depend on this one.
license: Apache
platforms:
- name: CentOS
versions:
- 7
- 8
- name: EL
versions:
- 7
- 8
min_ansible_version: 2.8

View File

@ -5,6 +5,8 @@ skipdist = True
[testenv]
usedevelop = True
setenv =
ANSIBLE_FORCE_COLOR=1
passenv =
ANSIBLE_*
CURL_CA_BUNDLE