zenika-open-source / terraform-azure-cli

Minimal & lightweight docker image including Azure and Terraform CLI

Home Page:https://hub.docker.com/r/zenika/terraform-azure-cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

python3-distutils missing

MacFlurry opened this issue · comments

Hello,

trying to get az version thrown me an error:

root@447eecc32209:/workspace# az version
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.7/dist-packages/azure/cli/__main__.py", line 33, in <module>
    az_cli = get_default_cli()
  File "/usr/local/lib/python3.7/dist-packages/azure/cli/core/__init__.py", line 628, in get_default_cli
    from azure.cli.core.azlogging import AzCliLogging
  File "/usr/local/lib/python3.7/dist-packages/azure/cli/core/azlogging.py", line 30, in <module>
    from azure.cli.core.commands.events import EVENT_INVOKER_PRE_CMD_TBL_TRUNCATE
  File "/usr/local/lib/python3.7/dist-packages/azure/cli/core/commands/__init__.py", line 28, in <module>
    from azure.cli.core.extension import get_extension
  File "/usr/local/lib/python3.7/dist-packages/azure/cli/core/extension/__init__.py", line 14, in <module>
    from distutils.sysconfig import get_python_lib
ModuleNotFoundError: No module named 'distutils.sysconfig'

so to fix it, I did an:

apt-get update -y
apt-get install -y python3-distutils

inside the container.

then I correctly get an az version

root@447eecc32209:/workspace# az version
{
  "azure-cli": "2.5.1",
  "azure-cli-command-modules-nspkg": "2.0.3",
  "azure-cli-core": "2.5.1",
  "azure-cli-nspkg": "3.0.4",
  "azure-cli-telemetry": "1.0.4",
  "extensions": {}
}

Could you please fix the Dockerfile ?

Best regards,

MacFlurry

Had the same issue with github actions, i added this by:
apt-get update && apt-get -y install python3-distutils

Not my preferred way, but fixed the issue for now.

@ybelMekk thanks for the PR

Hello @MacFlurry , @ybelMekk !
Thanks you guys for both pointing this issue and pushing a fix, I'm sorry it impacted your workflows !

Adding python3-distutils in the run image seem's to de the trick (adding it on the azure CLI build step is not enough as it is not copied to the run image).

We need to move the install line to the correct location in your PR #74 @ybelMekk, please see my review :-)

All that being said, it is time to add container-structure-test to the CI workflow to ensure this do not happen again (tracked in issue #15)

@MacFlurry, @ybelMekk , thanks again for pointing out and proposing a fix for this issue 👍
It is now resolved thanks to @ybelMekk PR #74.

I've tested all existing tags and cleaned up the broken ones as well as images on the registry.
So we now have a working latest tag from master, and a new release tag 4.0 with supported TF / Azure CLI versions.

Everything should be fine now 😄
I just have to add some testing in the CI (#15) to avoid this happening again !