From e58743faade8117435eca9a085fc19ca0da870da Mon Sep 17 00:00:00 2001 From: Victoria Martinez de la Cruz Date: Tue, 29 Oct 2024 08:57:15 +0100 Subject: [PATCH] Add ansible-galaxy requirements to STO This change [0] in the ansible-operator introduced the removal of both k8s and operator_sdk.util from the base image. This means we now need to add the dependendencies ourselves when building STO. [0] https://github.com/operator-framework/operator-sdk/pull/6483 --- build/Dockerfile | 6 +++++- requirements.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 requirements.yml diff --git a/build/Dockerfile b/build/Dockerfile index fc30dd77..b053350b 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,4 +1,4 @@ -FROM quay.io/operator-framework/ansible-operator:v1.35.0 +FROM quay.io/operator-framework/ansible-operator:v1.31.0 # temporarily switch to root user to adjust image layers USER 0 @@ -12,6 +12,10 @@ RUN bash -c -- 'if [ "${NO_PROXY:-__ZZZZZ}" == "__ZZZZZ" ]; then echo "Applying # -- cleans up the cached data from dnf to keep the image as small as possible RUN dnf update -y --exclude=ansible* && dnf install -y python3-passlib python3-bcrypt && dnf clean all && rm -rf /var/cache/dnf +COPY requirements.yml ${HOME}/requirements.yml +RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \ + && chmod -R ug+rwx ${HOME}/.ansible + # switch back to user 1001 when running the base image (non-root) USER 1001 diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 00000000..e1d85237 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,41 @@ +# NOTE(vkmc) Great docs from https://github.com/jmazzitelli/kiali-operator/blob/master/requirements.yml +# +# This is the Ansible Galaxy requirements that need to be installed locally to be able to run +# the operator Ansible playbook locally. +# +# To install these into your local Ansible environment: +# ansible-galaxy collection install -r requirements.yml --force-with-deps +# +# Make sure these collections match that which is inside the Ansible Operator SDK base image. +# You can determine what collections are installed by looking in the base image like this: +# +# podman run \ +# -it --rm --entrypoint '' \ +# quay.io/openshift/origin-ansible-operator:4.13 \ +# ls /opt/ansible/.ansible/collections/ansible_collections +# +# To determine the version of a specific collection, look at the MANIFEST.json: +# +# podman run \ +# -it --rm --entrypoint '' \ +# quay.io/openshift/origin-ansible-operator:4.13 \ +# cat /opt/ansible/.ansible/collections/ansible_collections/kubernetes/core/MANIFEST.json | grep version +# +# It is best if you have the same version of Ansible installed locally as found in the base image. You can determine +# the version of Ansible in the base image via: +# +# podman run \ +# -it --rm --entrypoint '' \ +# quay.io/openshift/origin-ansible-operator:4.13 \ +# ansible --version +# +# To install that version locally, you can git clone the source via: +# git clone -b v --depth 1 https://github.com/ansible/ansible.git +# and then set up your environment via: +# source ./ansible/hacking/env-setup -q + +collections: +- name: kubernetes.core + version: 2.2.3 +- name: operator_sdk.util + version: 0.4.0