Skip to content

Commit

Permalink
Merge pull request #26 from spacelift-io/install-flavorful-collections
Browse files Browse the repository at this point in the history
feat: install flavorful collections
  • Loading branch information
Apollorion authored Mar 10, 2025
2 parents d60053d + 3740943 commit 1af7cfd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ jobs:
docker run --rm ${{ env.IMAGE }} ansible-playbook --version
docker run --rm ${{ env.IMAGE }} ansible-galaxy --version
docker run --rm ${{ env.IMAGE }} ansible-runner --version
docker run --rm ${{ env.IMAGE }} ansible-galaxy collection list
- name: Test aws flavor
if: matrix.target == 'aws'
Expand Down
25 changes: 23 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
FROM python:3.12-alpine AS ansible
ARG ANSIBLE_VERSION=10.0
ENV ANSIBLE_COLLECTIONS_PATH=/usr/share/ansible/collections
ENV ANSIBLE_ROLES_PATH=/usr/share/ansible/roles
RUN apk -U upgrade --available &&\
# Required to install ansible pip package, bear in mind to remove those build deps at the end of this RUN directive
apk add --virtual=build --no-cache --update gcc musl-dev libffi-dev openssl-dev &&\
# Add here package mandatory to be able to run ansible
apk add --no-cache openssh-client ca-certificates&&\
pip install --no-cache-dir --upgrade pip &&\
pip install --no-cache-dir ansible==${ANSIBLE_VERSION}.* ansible-runner~=2.4 &&\
mkdir -p /usr/share/ansible/collections &&\
mkdir -p /usr/share/ansible/roles &&\
# Cleanup package manager cache and remove build deps
apk del build &&\
rm -rf /var/cache/apk/*
Expand All @@ -17,16 +21,33 @@ FROM ansible AS base
USER 1983

FROM ansible AS gcp
RUN pip install --no-cache-dir requests==2.* google-auth==2.*
RUN pip install --no-cache-dir requests==2.* google-auth==2.* && \
ansible-galaxy collection install 'google.cloud:>=1.5.1,<2.0.0' &&\
# Reset ansible permissions after installing newer collections \
rm -rf /ansible &&\
mkdir -p /ansible &&\
chown 1983:1983 /ansible
USER 1983

FROM ansible AS aws
RUN pip install --no-cache-dir boto3==1.*
RUN pip install --no-cache-dir boto3==1.* &&\
ansible-galaxy collection install 'amazon.aws:>=9.2.0,<10.0.0' &&\
# Reset ansible permissions after installing newer collections \
rm -rf /ansible &&\
mkdir -p /ansible &&\
chown 1983:1983 /ansible
USER 1983

FROM ansible AS azure
RUN apk add --virtual=build --no-cache gcc musl-dev linux-headers &&\
# Install azure collection
ansible-galaxy collection install 'azure.azcollection:>=3.2.0,<4.0.0' &&\
pip install --no-cache-dir -r /usr/share/ansible/collections/ansible_collections/azure/azcollection/requirements.txt &&\
pip install --no-cache-dir azure-cli==2.* &&\
# Reset ansible permissions after installing newer collections \
rm -rf /ansible &&\
mkdir -p /ansible &&\
chown 1983:1983 /ansible &&\
# Cleanup package manager cache and remove build deps
apk del build &&\
rm -rf /var/cache/apk/*
Expand Down

0 comments on commit 1af7cfd

Please sign in to comment.