Deploy OpenShift InfraRed files from Tobiko InfraRed plugin

Change-Id: I2a7d09d71a815c052e8a5e8dbb481d35904df234
This commit is contained in:
Federico Ressi 2022-01-18 16:05:34 +01:00
parent b565e89f22
commit f48fd21194
6 changed files with 125 additions and 71 deletions

View File

@ -86,8 +86,8 @@ services:
infrared:
build:
context: infrared_plugin
target: tobiko-infrared
hostname: tobiko-infrared
target: run
hostname: infrared
environment:
IR_EXTRA_ARGS: --tobiko-src-dir /tobiko
volumes:

View File

@ -1,6 +1,7 @@
FROM centos:8 as base
ENV TOBIKO_INFRARED_DIR /tobiko-infrared
ENV OPENSHIFT_INFRARED_URL=http://code.engineering.redhat.com/gerrit/openshift-ir-plugin.git
ENV WHEEL_DIR /wheel
ENV REPORT_DIR /report
ENV IR_HOME /infrared
@ -10,43 +11,41 @@ ENV IR_EXTRA_ARGS ""
RUN dnf install -y git python3 rsync which
RUN python3 -m pip install --upgrade wheel setuptools pip
FROM base as source
# Populate tobiko-infrared source dir
ADD . ${TOBIKO_INFRARED_DIR}
FROM source as build
# Build Infrared wheel files
RUN python3 -m pip wheel -w ${WHEEL_DIR} -r ${TOBIKO_INFRARED_DIR}/requirements.txt
# Creates directories and use infrared home dir as home
RUN mkdir -p "${IR_HOME}" "${REPORT_DIR}"
WORKDIR "${IR_HOME}"
FROM base as install
# Install wheels
RUN mkdir -p ${WHEEL_DIR}
COPY --from=build ${WHEEL_DIR} ${WHEEL_DIR}
RUN pip install ${WHEEL_DIR}/*.whl
ADD requirements.txt .
RUN pip install -r requirements.txt
FROM source as tobiko-infrared
# Creates directories
RUN mkdir -p "${IR_HOME}" "${REPORT_DIR}"
FROM base as configure
# Copy python pacakges
COPY --from=install /usr/local /usr/local/
# Add tobiko plugin
# Add optional plugins
RUN infrared plugin add "${OPENSHIFT_INFRARED_URL}" || true
# Add Tobiko plugin
ADD . "${TOBIKO_INFRARED_DIR}"
RUN infrared plugin add "${TOBIKO_INFRARED_DIR}"
FROM base as run
# Copy python pacakges
COPY --from=install /usr/local /usr/local/
# Copy infrared home dir
COPY --from=configure "${IR_HOME}" "${IR_HOME}"
# Create initial workspace
RUN infrared workspace checkout --create default
# Use infrared home dir as home
WORKDIR ${IR_HOME}
# Run Tobiko Infrared plugin
CMD infrared tobiko --collect-dir "${REPORT_DIR}" ${IR_EXTRA_ARGS}

View File

@ -101,6 +101,26 @@ subparsers:
required: yes
ansible_variable: tobiko_src_dir
default: '{{ inventory_dir }}/src/tobiko'
openshift-ir-src-dir:
type: Value
help: Local directory where OpenShift InfraRed scripts are deployed from0
ansible_variable: openshift_infrared_src_dir
openshift-ir-dir:
type: Value
help: Remote directory where OpenShift InfraRed scripts are deployed to
ansible_variable: openshift_infrared_dir
openshift-ir-repo:
type: Value
help: Git URL from where to download OpenShift InfraRed files
ansible_variable: openshift_infrared_git_repo
openshift-ir-remote:
type: Value
help: Git remote name to be used for checking out OpenShift InfraRed files
ansible_variable: openshift_infrared_git_remote
openshift-ir-refspec:
type: Value
help: Git refspect to be used for checking out OpenShift InfraRed files
ansible_variable: openshift_infrared_git_refspec
- title: Configure stage
options:

View File

@ -8,14 +8,15 @@
- (deploy_clean | bool)
- name: "ensure target directory exists: '{{ deploy_dir }}'"
- when: (deploy_git_refspec | length) > 0
block:
- name: "ensure target directory exists: '{{ deploy_dir }}'"
file:
path: "{{ deploy_dir | realpath }}"
state: directory
register: create_dest_dir
- name: "checkout files from '{{ deploy_git_repo }}[{{ deploy_git_refspec }}]' to '{{ deploy_dir }}'"
- name: "checkout files from '{{ deploy_git_repo }}[{{ deploy_git_refspec }}]' to '{{ deploy_dir }}'"
git:
dest: '{{ deploy_dir }}'
repo: '{{ deploy_git_repo }}'
@ -24,11 +25,26 @@
remote: '{{ deploy_git_remote or omit }}'
force: yes
register: checkout_files
when:
- (deploy_git_refspec | length) > 0
- name: "copy '{{ deploy_src_dir }}' to '{{ deploy_dir }}'"
- when:
- (deploy_src_dir | length) > 0
- checkout_files is skipped
block:
- name: "check source directory exists"
stat:
path: '{{ deploy_src_dir }}'
register: deploy_src_dir_stat
- when: deploy_src_dir_stat.stat.exists
block:
- name: "ensure target directory exists: '{{ deploy_dir }}'"
file:
path: "{{ deploy_dir | realpath }}"
state: directory
register: create_dest_dir
- name: "copy '{{ deploy_src_dir }}' to '{{ deploy_dir }}'"
synchronize:
src: "{{ deploy_src_dir | realpath }}/."
dest: "{{ deploy_dir | realpath }}"
@ -37,28 +53,16 @@
rsync_opts:
- '--exclude-from={{ deploy_src_dir | realpath }}/.gitignore'
register: copy_src_dir
when:
- (deploy_src_dir | length) > 0
- checkout_files is skipped
- name: "get last change details for '{{ deploy_dir }}'" # noqa 303
- when: (checkout_files is not skipped) or (copy_src_dir is not skipped)
block:
- name: "get last change details for '{{ deploy_dir }}'" # noqa 303
command:
chdir: "{{ deploy_dir }}"
cmd: git log -n 1
changed_when: no
register: get_git_log
- name: "show last change details"
- name: "show last change details"
debug: var=get_git_log.stdout_lines
# we install validations-common here since it's
# packaged by rhel-osp
- name: install validations-common
ignore_errors: yes
become: true
package:
name: validations-common
state: present

View File

@ -6,3 +6,16 @@ test_git_refspec: ''
tobiko_git_remote: ''
test_git_remote: ''
stacks_cleanup: false
# Local directory where OpenShift InfraRed scripts are deployed from
openshift_infrared_src_dir: '{{ playbook_dir }}/../openshift'
# Remote directory where OpenShift InfraRed scripts are deployed to
openshift_infrared_dir: '{{ ansible_user_dir }}/src/openshift-ir-plugin'
# Remote Git repo from where OpenShift InfraRed scripts are deployed from
openshift_infrared_git_repo:
'http://code.engineering.redhat.com/gerrit/openshift-ir-plugin.git'
openshift_infrared_git_refspec: ''
openshift_infrared_git_remote: ''

View File

@ -36,6 +36,24 @@
deploy_git_remote: '{{ test_git_remote }}'
when: test_dir != tobiko_dir
- name: deploy OpenShift InfraRed plugin files
include_role: name=tobiko-ir-deploy
vars:
deploy_dir: '{{ openshift_infrared_dir | realpath }}'
deploy_src_dir: '{{ openshift_infrared_src_dir | realpath }}'
deploy_git_repo: '{{ openshift_infrared_git_repo }}'
deploy_git_refspec: '{{ openshift_infrared_git_refspec }}'
deploy_git_remote: '{{ openshift_infrared_git_remote }}'
# validations-common here since it's packaged by rhel-osp
- name: install validations-common
ignore_errors: yes
become: true
package:
name: validations-common
state: present
- name: "initialize test execution"
include_role: name=tobiko-configure