Skip to content

Commit

Permalink
Add GCP flavor of Ansible
Browse files Browse the repository at this point in the history
Signed-off-by: peterdeme <[email protected]>
  • Loading branch information
peterdeme committed Feb 15, 2024
1 parent b934221 commit c069fd1
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 16 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
max-parallel: 2 # ECR has pretty aggressive rate limiting 😪
matrix:
folder: [base, aws]
folder: [base, aws, gcp]
arch: [amd64, arm64]
env:
IMAGE_NAME: ansible-test-${{ matrix.folder }}-${{ matrix.arch }}:${{ github.sha }}
Expand Down Expand Up @@ -54,3 +54,7 @@ jobs:
if [ "${{ matrix.folder }}" == "aws" ]; then
docker run --rm ${{ env.IMAGE_NAME }} sh -c "python3 -c \"import boto3; print(boto3.__version__)\""
fi
if [ "${{ matrix.folder }}" == "gcp" ]; then
docker run --rm ${{ env.IMAGE_NAME }} sh -c "python3 -c \"import google.auth; print(google.auth.__version__)\""
fi
47 changes: 44 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ jobs:
with:
platforms: linux/arm64

- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand Down Expand Up @@ -110,3 +107,47 @@ jobs:
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }}
tags: |
${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_AWS }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
gcp:
needs: base
name: Build and deploy the alpine base GCP image
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@main

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/arm64

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 900

- name: Install latest AWS CLI
id: install-aws-cli
uses: unfor19/install-aws-cli-action@v1

- name: Login to Amazon ECR
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${REPOSITORY_PATH}
env:
REPOSITORY_PATH: ${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_GCP }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push the image
uses: docker/build-push-action@v5
with:
build-args: |
REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}
context: aws
platforms: linux/amd64,linux/arm64
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }}
tags: |
${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_GCP }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
11 changes: 0 additions & 11 deletions .github/workflows/get_aws_address.yml

This file was deleted.

8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ to use `public.ecr.aws/spacelift/runner-ansible` as the runner image for the sta
The image is pushed to the `public.ecr.aws/spacelift/runner-ansible` public repository. It is also pushed to the
`ghcr.io/spacelift-io/runner-ansible` repository as a backup in case of issues with ECR.

Altogether we have 3 flavors of the image:

- `public.ecr.aws/spacelift/runner-ansible` - built on top of the [Spacelift Terraform runner image](https://github.com/spacelift-io/runner-terraform), with Ansible installed.
- `public.ecr.aws/spacelift/runner-ansible-aws` - built on top of `runner-ansible`, with `boto3` installed.
- `public.ecr.aws/spacelift/runner-ansible-gcp` - built on top of `runner-ansible`, with `google-auth` installed.

## Branch Model

This repository uses two main branches:

- `main` - contains the production version of the runner image.
- `future` - used to test development changes.

Pushes to main deploy to the latest tag, whereas pushes to future deploy to the future tag. This
Pushes to main deploy to the `latest` tag, whereas pushes to future deploy to the `future` tag. This
means that to use the development version you can use the `public.ecr.aws/spacelift/runner-ansible:future` image.

## Development
Expand Down
5 changes: 5 additions & 0 deletions gcp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARG REPOSITORY_BASE_PATH

FROM ${REPOSITORY_BASE_PATH}:latest

RUN pip install requests google-auth

0 comments on commit c069fd1

Please sign in to comment.