From 97e5072595ae5db7513ce07bea98be80e14e87a5 Mon Sep 17 00:00:00 2001 From: Jason King Date: Fri, 29 Sep 2023 11:22:12 -0700 Subject: [PATCH] Added build container workflow --- .github/workflows/release.yml | 64 +++++++++++++++++++++++++++++++++++ Dockerfile | 28 +++++++++++++++ requirements.txt | 16 +++++++++ requirements.yml | 9 +++++ 4 files changed, 117 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 Dockerfile create mode 100644 requirements.txt create mode 100644 requirements.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7ffb182 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,64 @@ +--- +name: Release +on: + release: + types: + - created + workflow_dispatch: + inputs: + tag: + description: 'Image Tag' + required: true + type: string + default: 'latest' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}/mdd + + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GHCR_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + if: ${{ ! inputs.tag }} + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + file: Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Docker image + if: ${{ inputs.tag }} + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + file: Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.tag }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6064107 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM --platform=linux/amd64 ubuntu:20.04 + +ARG build_date=unspecified + +# workspace location +ARG WORKSPACE +ENV WORKSPACE ${WORKSPACE:-/ansible} +ENV ANSIBLE_COLLECTIONS_PATH / + +COPY requirements.txt /tmp/requirements.txt +COPY requirements.yml /tmp/requirements.yml +USER root +RUN mkdir /root/.ssh && bash -c 'echo -e "Host *\n KexAlgorithms +diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1" > /root/.ssh/config' +RUN mkdir /ansible_collections && chmod 777 /ansible_collections +RUN apt-get update && \ + apt-get install -y python3.8 python3-pip sshpass git && \ + pip3 install --upgrade --no-cache-dir setuptools pip && \ + echo "===> Installing PIP Requirements <===" && \ + pip3 install --no-cache -r /tmp/requirements.txt && \ + echo "===> Installing Ansible Collections <===" && \ + rm -rf /var/lib/apt/lists/* && \ + ansible-galaxy collection install -r /tmp/requirements.yml + +ENV ANSIBLE_HOST_KEY_CHECKING=false \ + ANSIBLE_RETRY_FILES_ENABLED=false \ + ANSIBLE_SSH_PIPELINING=true + +WORKDIR ${WORKSPACE} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..6a5fee9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,16 @@ +ansible==4.5.0 +virl2_client==2.6.0 +netaddr +pynetbox +jsonschema +ipaddress +paramiko +genie +pyats +jmespath +passlib +botocore +boto3 +nso-oc==2.79.4 +networkx +scipy diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..7b13d57 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,9 @@ +collections: + - name: https://github.com/ciscodevnet/ansible-cml.git + type: git + - source: . + type: dir + - name: https://github.com/model-driven-devops/ansible-nso.git + type: git + - name: amazon.aws + source: https://galaxy.ansible.com