diff --git a/.github/workflows/container_build_base.yml b/.github/workflows/container_build_base.yml index 85fb9127b10..124512afa74 100644 --- a/.github/workflows/container_build_base.yml +++ b/.github/workflows/container_build_base.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: container_name: [base] - python_version: ["3.9", "3.10", "3.11"] + python_version: ["3.10", "3.11", "3.12"] include: - python_version: "3.11" container_tags: latest diff --git a/.github/workflows/container_build_dev.yml b/.github/workflows/container_build_dev.yml index 9ae483554d1..cdaf6a9b695 100644 --- a/.github/workflows/container_build_dev.yml +++ b/.github/workflows/container_build_dev.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: container_name: [dev] - python_version: ["3.9", "3.10", "3.11"] + python_version: ["3.10", "3.11", "3.12"] include: - python_version: "3.11" container_tags: latest diff --git a/.github/workflows/container_build_template.yml b/.github/workflows/container_build_template.yml index 017872f4965..e7e07122271 100644 --- a/.github/workflows/container_build_template.yml +++ b/.github/workflows/container_build_template.yml @@ -122,17 +122,13 @@ jobs: exit 1 fi - - name: Find ansible-core version 🔥 - id: find-ansible-core-version - run: | - ANSIBLE_CORE_VERSION=$(cat ansible_collections/arista/avd/requirements-dev.txt| grep ansible-core) - echo "ansible_core_version=$ANSIBLE_CORE_VERSION" >> $GITHUB_OUTPUT - - - name: Find ansible install location - id: find-ansible-install-location + - name: Find ansible and pyavd install location + id: find-install-locations run: | + PYAVD_INSTALL_LOCATION="git+https://github.com/${{ github.repository }}.git@${{ github.ref_name }}#subdirectory=python-avd" ANSIBLE_INSTALL_LOCATION="git+https://github.com/${{ github.repository }}.git#/ansible_collections/arista/avd/,${{ github.ref_name }}" echo "ansible_install_location=$ANSIBLE_INSTALL_LOCATION" >> $GITHUB_OUTPUT + echo "pyavd_install_location=$PYAVD_INSTALL_LOCATION" >> $GITHUB_OUTPUT # This check is temporarily deactivated, will be rewised in later PRs # @@ -176,8 +172,8 @@ jobs: env: FROM_IMAGE: ${{ steps.generate-from-parameters.outputs.from_image }} FROM_VARIANT: ${{ steps.generate-from-parameters.outputs.from_variant }} - ANSIBLE_INSTALL_LOCATION: ${{ steps.find-ansible-install-location.outputs.ansible_install_location }} - ANSIBLE_CORE_VERSION: ${{ steps.find-ansible-core-version.outputs.ansible_core_version }} + ANSIBLE_INSTALL_LOCATION: ${{ steps.find-install-locations.outputs.ansible_install_location }} + PYAVD_INSTALL_LOCATION: ${{ steps.find-install-locations.outputs.pyavd_install_location }} USERNAME: ${{ inputs.username }} UID: ${{ inputs.user_id }} GID: ${{ inputs.group_id }} diff --git a/.github/workflows/container_build_universal.yml b/.github/workflows/container_build_universal.yml index 903c4dd80f3..2ff029681c0 100644 --- a/.github/workflows/container_build_universal.yml +++ b/.github/workflows/container_build_universal.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: container_name: [universal] - python_version: ["3.9", "3.10", "3.11"] + python_version: ["3.10", "3.11", "3.12"] include: - python_version: "3.11" container_tags: latest diff --git a/containers/dev/.devcontainer/entrypoint.sh b/containers/dev/.devcontainer/entrypoint.sh index 4771f1fefbe..5bae915c88e 100644 --- a/containers/dev/.devcontainer/entrypoint.sh +++ b/containers/dev/.devcontainer/entrypoint.sh @@ -1,39 +1,23 @@ #!/bin/bash USERNAME=$(whoami) -AVD_COLLECTION_PATH="${HOME}/.ansible/collections/ansible_collections/arista/avd" CONTAINER_WORKSPACE=$(git rev-parse --show-toplevel) CONTAINER_WSF_AVD_PATH=${CONTAINER_WORKSPACE}/ansible_collections/arista/avd # only install collections if ansible binary is missing if [ -z "$(command -v ansible)" ]; then - # if collection is already mounted, it will be used to install the requirements - # there is no need to install AVD collection for this case as it's already mounted to the correct location - if [ -f ${AVD_COLLECTION_PATH}/requirements.txt ] && [ -f ${AVD_COLLECTION_PATH}/requirements-dev.txt ] ; then - sudo chown -R ${USERNAME} ${HOME}/.ansible # make sure mounted path is owned by container user and not root - ANSIBLE_CORE_VERSION=$(cat ${AVD_COLLECTION_PATH}/requirements-dev.txt | grep ansible-core) # if env variables are set - use git - elif ! [ -z "${AVD_GITHUB_REPO}" ] && ! [ -z "${AVD_BRANCH_NAME}" ]; then - ANSIBLE_CORE_VERSION=$(curl -s https://raw.githubusercontent.com/${AVD_GITHUB_REPO}/${AVD_BRANCH_NAME}/ansible_collections/arista/avd/requirements-dev.txt | grep ansible-core) + if ! [ -z "${AVD_GITHUB_REPO}" ] && ! [ -z "${AVD_BRANCH_NAME}" ]; then AVD_INSTALL_PATH="git+https://github.com/${AVD_GITHUB_REPO}.git#/ansible_collections/arista/avd/,${AVD_BRANCH_NAME}" - # In some cases AVD can not be correctly mounted, for ex. when running dev container as Codespace - # In that case if collection is available in the container workspace, it will be installed from there + PYAVD_INSTALL_LOCATION="git+https://github.com/${AVD_GITHUB_REPO}.git@${AVD_BRANCH_NAME}#subdirectory=python-avd" + pip install "pyavd[ansible] @ ${PYAVD_INSTALL_LOCATION}" + ansible-galaxy collection install --force ${AVD_INSTALL_PATH} + # otherwise install requirements and collection from container workspace elif [ -f ${CONTAINER_WSF_AVD_PATH}/requirements.txt ] && [ -f ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt ] ; then - ANSIBLE_CORE_VERSION=$(cat ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt | grep ansible-core) - AVD_INSTALL_PATH="${CONTAINER_WSF_AVD_PATH}/" - fi - - # install ansible core and requirements - if ! [ -z "${ANSIBLE_CORE_VERSION}" ]; then - pip3 install "${ANSIBLE_CORE_VERSION}" - if ! [ -z "${AVD_INSTALL_PATH}" ]; then - ansible-galaxy collection install --force ${AVD_INSTALL_PATH} - else - # if collection was mounted and not installed - add requirements - ansible-galaxy collection install -r ${AVD_COLLECTION_PATH}/collections.yml - fi - pip3 install -r ${AVD_COLLECTION_PATH}/requirements.txt -r ${AVD_COLLECTION_PATH}/requirements-dev.txt + # use editable install for requirements + pip install -r ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt -r ${CONTAINER_WSF_AVD_PATH}/requirements.txt + ansible-galaxy collection install --force ${CONTAINER_WSF_AVD_PATH} fi # if ansible installation failed for whatever reason - raise an error diff --git a/containers/universal/.devcontainer/Dockerfile b/containers/universal/.devcontainer/Dockerfile index 1ede90bc49e..4d3e7428700 100644 --- a/containers/universal/.devcontainer/Dockerfile +++ b/containers/universal/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ ARG FROM_VARIANT FROM ${FROM_IMAGE}:${FROM_VARIANT} -ARG ANSIBLE_CORE_VERSION +ARG PYAVD_INSTALL_LOCATION ARG ANSIBLE_INSTALL_LOCATION ARG USERNAME @@ -11,8 +11,7 @@ ARG USERNAME USER ${USERNAME} ENV PATH=$PATH:/home/${USERNAME}/.local/bin # Install Ansible AVD collection. -RUN pip3 install "${ANSIBLE_CORE_VERSION}" \ +RUN pip install "pyavd[ansible] @ ${PYAVD_INSTALL_LOCATION}" \ && ansible-galaxy collection install ${ANSIBLE_INSTALL_LOCATION} \ - && pip3 install -r /home/${USERNAME}/.ansible/collections/ansible_collections/arista/avd/requirements.txt \ # install community.general to support callback plugins in ansible.cfg, etc. && ansible-galaxy collection install community.general diff --git a/containers/universal/.devcontainer/devcontainer.json b/containers/universal/.devcontainer/devcontainer.json index a7a51b83d12..a75560286db 100644 --- a/containers/universal/.devcontainer/devcontainer.json +++ b/containers/universal/.devcontainer/devcontainer.json @@ -8,6 +8,7 @@ "FROM_IMAGE": "${localEnv:FROM_IMAGE}", "FROM_VARIANT": "${localEnv:FROM_VARIANT}", "ANSIBLE_INSTALL_LOCATION": "${localEnv:ANSIBLE_INSTALL_LOCATION}", + "PYAVD_INSTALL_LOCATION": "${localEnv:PYAVD_INSTALL_LOCATION}", "ANSIBLE_CORE_VERSION": "${localEnv:ANSIBLE_CORE_VERSION}", "USERNAME": "${localEnv:USERNAME}" }