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 May 1, 2024
1 parent 5807cb7 commit babdaa5
Show file tree
Hide file tree
Showing 15 changed files with 5 additions and 159 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.

11 changes: 0 additions & 11 deletions linux/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ RUN bash ./tdnfinstall.sh \
gpgme \
gnupg2 \
autoconf \
ansible \
bash-completion \
build-essential \
binutils \
Expand Down Expand Up @@ -157,16 +156,6 @@ RUN pip3 install --upgrade sfctl \
&& pip3 install --upgrade mssql-scripter \
&& rm -rf ~/.cache/pip/

# # 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" \
&& rm -rf ~/.local/share/virtualenv/ \
&& rm -rf ~/.cache/pip/ \
&& 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 @@ -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(.+)"},
Expand Down
15 changes: 5 additions & 10 deletions linux/tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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/
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
11 changes: 0 additions & 11 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

0 comments on commit babdaa5

Please sign in to comment.