Skip to content

Commit

Permalink
ustream ci: Use infra scripts to build testing images
Browse files Browse the repository at this point in the history
As we do not use molecule features, using a Dockerfile and the
ansible-freeipa deployment roles is enough to create the container
testing images.

This patch removes the usage of molecule in favor of the custom
ansible-freeipa image building script, which allow us to have a similar
process for creating images both on the ustream CI, or on a developer's
environment.

Also, CentOS 7 is removed from the build script, as it in not possible
to run CentOS 7 containers with current versions of systemd.
  • Loading branch information
rjeffman committed Jul 20, 2024
1 parent ffb892a commit 07d4846
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 32 deletions.
28 changes: 14 additions & 14 deletions tests/azure/build-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,30 @@ schedules:
trigger: none

pool:
vmImage: 'ubuntu-20.04'
vmImage: 'ubuntu-22.04'

stages:

- stage: CentOS_7
dependsOn: []
jobs:
- template: templates/build_container.yml
parameters:
job_name_suffix: Centos7
container_name: centos-7
build_scenario_name: centos-7-build
# Currently, it's not possible to use CentOS container
#
# - stage: CentOS_7
# dependsOn: []
# jobs:
# - template: templates/build_container.yml
# parameters:
# job_name_suffix: Centos7
# container_name: centos-7
# build_scenario_name: centos-7-build

- stage: CentOS_8_Stream
dependsOn: []
jobs:
- template: templates/build_container.yml
parameters:
job_name_suffix: C8S
container_name: c8s
build_scenario_name: c8s-build
distro: c8s
# ansible-core 2.17+ cannot be used to deploy on CentOS 8 Stream.
ansible_core_version: "<2.17"

- stage: CentOS_9_Stream
dependsOn: []
Expand All @@ -40,7 +43,6 @@ stages:
parameters:
job_name_suffix: C9S
container_name: c9s
build_scenario_name: c9s-build

- stage: Fedora_Latest
dependsOn: []
Expand All @@ -49,7 +51,6 @@ stages:
parameters:
job_name_suffix: FedoraLatest
container_name: fedora-latest
build_scenario_name: fedora-latest-build

- stage: Fedora_Rawhide
dependsOn: []
Expand All @@ -58,4 +59,3 @@ stages:
parameters:
job_name_suffix: FedoraRawhide
container_name: fedora-rawhide
build_scenario_name: fedora-rawhide-build
40 changes: 22 additions & 18 deletions tests/azure/templates/build_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
parameters:
- name: job_name_suffix
type: string
- name: container_name
type: string
- name: build_scenario_name
- name: distro
type: string
- name: python_version
type: string
default: 3.x
- name: ansible_core_version
default: ""

jobs:
- job: BuildTestImage${{ parameters.job_name_suffix }}
Expand All @@ -18,26 +18,30 @@ jobs:
inputs:
versionSpec: '${{ parameters.python_version }}'

- script: python -m pip install --upgrade pip setuptools wheel ansible
- script: python -m pip install --upgrade pip "ansible-core${{ parameters.ansible_version }}"
retryCountOnTaskFailure: 5
displayName: Install tools

- script: pip install molecule-plugins[docker] "requests<2.29"
retryCountOnTaskFailure: 5
displayName: Install molecule
- script: ansible-galaxy collection install containers.podman
displayName: Install Ansible Galaxy collections

- script: molecule create -s ${{ parameters.build_scenario_name }}
retryCountOnTaskFailure: 5
displayName: Create test container
env:
ANSIBLE_LIBRARY: ./molecule
- script: infra/images/build.sh -I ${{ parameters.distro }}
displayName: Build ${{ parameters.distro }} base image

- script: |
docker stop ${{ parameters.build_scenario_name }}
docker commit ${{ parameters.build_scenario_name }} quay.io/ansible-freeipa/upstream-tests:${{ parameters.container_name }}
docker login -u="$QUAY_ROBOT_USERNAME" -p="$QUAY_ROBOT_TOKEN" quay.io
docker push quay.io/ansible-freeipa/upstream-tests:${{ parameters.container_name }}
displayName: Save image and upload
- script: podman login -u="$QUAY_ROBOT_USERNAME" -p="$QUAY_ROBOT_TOKEN" quay.io
displayName: Registry login
env:
# Secrets needs to be mapped as env vars to work properly
QUAY_ROBOT_TOKEN: $(QUAY_ROBOT_TOKEN)

- script: |
podman commit ansible-test
podman push ${{ parameters.distro }} quay.io/ansible-freeipa/upstream-tests:${{ parameters.distro }}-base
displayName: Save base image and upload
- script: infra/images/build.sh -c ansible-test -I ${{ parameters.distro }}
displayName: Install FreeIPA into the container

- script: |
podman push ${{ parameters.distro }} quay.io/ansible-freeipa/upstream-tests:${{ parameters.distro }}
displayName: Save FreeIPA image and upload

0 comments on commit 07d4846

Please sign in to comment.