6fd5393cbd
Currently we have a few possible places for building package in the job. It requires logic change in order to differentiate between injection cases. build-test-packages role can run and not to build anything bc of various reasons, in this case we need to avoid running install-built-repo role, that's why we set compressed_gating_repo to empty string and check in every case if it's empty or not. If compressed_gating_repo is emptry - we didn't built *last* time anything, so nothing should run. Change-Id: Ib19addc66678804abb86f36006fb35f3f1f1d471
204 lines
6.0 KiB
YAML
204 lines
6.0 KiB
YAML
---
|
|
|
|
- name: Ensure DLRN package dependencies
|
|
become: yes
|
|
yum: name={{ item }} state=present
|
|
with_items:
|
|
- createrepo
|
|
- gcc
|
|
- git
|
|
- libffi-devel
|
|
- mock
|
|
- openssl-devel
|
|
- python-virtualenv
|
|
- rpm-build
|
|
- sqlite
|
|
- redhat-rpm-config
|
|
- rpmdevtools
|
|
|
|
- name: Create mock group
|
|
become: yes
|
|
group: name=mock state=present
|
|
|
|
- name: Add user to mock group
|
|
become: yes
|
|
user:
|
|
name: '{{ ansible_user }}'
|
|
groups: mock
|
|
append: yes
|
|
|
|
- name: Remove data files from previous runs
|
|
file:
|
|
path: '{{ build_repo_dir }}/DLRN'
|
|
state: absent
|
|
when: not dlrn_pre_installed|bool
|
|
|
|
- name: Ensure DLRN dir is present
|
|
file:
|
|
path: '{{ build_repo_dir }}/DLRN/'
|
|
state: directory
|
|
|
|
- name: drop in the templated version of projects.ini
|
|
template:
|
|
src: projects.ini.j2
|
|
dest: '{{ build_repo_dir }}/DLRN/projects.ini'
|
|
|
|
- name: Install and update pip
|
|
pip:
|
|
name: pip
|
|
virtualenv: "{{ build_repo_dir }}/dlrn-venv"
|
|
state: latest
|
|
extra_args: --upgrade
|
|
|
|
- name: Pip install DLRN
|
|
pip:
|
|
name: dlrn
|
|
virtualenv: "{{ build_repo_dir }}/dlrn-venv"
|
|
state: latest
|
|
when: not dlrn_pre_installed|bool
|
|
|
|
- name: Pip install pre-installed DLRN
|
|
shell: >
|
|
source {{ build_repo_dir }}/dlrn-venv/bin/activate;
|
|
pip install -r requirements.txt;
|
|
python setup.py install;
|
|
args:
|
|
chdir: '{{ build_repo_dir }}/DLRN'
|
|
when: dlrn_pre_installed|bool
|
|
|
|
- name: copy the DLRN scripts in the virtualenv to the scripts dir
|
|
shell: "/usr/bin/cp -Rv {{ build_repo_dir }}/dlrn-venv/share/dlrn/scripts {{ build_repo_dir }}/DLRN/"
|
|
|
|
- name: Fetch local rdoinfo copy
|
|
git:
|
|
repo: '{{ artg_rdoinfo_repo_url }}'
|
|
dest: '{{ build_repo_dir }}/DLRN/rdoinfo'
|
|
version: 'master'
|
|
|
|
- name: Use local CentOS mirror if available
|
|
shell: >
|
|
gawk '{ print $0 }; /^# repos$/ { exit }' {{ build_repo_dir }}/DLRN/scripts/centos.cfg
|
|
> {{ build_repo_dir }}/DLRN/scripts/centos-local.cfg;
|
|
cat /etc/yum.repos.d/quickstart-centos-*.repo >> {{ build_repo_dir }}/DLRN/scripts/centos-local.cfg;
|
|
find /etc/yum.repos.d -name "delorean*repo" ! -name "delorean*build-deps.repo" -exec cat {} \; >> {{ build_repo_dir }}/DLRN/scripts/centos-local.cfg;
|
|
find /etc/yum.repos.d -name "delorean*build-deps.repo" -exec sed 's/enabled=.*/enabled=1/g' {} \; >> {{ build_repo_dir }}/DLRN/scripts/centos-local.cfg;
|
|
echo '"""' >> {{ build_repo_dir }}/DLRN/scripts/centos-local.cfg;
|
|
mkdir -p /tmp/fake-dlrn-repos/current;
|
|
touch /tmp/fake-dlrn-repos/delorean-deps.repo;
|
|
touch /tmp/fake-dlrn-repos/current/delorean.repo;
|
|
when: dlrn_use_local_mirrors|bool
|
|
|
|
- name: Use custom target for DLRN
|
|
lineinfile:
|
|
dest: '{{ build_repo_dir }}/DLRN/projects.ini'
|
|
regexp: 'target=.*'
|
|
line: 'target=centos-local'
|
|
when: dlrn_use_local_mirrors|bool
|
|
|
|
# FIXME(jpena): once DLRN 0.8.0 is released, we can remove this
|
|
- name: Check if DLRN/scripts/build_rpm.sh exists
|
|
stat:
|
|
path: '{{ build_repo_dir }}/DLRN/scripts/build_rpm.sh'
|
|
register: old_dlrn
|
|
|
|
- name: Remove DLRN RPM install test
|
|
shell: >
|
|
sed -i -e 's%--postinstall%%'
|
|
{{ build_repo_dir }}/DLRN/scripts/build_rpm.sh
|
|
when: old_dlrn.stat.exists
|
|
|
|
- name: get env variables for changes and default change list
|
|
set_fact:
|
|
gerrit_host: "{{ lookup('env', 'GERRIT_HOST') }}"
|
|
zuul_changes: "{{ lookup('env', 'ZUUL_CHANGES') }}"
|
|
artg_change_list: "{{ artg_change_list|default([]) }}"
|
|
cacheable: true
|
|
|
|
- name: Parse Jenkins changes
|
|
jenkins_deps:
|
|
host: "{{ lookup('env', 'GERRIT_HOST') }}"
|
|
change_id: "{{ lookup('env', 'GERRIT_CHANGE_ID') }}"
|
|
branch: "{{ lookup('env', 'GERRIT_BRANCH') }}"
|
|
patchset_rev: "{{ lookup('env', 'GERRIT_PATCHSET_REVISION') }}"
|
|
when: gerrit_host != ""
|
|
|
|
- name: Add Jenkins changes to the change list
|
|
set_fact:
|
|
artg_change_list: "{{ artg_change_list|union(jenkins_change_list|default([])) }}"
|
|
cacheable: true
|
|
|
|
- name: Parse Zuul changes
|
|
zuul_deps:
|
|
host: "{{ lookup('env', 'ZUUL_URL')|default('https://review.openstack.org', true) }}"
|
|
changes: "{{ lookup('env', 'ZUUL_CHANGES') }}"
|
|
branch: "{{ lookup('env', 'ZUUL_BRANCH') }}"
|
|
when: zuul_changes != ""
|
|
|
|
- name: Add Zuul changes to the change list
|
|
set_fact:
|
|
artg_change_list: "{{ artg_change_list|union(zuul_change_list|default([])) }}"
|
|
cacheable: true
|
|
|
|
- name: Clone and build the specific DLRN projects
|
|
include: dlrn-build.yml artg_change={{ item }}
|
|
with_items: '{{ artg_change_list|default([]) }}'
|
|
when:
|
|
- item.project not in artg_skipped_projects
|
|
- release in item.branch
|
|
|
|
- block:
|
|
- name: Create a directory to hold the rpms
|
|
file:
|
|
path: '{{ build_repo_dir }}/gating_repo'
|
|
state: directory
|
|
|
|
- name: Copy the generated rpms
|
|
shell: >
|
|
set -o pipefail &&
|
|
rm -rf {{ build_repo_dir }}/gating_repo/*;
|
|
find {{ build_repo_dir }}/DLRN/data/repos -type f -name '*.rpm' -print0 | xargs -0 cp -t {{ build_repo_dir }}/gating_repo;
|
|
|
|
- name: Run createrepo on generated rpms
|
|
shell: 'createrepo gating_repo'
|
|
args:
|
|
chdir: '{{ build_repo_dir }}'
|
|
|
|
- name: Compress the repo
|
|
shell: 'tar czf {{ artg_compressed_gating_repo }} gating_repo'
|
|
args:
|
|
chdir: '{{ build_repo_dir }}'
|
|
when:
|
|
- repo_built is defined
|
|
- repo_built.skipped is not defined
|
|
|
|
- name: Clean up
|
|
file:
|
|
path: '{{ item }}'
|
|
state: absent
|
|
with_items:
|
|
- '{{ build_repo_dir }}/dlrn-venv'
|
|
- '{{ build_repo_dir }}/gating_repo'
|
|
when: dlrn_cleanup|bool
|
|
|
|
- name: Clean up DLRN if it was cloned by the playbook
|
|
file:
|
|
path: '{{ build_repo_dir }}/DLRN'
|
|
state: absent
|
|
when:
|
|
- not dlrn_pre_installed|bool
|
|
- dlrn_cleanup|bool
|
|
|
|
- name: Trigger repo injection for quickstart
|
|
set_fact:
|
|
compressed_gating_repo: "{{ artg_compressed_gating_repo }}"
|
|
cacheable: true
|
|
when:
|
|
- repo_built is defined
|
|
- repo_built.skipped is not defined
|
|
|
|
- name: Don't trigger repo injection if nothing is built
|
|
set_fact:
|
|
compressed_gating_repo: ""
|
|
cacheable: true
|
|
when: repo_built is not defined or repo_built.skipped is defined
|