Skip to content

Commit c3882e0

Browse files
author
Kevin Jayne
authored
feat: Kevin build Ansible harness image (#207)
* initialize harness ansible build * add python version to build matrix * copy harness into python base with ansible installed * use python alpine for ansible base image * update ansible and python matrix versions * use major and minor (w/o patch) for tagging
1 parent 502a38d commit c3882e0

File tree

4 files changed

+113
-2
lines changed

4 files changed

+113
-2
lines changed

.github/workflows/publish-harness.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,83 @@ jobs:
173173
HARNESS_BASE_IMAGE_REPO=ghcr.io/pluralsh/stackrun-harness-base
174174
HARNESS_BASE_IMAGE_TAG=${{ needs.publish-harness-base.outputs.version }}
175175
176+
publish-harness-ansible:
177+
name: Build and push harness ansible container
178+
runs-on: ubuntu-20.04
179+
needs: [publish-harness-base]
180+
strategy:
181+
matrix:
182+
versions:
183+
- ansible: '4.10.0'
184+
python: '3.9'
185+
tag: '4.10'
186+
- ansible: '5.7.0'
187+
python: '3.10'
188+
tag: '5.7'
189+
- ansible: '6.7.0'
190+
python: '3.10'
191+
tag: '6.7'
192+
- ansible: '7.7.0'
193+
python: '3.11'
194+
tag: '7.7'
195+
- ansible: '8.7.0'
196+
python: '3.11'
197+
tag: '8.7'
198+
- ansible: '9.0.0'
199+
python: '3.12'
200+
tag: '9.0'
201+
- ansible: '10.0.0'
202+
python: '3.12'
203+
tag: '10.0'
204+
permissions:
205+
contents: write
206+
discussions: write
207+
pull-requests: write
208+
packages: write
209+
steps:
210+
- name: Checkout
211+
uses: actions/checkout@v4
212+
with:
213+
fetch-depth: 0
214+
- name: Docker meta
215+
id: meta
216+
uses: docker/metadata-action@v5
217+
with:
218+
images: |
219+
ghcr.io/pluralsh/harness
220+
docker.io/pluralsh/harness
221+
tags: |
222+
type=semver,pattern={{version}},suffix=-ansible-${{ matrix.versions.tag }},priority=1000
223+
type=sha,suffix=-ansible-${{ matrix.versions.tag }},priority=800
224+
type=ref,event=pr,suffix=-ansible-${{ matrix.versions.tag }},priority=600
225+
- name: Set up QEMU
226+
uses: docker/setup-qemu-action@v3
227+
- name: Set up Docker Buildx
228+
uses: docker/setup-buildx-action@v3
229+
- name: Login to GHCR
230+
uses: docker/login-action@v3
231+
with:
232+
registry: ghcr.io
233+
username: ${{ github.repository_owner }}
234+
password: ${{ secrets.GITHUB_TOKEN }}
235+
- name: Login to Docker
236+
uses: docker/login-action@v3
237+
with:
238+
username: mjgpluralsh
239+
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
240+
- name: Build and push
241+
uses: docker/build-push-action@v5
242+
with:
243+
context: "."
244+
file: "./dockerfiles/harness/ansible.Dockerfile"
245+
push: true
246+
tags: ${{ steps.meta.outputs.tags }}
247+
labels: ${{ steps.meta.outputs.labels }}
248+
platforms: linux/amd64,linux/arm64
249+
cache-from: type=gha
250+
cache-to: type=gha,mode=max
251+
build-args: |
252+
ANSIBLE_VERSION=${{ matrix.versions.ansible }}
253+
PYTHON_VERSION=${{ matrix.versions.python }}
254+
HARNESS_BASE_IMAGE_REPO=ghcr.io/pluralsh/stackrun-harness-base
255+
HARNESS_BASE_IMAGE_TAG=${{ needs.publish-harness-base.outputs.version }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
ARG HARNESS_BASE_IMAGE_TAG=latest
2+
ARG HARNESS_BASE_IMAGE_REPO=harness-base
3+
ARG HARNESS_BASE_IMAGE=$HARNESS_BASE_IMAGE_REPO:$HARNESS_BASE_IMAGE_TAG
4+
5+
ARG PYTHON_VERSION=3.10
6+
7+
# Use harness base image
8+
FROM ${HARNESS_BASE_IMAGE} as harness
9+
10+
# Build Ansible from Python Image
11+
FROM python:${PYTHON_VERSION}-alpine as final
12+
13+
# Copy Harness bin from the Harness Image
14+
COPY --from=harness /harness /usr/local/bin/harness
15+
16+
# Install build dependencies, Ansible, and openssh-client
17+
ARG ANSIBLE_VERSION=9.0.0
18+
RUN apk add --no-cache --virtual .build-deps \
19+
gcc \
20+
musl-dev \
21+
libffi-dev \
22+
openssl-dev \
23+
make \
24+
build-base && \
25+
pip install --no-cache-dir ansible==${ANSIBLE_VERSION} && \
26+
apk add --no-cache openssh-client && \
27+
apk del .build-deps
28+
29+
ARG PYTHON_VERSION

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ require (
3939
k8s.io/apimachinery v0.29.3
4040
k8s.io/cli-runtime v0.29.2
4141
k8s.io/client-go v0.29.2
42+
k8s.io/klog v1.0.0
4243
k8s.io/klog/v2 v2.110.1
4344
k8s.io/kubectl v0.29.2
4445
layeh.com/gopher-luar v1.0.11

go.sum

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3I
207207
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
208208
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
209209
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
210+
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
210211
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
211212
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
212213
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
@@ -526,8 +527,6 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
526527
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
527528
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
528529
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
529-
github.com/pluralsh/console-client-go v0.5.12 h1:JuTxEXK1B60sE5yUMfgfn8/aus5i459MFMZs8FnX/LA=
530-
github.com/pluralsh/console-client-go v0.5.12/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
531530
github.com/pluralsh/console-client-go v0.5.13 h1:HOmkho5aaU42f6PkSb+BUFjhCJKnL5jceLZiT16HMBE=
532531
github.com/pluralsh/console-client-go v0.5.13/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
533532
github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E=
@@ -1096,6 +1095,8 @@ k8s.io/client-go v0.29.2 h1:FEg85el1TeZp+/vYJM7hkDlSTFZ+c5nnK44DJ4FyoRg=
10961095
k8s.io/client-go v0.29.2/go.mod h1:knlvFZE58VpqbQpJNbCbctTVXcd35mMyAAwBdpt4jrA=
10971096
k8s.io/component-base v0.29.2 h1:lpiLyuvPA9yV1aQwGLENYyK7n/8t6l3nn3zAtFTJYe8=
10981097
k8s.io/component-base v0.29.2/go.mod h1:BfB3SLrefbZXiBfbM+2H1dlat21Uewg/5qtKOl8degM=
1098+
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
1099+
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
10991100
k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0=
11001101
k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo=
11011102
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780=

0 commit comments

Comments
 (0)