Skip to content

Commit 2798f84

Browse files
fabianvfasmacdo
authored andcommitted
Allow publishing of Ansible 2.9 and 2.11 images
Related to #5115 This PR introduces the Dockerfile and infrastructure to build Ansible 2.9 and Ansible 2.11 images side by side. This commit does not integrate these changes into CI, and therefore will need to be mered alongside a follow-up PR to intetgrate with GitHub actions. Co-authored-by: Austin Macdonald <[email protected]> Co-authored-by: Fabian von Feilitzsch <[email protected]> Signed-off-by: austin <[email protected]>
1 parent ff54fb4 commit 2798f84

File tree

10 files changed

+610
-5
lines changed

10 files changed

+610
-5
lines changed

.github/workflows/deploy-manual.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ jobs:
3232
with:
3333
fetch-depth: 1
3434

35-
- name: create tag
35+
# TODO(asmacdo) add 2.11-preview-base
36+
- name: create 2.9-base tag
3637
id: tag
3738
run: |
3839
set -e
40+
# TODO(asmacdo)
3941
IMG=quay.io/${{ github.repository_owner }}/ansible-operator-base
4042
TAG="${{ github.event.inputs.ansible_operator_base_tag }}"
4143
GIT_COMMIT=$(git rev-parse HEAD)
@@ -58,7 +60,8 @@ jobs:
5860
5961
# This change will be staged and committed in the PR pushed below.
6062
# The script below will fail if no change was made.
61-
- name: update ansible-operator base
63+
# TODO(asmacdo) add base of 2.11-preview
64+
- name: update base of ansible-operator
6265
id: update
6366
run: |
6467
set -ex
@@ -67,6 +70,7 @@ jobs:
6770
REF="${{ github.event.ref }}"
6871
echo ::set-output name=branch_name::"${REF##*/}"
6972
73+
# TODO(asmacdo) add base of 2.11-preview
7074
- name: create PR
7175
uses: peter-evans/create-pull-request@v3
7276
with:

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ jobs:
9898
- name: create tags
9999
id: tags
100100
run: |
101+
# TODO(asmacdo) github.repository_owner is wrong. This should be a quay account, `operator-framework` happens to be the same in
102+
# gh and quay.
101103
IMG=quay.io/${{ github.repository_owner }}/${{ matrix.id }}
102104
echo ::set-output name=tags::$(.github/workflows/get_image_tags.sh "$IMG" "v")
103105

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ build/scorecard-test build/scorecard-test-kuttl build/custom-scorecard-tests:
8282

8383
# Convenience wrapper for building all remotely hosted images.
8484
.PHONY: image-build
85-
IMAGE_TARGET_LIST = operator-sdk helm-operator ansible-operator scorecard-test scorecard-test-kuttl
85+
# TODO(asmacdo) add 2.11-preview
86+
IMAGE_TARGET_LIST = operator-sdk helm-operator ansible-operator/2.9 Oscorecard-test scorecard-test-kuttl
8687
image-build: $(foreach i,$(IMAGE_TARGET_LIST),image/$(i)) ## Build all images.
8788

8889
# Build an image.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Build the manager binary
2+
FROM --platform=$BUILDPLATFORM golang:1.16 as builder
3+
ARG TARGETARCH
4+
5+
WORKDIR /workspace
6+
# Copy the Go Modules manifests
7+
COPY go.mod go.mod
8+
COPY go.sum go.sum
9+
# cache deps before building and copying source so that we don't need to re-download as much
10+
# and so that source changes don't invalidate our downloaded layer
11+
RUN go mod download
12+
13+
# Copy the go source
14+
COPY . .
15+
16+
# Build
17+
RUN GOOS=linux GOARCH=$TARGETARCH make build/ansible-operator
18+
19+
# Final image.
20+
# TODO(asmacdo) update GH action to set this
21+
FROM quay.io/operator-framework/ansible-operator-2.11-preview-base:master-bc8aedd752afff8aed00e62901d69e737d3e370e
22+
23+
ENV HOME=/opt/ansible \
24+
USER_NAME=ansible \
25+
USER_UID=1001
26+
27+
# Ensure directory permissions are properly set
28+
RUN echo "${USER_NAME}:x:${USER_UID}:0:${USER_NAME} user:${HOME}:/sbin/nologin" >> /etc/passwd \
29+
&& mkdir -p ${HOME}/.ansible/tmp \
30+
&& chown -R ${USER_UID}:0 ${HOME} \
31+
&& chmod -R ug+rwx ${HOME}
32+
33+
WORKDIR ${HOME}
34+
USER ${USER_UID}
35+
36+
COPY --from=builder /workspace/build/ansible-operator /usr/local/bin/ansible-operator
37+
38+
ENTRYPOINT ["/tini", "--", "/usr/local/bin/ansible-operator", "run", "--watches-file=./watches.yaml"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
ansible-runner = "~=1.4.7"
8+
ansible-runner-http = "==1.0.0"
9+
ipaddress = "==1.0.23"
10+
openshift = "~=0.12.0"
11+
jmespath = "==0.10.0"
12+
# cryptography needs to be pinned to 3.3.2 as this is the last version
13+
# before its setup requires rust, which is not available via RPM in the
14+
# base image. This pin should be re-evaluated once the base image is updated.
15+
cryptography = "==3.3.2"
16+
ansible-core = "~=2.11.0"
17+
18+
[dev-packages]
19+
20+
[requires]
21+
python_version = "3.8"

images/ansible-operator/2.11/Pipfile.lock

Lines changed: 537 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.
File renamed without changes.

images/ansible-operator/base.Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
FROM registry.access.redhat.com/ubi8/ubi:8.4
66
ARG TARGETARCH
7+
ARG ANSIBLE_VERSION=2.9
78

89
# Label this image with the repo and commit that built it, for freshmaking purposes.
910
ARG GIT_COMMIT=devel
@@ -15,8 +16,9 @@ RUN mkdir -p /etc/ansible \
1516
&& echo 'roles_path = /opt/ansible/roles' >> /etc/ansible/ansible.cfg \
1617
&& echo 'library = /usr/share/ansible/openshift' >> /etc/ansible/ansible.cfg
1718

18-
# Copy python dependencies specs to be installed using Pipenv
19-
COPY Pipfile* ./
19+
20+
# Copy python dependencies (including ansible) to be installed using Pipenv
21+
COPY images/ansible-operator/${ANSIBLE_VERSION}/Pipfile* ./
2022
# Instruct pip(env) not to keep a cache of installed packages,
2123
# to install into the global site-packages and
2224
# to clear the pipenv cache as well

0 commit comments

Comments
 (0)