From 7966b0da95b4e7d0a72246572816e9a7f8f43c07 Mon Sep 17 00:00:00 2001 From: Suraj Deshmukh Date: Wed, 24 Apr 2024 17:21:02 +0000 Subject: [PATCH] Remove ansible from the base and tools images A user can still install ansible, ansible-galaxy as they need using pip3. This will reduce the size of the image. ``` pip3 install ansible ansible-galaxy collection install \ azure.azcollection --force -p ./collections ``` Signed-off-by: Suraj Deshmukh --- linux/ansible/ansible | 12 ------------ linux/ansible/ansible-config | 12 ------------ linux/ansible/ansible-connection | 12 ------------ linux/ansible/ansible-console | 12 ------------ linux/ansible/ansible-doc | 12 ------------ linux/ansible/ansible-galaxy | 12 ------------ linux/ansible/ansible-inventory | 12 ------------ linux/ansible/ansible-playbook | 12 ------------ linux/ansible/ansible-pull | 12 ------------ linux/ansible/ansible-vault | 12 ------------ linux/base.Dockerfile | 9 --------- .../PSCloudShellUtility/PSCloudShellUtility.psm1 | 1 - linux/tools.Dockerfile | 15 +++++---------- tests/PSinLinuxCloudShellImage.Tests.ps1 | 6 ------ tests/command_list | 11 ----------- 15 files changed, 5 insertions(+), 157 deletions(-) delete mode 100644 linux/ansible/ansible delete mode 100644 linux/ansible/ansible-config delete mode 100644 linux/ansible/ansible-connection delete mode 100644 linux/ansible/ansible-console delete mode 100644 linux/ansible/ansible-doc delete mode 100644 linux/ansible/ansible-galaxy delete mode 100644 linux/ansible/ansible-inventory delete mode 100644 linux/ansible/ansible-playbook delete mode 100644 linux/ansible/ansible-pull delete mode 100644 linux/ansible/ansible-vault diff --git a/linux/ansible/ansible b/linux/ansible/ansible deleted file mode 100644 index 634d3f28..00000000 --- a/linux/ansible/ansible +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -if [ -z "$MSI_ENDPOINT" ]; then - export ANSIBLE_AZURE_AUTH_SOURCE='cli' -else - export ANSIBLE_AZURE_AUTH_SOURCE='msi' -fi - -source /opt/ansible/bin/activate -ansible "$@" -deactivate diff --git a/linux/ansible/ansible-config b/linux/ansible/ansible-config deleted file mode 100644 index 71fa7602..00000000 --- a/linux/ansible/ansible-config +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -if [ -z "$MSI_ENDPOINT" ]; then - export ANSIBLE_AZURE_AUTH_SOURCE='cli' -else - export ANSIBLE_AZURE_AUTH_SOURCE='msi' -fi - -source /opt/ansible/bin/activate -ansible-config "$@" -deactivate diff --git a/linux/ansible/ansible-connection b/linux/ansible/ansible-connection deleted file mode 100644 index b4d78a7a..00000000 --- a/linux/ansible/ansible-connection +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -if [ -z "$MSI_ENDPOINT" ]; then - export ANSIBLE_AZURE_AUTH_SOURCE='cli' -else - export ANSIBLE_AZURE_AUTH_SOURCE='msi' -fi - -source /opt/ansible/bin/activate -ansible-connection "$@" -deactivate diff --git a/linux/ansible/ansible-console b/linux/ansible/ansible-console deleted file mode 100644 index d0230f28..00000000 --- a/linux/ansible/ansible-console +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -if [ -z "$MSI_ENDPOINT" ]; then - export ANSIBLE_AZURE_AUTH_SOURCE='cli' -else - export ANSIBLE_AZURE_AUTH_SOURCE='msi' -fi - -source /opt/ansible/bin/activate -ansible-console "$@" -deactivate diff --git a/linux/ansible/ansible-doc b/linux/ansible/ansible-doc deleted file mode 100644 index 5e4204eb..00000000 --- a/linux/ansible/ansible-doc +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -if [ -z "$MSI_ENDPOINT" ]; then - export ANSIBLE_AZURE_AUTH_SOURCE='cli' -else - export ANSIBLE_AZURE_AUTH_SOURCE='msi' -fi - -source /opt/ansible/bin/activate -ansible-doc "$@" -deactivate diff --git a/linux/ansible/ansible-galaxy b/linux/ansible/ansible-galaxy deleted file mode 100644 index 5c8b7860..00000000 --- a/linux/ansible/ansible-galaxy +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -if [ -z "$MSI_ENDPOINT" ]; then - export ANSIBLE_AZURE_AUTH_SOURCE='cli' -else - export ANSIBLE_AZURE_AUTH_SOURCE='msi' -fi - -source /opt/ansible/bin/activate -ansible-galaxy "$@" -deactivate diff --git a/linux/ansible/ansible-inventory b/linux/ansible/ansible-inventory deleted file mode 100644 index 94b7490a..00000000 --- a/linux/ansible/ansible-inventory +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -if [ -z "$MSI_ENDPOINT" ]; then - export ANSIBLE_AZURE_AUTH_SOURCE='cli' -else - export ANSIBLE_AZURE_AUTH_SOURCE='msi' -fi - -source /opt/ansible/bin/activate -ansible-inventory "$@" -deactivate diff --git a/linux/ansible/ansible-playbook b/linux/ansible/ansible-playbook deleted file mode 100644 index 5c460b72..00000000 --- a/linux/ansible/ansible-playbook +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -if [ -z "$MSI_ENDPOINT" ]; then - export ANSIBLE_AZURE_AUTH_SOURCE='cli' -else - export ANSIBLE_AZURE_AUTH_SOURCE='msi' -fi - -source /opt/ansible/bin/activate -ansible-playbook "$@" -deactivate diff --git a/linux/ansible/ansible-pull b/linux/ansible/ansible-pull deleted file mode 100644 index 21c05ee9..00000000 --- a/linux/ansible/ansible-pull +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -if [ -z "$MSI_ENDPOINT" ]; then - export ANSIBLE_AZURE_AUTH_SOURCE='cli' -else - export ANSIBLE_AZURE_AUTH_SOURCE='msi' -fi - -source /opt/ansible/bin/activate -ansible-pull "$@" -deactivate diff --git a/linux/ansible/ansible-vault b/linux/ansible/ansible-vault deleted file mode 100644 index cda6729a..00000000 --- a/linux/ansible/ansible-vault +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -if [ -z "$MSI_ENDPOINT" ]; then - export ANSIBLE_AZURE_AUTH_SOURCE='cli' -else - export ANSIBLE_AZURE_AUTH_SOURCE='msi' -fi - -source /opt/ansible/bin/activate -ansible-vault "$@" -deactivate diff --git a/linux/base.Dockerfile b/linux/base.Dockerfile index 30305502..8f7a1898 100644 --- a/linux/base.Dockerfile +++ b/linux/base.Dockerfile @@ -31,7 +31,6 @@ RUN bash ./tdnfinstall.sh \ gpgme \ gnupg2 \ autoconf \ - ansible \ bash-completion \ build-essential \ binutils \ @@ -156,14 +155,6 @@ ENV LANG="en_US.utf8" RUN pip3 install --upgrade sfctl \ && pip3 install --upgrade mssql-scripter -# # BEGIN: Install Ansible in isolated Virtual Environment -COPY ./linux/ansible/ansible* /usr/local/bin/ -RUN chmod 755 /usr/local/bin/ansible* \ - && cd /opt \ - && virtualenv -p python3 ansible \ - && /bin/bash -c "source ansible/bin/activate && pip3 list --outdated --format=freeze | cut -d '=' -f1 | xargs -n1 pip3 install -U && pip3 install ansible && pip3 install pywinrm\>\=0\.2\.2 && deactivate" \ - && ansible-galaxy collection install azure.azcollection --force -p /usr/share/ansible/collections - # Install latest version of Istio ENV ISTIO_ROOT /usr/local/istio-latest RUN curl -sSL https://git.io/getLatestIstio | sh - \ diff --git a/linux/powershell/PSCloudShellUtility/PSCloudShellUtility.psm1 b/linux/powershell/PSCloudShellUtility/PSCloudShellUtility.psm1 index 0571c7b9..dfda5692 100644 --- a/linux/powershell/PSCloudShellUtility/PSCloudShellUtility.psm1 +++ b/linux/powershell/PSCloudShellUtility/PSCloudShellUtility.psm1 @@ -1803,7 +1803,6 @@ function Get-PackageVersion() { $packageVersionDetections = @( @{displayname = "Node.JS"; command = "node"; args = "--version"; match = "v(.*)"}, @{displayname = "Cloud Foundry CLI"; command = "cf"; args = "-v"; match = "cf version (.*)"}, - @{displayname = "Ansible"; command = "ansible"; args = "--version"; match = "ansible \[core ([\d\.]+)\]"}, @{displayname = "Istio"; command = "istioctl"; args = "version -s --remote=false"; match = "(.+)"}, @{displayname = "Go"; command = "go"; args = "version"; match = "go version go(\S+) .*"}, @{displayname = "Packer"; command = "packer"; args = "version"; match = "Packer v(.+)"}, diff --git a/linux/tools.Dockerfile b/linux/tools.Dockerfile index 6c62cfcd..dfb22d0b 100644 --- a/linux/tools.Dockerfile +++ b/linux/tools.Dockerfile @@ -22,8 +22,8 @@ RUN tdnf clean all && \ # Install any Azure CLI extensions that should be included by default. RUN az extension add --system --name ai-examples -y \ -&& az extension add --system --name ssh -y \ -&& az extension add --system --name ml -y + && az extension add --system --name ssh -y \ + && az extension add --system --name ml -y # Install kubectl RUN az aks install-cli \ @@ -49,14 +49,9 @@ RUN npm install -q -g @pnp/cli-microsoft365 # Install Bicep CLI RUN curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64 \ - && chmod +x ./bicep \ - && mv ./bicep /usr/local/bin/bicep \ - && bicep --help - -# Temp: fix ansible modules. Proper fix is to update base layer to use regular python for Ansible. -RUN mkdir -p /usr/share/ansible/collections/ansible_collections/azure/azcollection/ \ - && wget -nv -q -O /usr/share/ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt \ - && /opt/ansible/bin/python -m pip install -r /usr/share/ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt + && chmod +x ./bicep \ + && mv ./bicep /usr/local/bin/bicep \ + && bicep --help # Copy and run script to Install powershell modules and setup Powershell machine profile COPY ./linux/powershell/PSCloudShellUtility/ /usr/local/share/powershell/Modules/PSCloudShellUtility/ diff --git a/tests/PSinLinuxCloudShellImage.Tests.ps1 b/tests/PSinLinuxCloudShellImage.Tests.ps1 index 2377cb06..e883524d 100755 --- a/tests/PSinLinuxCloudShellImage.Tests.ps1 +++ b/tests/PSinLinuxCloudShellImage.Tests.ps1 @@ -77,12 +77,6 @@ Describe "Various programs installed with expected versions" { $paths | Should -Contain "~/.local/bin" } - It "Ansible pwsh has modules" { - Test-Path -Path "/usr/share/ansible/collections/ansible_collections/azure/azcollection/" | Should -Be $true - $process = Start-Process -FilePath /opt/ansible/bin/python -ArgumentList "-c `"import msrest`"" -Wait -PassThru - $process.ExitCode | Should -Be 0 - } - It "Has various environment vars" { $env:AZUREPS_HOST_ENVIRONMENT | Should -Be "cloud-shell/1.0" } diff --git a/tests/command_list b/tests/command_list index c5deaa2b..8f377f3b 100644 --- a/tests/command_list +++ b/tests/command_list @@ -39,17 +39,6 @@ agetty alias alternatives anacron -ansible -ansible-config -ansible-connection -ansible-console -ansible-doc -ansible-galaxy -ansible-inventory -ansible-playbook -ansible-pull -ansible-test -ansible-vault apparmor_parser apparmor_status applygnupgdefaults