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..97e461c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM --platform=linux/amd64 ubuntu:22.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 +COPY . /tmp/ansible-mdd + +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.10 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/Makefile b/Makefile index ad426fd..e5ed66a 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,9 @@ test: clean build $(VENV) $(TARBALL_NAME) ## Run Sanity Tests $(VENV_BIN)/pip uninstall -y ansible-base $(VENV_BIN)/pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check cd ./ansible_collections/ciscops/mdd && ../../../$(VENV_BIN)/ansible-test sanity --docker -v --color + $(RM) $(TARBALL_NAME) $(RM) -r ./ansible_collections + $(RM) -r ./venv clean: ## Clean $(RM) $(TARBALL_NAME) diff --git a/galaxy.yml b/galaxy.yml index 8b4e175..1bd5652 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -8,7 +8,7 @@ namespace: ciscops name: mdd # The version of the collection. Must be compatible with semantic versioning -version: 1.2.9 +version: 1.2.10 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md @@ -72,4 +72,7 @@ build_ignore: - '.env' - '.github' - 'tests/output/' -- 'ansible_collections/' +- 'ansible_collections' +- 'Dockerfile' +- 'requirements.txt' +- 'requirements.yml' diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..caec60c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,16 @@ +ansible==8.4.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..409e937 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,9 @@ +collections: + - name: https://github.com/ciscodevnet/ansible-cml.git + type: git + - source: /tmp/ansible-mdd + type: dir + - name: https://github.com/model-driven-devops/ansible-nso.git + type: git + - name: amazon.aws + source: https://galaxy.ansible.com