Skip to content

Commit

Permalink
Remove ansible from the base and tools images
Browse files Browse the repository at this point in the history
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 <suraj.deshmukh@microsoft.com>
  • Loading branch information
surajssd committed Apr 25, 2024
1 parent 14218b1 commit 4b10602
Show file tree
Hide file tree
Showing 15 changed files with 8 additions and 161 deletions.
12 changes: 0 additions & 12 deletions linux/ansible/ansible

This file was deleted.

12 changes: 0 additions & 12 deletions linux/ansible/ansible-config

This file was deleted.

12 changes: 0 additions & 12 deletions linux/ansible/ansible-connection

This file was deleted.

12 changes: 0 additions & 12 deletions linux/ansible/ansible-console

This file was deleted.

12 changes: 0 additions & 12 deletions linux/ansible/ansible-doc

This file was deleted.

12 changes: 0 additions & 12 deletions linux/ansible/ansible-galaxy

This file was deleted.

12 changes: 0 additions & 12 deletions linux/ansible/ansible-inventory

This file was deleted.

12 changes: 0 additions & 12 deletions linux/ansible/ansible-playbook

This file was deleted.

12 changes: 0 additions & 12 deletions linux/ansible/ansible-pull

This file was deleted.

12 changes: 0 additions & 12 deletions linux/ansible/ansible-vault

This file was deleted.

14 changes: 2 additions & 12 deletions linux/base.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# base.Dockerfile contains components which are large and change less frequently.
# tools.Dockerfile contains the smaller, more frequently-updated components.
# base.Dockerfile contains components which are large and change less frequently.
# tools.Dockerfile contains the smaller, more frequently-updated components.

# Within Azure, the image layers
# built from this file are cached in a number of locations to speed up container startup time. A manual
Expand Down Expand Up @@ -38,7 +38,6 @@ RUN bash ./tdnfinstall.sh \
gpgme \
gnupg2 \
autoconf \
ansible \
bash-completion \
build-essential \
binutils \
Expand Down Expand Up @@ -193,15 +192,6 @@ RUN curl -fSsL `curl -fSsL https://api.github.com/repos/Azure/batch-shipyard/rel
&& /bin/bash -c "source cloudshell/bin/activate && python3 -m compileall -f /opt/batch-shipyard/shipyard.py /opt/batch-shipyard/convoy && deactivate" \
&& ln -sf /opt/batch-shipyard/shipyard /usr/local/bin/shipyard

# # BEGIN: Install Ansible in isolated Virtual Environment
COPY ./linux/ansible/ansible* /usr/local/bin/
RUN chmod 755 /usr/local/bin/ansible* \
&& pip3 install virtualenv \
&& cd /opt \
&& virtualenv -p python3 ansible \
&& /bin/bash -c "source ansible/bin/activate && 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 - \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,6 @@ function Get-PackageVersion() {
@{displayname = "Cloud Foundry CLI"; command = "cf"; args = "-v"; match = "cf version (.*)"},
@{displayname = "Blobxfer"; command = "blobxfer"; args = "--version"; match = "blobxfer, version (.*)"},
@{displayname = "Batch Shipyard"; command = "shipyard"; args = "--version"; match = "shipyard.py, 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(.+)"},
Expand Down
15 changes: 5 additions & 10 deletions linux/tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ RUN wget https://azurecliprod.blob.core.windows.net/cloudshell-release/azure-cli

# 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 \
Expand All @@ -48,14 +48,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/
Expand Down
6 changes: 0 additions & 6 deletions tests/PSinLinuxCloudShellImage.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
13 changes: 1 addition & 12 deletions tests/command_list
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1437,4 +1426,4 @@ zstd
zstdcat
zstdgrep
zstdless
zstdmt
zstdmt

0 comments on commit 4b10602

Please sign in to comment.