vmware-samples / packer-examples-for-vsphere

Packer Examples for vSphere
https://vmware-samples.github.io/packer-examples-for-vsphere/
Other
797 stars 318 forks source link

Dev Container build failure #954

Open erikspigle-payroc opened 1 month ago

erikspigle-payroc commented 1 month ago

Code of Conduct

Project Version

latest

VMware vSphere

N/A

HashiCorp Packer

N/A

HashiCorp Packer Plugin for VMware vSphere

N/A

Guest Operating System

Ubuntu Server 22.04 LTS

Environment Details

Building as a dev container in the latest VS Code and latest Docker Desktop using the current .devcontainer definitions on the most currently patched Windows 11.

Description

It seems there are problems with the referenced ansible feature for the dev container. While this project has nothing to do with maintaining that ansible feature, it should be considered to install ansible in a different way as that project is broken and hasn't been touched in closing in on a year. It has been months since any code has been maintained in that project:

https://github.com/devcontainers-contrib/features/tree/main/src/ansible

Expected Behavior

dev container building successfully with no failures.

Actual Behavior

The dev container is failing to build due to reliance on feature installed by "https://github.com/devcontainers-contrib/features/tree/main/src/ansible".

Steps to Reproduce

Either build out a dev container using the spec in this project, or build a net new dev container in VS Code and use Ubuntu as the base OS, and then choose the ansible feature that gets installed from here: https://github.com/devcontainers-contrib/features/tree/main/src/ansible as an additional feature. It will fail in the same way, either way.

Log Fragments and Files

Log entries of the failure to build:

  installed package ansible-core 2.17.2, installed using Python 3.10.12
#0 28.55   These apps are now globally available
#0 28.55     - ansible
#0 28.55     - ansible-config
#0 28.55     - ansible-connection
#0 28.55     - ansible-console
#0 28.55     - ansible-doc
#0 28.55     - ansible-galaxy
#0 28.55     - ansible-inventory
#0 28.55     - ansible-playbook
#0 28.55     - ansible-pull
#0 28.55     - ansible-test
#0 28.55     - ansible-vault
#0 28.55 done! ��� ���� ���
#0 28.55 usage: pipx [-h] [--quiet] [--verbose] [--global] [--version]
#0 28.66             {install,install-all,uninject,inject,pin,unpin,upgrade,upgrade-all,upgrade-shared,uninstall,uninstall-all,reinstall,reinstall-all,list,interpreter,run,runpip,ensurepath,environment,completions}
#0 28.66             ...
#0 28.66 pipx: error: unrecognized arguments: ansible
#0 28.66 Traceback (most recent call last):
#0 28.71   File "<string>", line 1, in <module>
#0 28.71   File "nanolayer.__main__", line 50, in main
#0 28.71   File "typer.main", line 328, in __call__
#0 28.71   File "typer.main", line 311, in __call__
#0 28.71   File "click.core", line 1157, in __call__
#0 28.71   File "typer.core", line 778, in main
#0 28.71   File "typer.core", line 216, in _main
#0 28.71   File "click.core", line 1688, in invoke
#0 28.71   File "click.core", line 1688, in invoke
#0 28.71   File "click.core", line 1434, in invoke
#0 28.71   File "click.core", line 783, in invoke
#0 28.71   File "typer.main", line 683, in wrapper
#0 28.71   File "nanolayer.cli.install", line 65, in install_devcontainer_feature
#0 28.71   File "nanolayer.installers.devcontainer_feature.oci_feature_installer", line 131, in install
#0 28.71   File "nanolayer.utils.invoker", line 59, in invoke
#0 28.71 nanolayer.utils.invoker.Invoker.InvokerException: The command 'cd /tmp/tmp9_dxsv30 && chmod +x -R . && _REMOTE_USER="vscode" _REMOTE_USER_HOME="/home/vscode" PACKAGE="ansible-core" INJECTIONS="ansible" VERSION="latest" INCLUDEDEPS="false" INTERPRETER="" NANOLAYER_VERBOSE="" NANOLAYER_FORCE_CLI_INSTALLATION="" NANOLAYER_PROPAGATE_CLI_LOCATION="1" NANOLAYER_CLI_LOCATION="/tmp/nanolayer-K9xcqxBQBr/nanolayer" bash  -i  +H ./install.sh' failed. error: Return Code: 2. see logs for details.
#0 28.92 ERROR: Feature "Ansible (via pipx)" (ghcr.io/devcontainers-contrib/features/ansible) failed to install! Look at the documentation at http://github.com/devcontainers-contrib/features/tree/main/src/ansible for help troubleshooting this error.
------
Dockerfile-with-features:37
--------------------
  36 |     
  37 | >>> RUN --mount=type=bind,from=dev_containers_feature_content_source,source=ansible_0,target=/tmp/build-features-src/ansible_0 \
  38 | >>>     cp -ar /tmp/build-features-src/ansible_0 /tmp/dev-container-features \
  39 | >>>  && chmod -R 0755 /tmp/dev-container-features/ansible_0 \
  40 | >>>  && cd /tmp/dev-container-features/ansible_0 \
  41 | >>>  && chmod +x ./devcontainer-features-install.sh \
  42 | >>>  && ./devcontainer-features-install.sh \
  43 | >>>  && rm -rf /tmp/dev-container-features/ansible_0
  44 |     
--------------------
error: failed to solve: process "/bin/sh -c cp -ar /tmp/build-features-src/ansible_0 /tmp/dev-container-features  && chmod -R 0755 /tmp/dev-container-features/ansible_0  && cd /tmp/dev-container-features/ansible_0  && chmod +x ./devcontainer-features-install.sh  && ./devcontainer-features-install.sh  && rm -rf /tmp/dev-container-features/ansible_0" did not complete successfully: exit code: 1
[42368 ms] Error: Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-root/container-features/0.65.0-1722946969142/Dockerfile-with-features -t vsc-packer-examples-for-vsphere-44193c409f5009b7753456926a642ae04fce67db059d25a6baec99bf3f597b81 --target dev_containers_target_stage --build-context dev_containers_feature_content_source=/tmp/devcontainercli-root/container-features/0.65.0-1722946969142 --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp /workspaces/packer-examples-for-vsphere/.devcontainer
[42368 ms]     at mtA (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:466:1933)
[42368 ms]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[42368 ms]     at async Pm (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:465:1856)
[42368 ms]     at async NH (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:465:610)
[42368 ms]     at async KtA (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:482:3771)
[42368 ms]     at async eB (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:482:4886)
[42368 ms]     at async hrA (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:663:200)
[42369 ms]     at async lrA (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:662:13452)
[42384 ms] Exit code 1
[42384 ms] Start: Run: docker rm -f 834ca249cd83bc51f2f178592da40a65e18ad4ece485fbb62645e3a383c88826
[42399 ms] Command failed: node /root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-0e7e42c2-7543-45a9-be54-5e45a060f05a1722946959221 --workspace-folder /workspaces/packer-examples-for-vsphere --workspace-mount-consistency cached --id-label vsch.local.repository=https://github.com/vmware-samples/packer-examples-for-vsphere --id-label vsch.local.repository.volume=packer-examples-for-vsphere-699e0bd8385edf4c51aaa29ddb2f67185c2d9977e1d0ddd6006c4c08705c36e5 --id-label vsch.local.repository.folder=packer-examples-for-vsphere --id-label devcontainer.config_file=/workspaces/packer-examples-for-vsphere/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspaces/packer-examples-for-vsphere/.devcontainer/devcontainer.json --override-config /tmp/devcontainer-0e020011-2474-49c6-953a-3666160e90da.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=packer-examples-for-vsphere-699e0bd8385edf4c51aaa29ddb2f67185c2d9977e1d0ddd6006c4c08705c36e5,target=/workspaces,external=true --mount type=volume,source=vscode,target=/vscode,external=true --mount type=bind,source=\\wsl.localhost\Ubuntu\mnt\wslg\runtime-dir\wayland-0,target=/tmp/vscode-wayland-26219d69-f383-4c4e-81ac-501374b69626.sock --skip-post-create --update-remote-user-uid-default off --mount-workspace-git-root --terminal-columns 253 --terminal-rows 25 --include-configuration --include-merged-configuration
[42399 ms] Exit code 1
[42543 ms] Container server terminated (code: 137, signal: null).

Screenshots

No response

Additional Context

I think the real ask is to not rely on this ansible feature for the dev container build (as it seems to be an abandoned project) and to maybe install ansible in another way for the dev container buildout.

burnsjared0415 commented 1 month ago

if we replace "ghcr.io/devcontainers-contrib/features/ansible:2": {}, "mcr.microsoft.com/vscode/devcontainers/ansible:latest": {}, in the devcontainer.json does it work better?

erikspigle-payroc commented 1 month ago

Tried this in another project, does not seem to resolve:

[4836 ms] Start: Run: docker inspect --type image mcr.microsoft.com/devcontainers/base:ubuntu-22.04
[5418 ms] Resolving Feature dependencies for 'mcr.microsoft.com/vscode/devcontainers/ansible:latest'...
[5418 ms] * Processing feature: mcr.microsoft.com/vscode/devcontainers/ansible:latest
[5531 ms] Could not resolve Feature manifest for 'mcr.microsoft.com/vscode/devcontainers/ansible:latest'.  If necessary, provide registry credentials with 'docker login <registry>'.
[5531 ms] Github feature.
[5531 ms] Could not resolve Feature 'mcr.microsoft.com/vscode/devcontainers/ansible:latest'.  Ensure the Feature is published and accessible from your current environment.
[5532 ms] Error: ERR: Feature 'mcr.microsoft.com/vscode/devcontainers/ansible:latest' could not be processed.  You may not have permission to access this Feature, or may not be logged in.  If the issue persists, report this to the Feature author.
[5532 ms]     at yeA (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:285:9703)
[5532 ms]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[5532 ms]     at async OC (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:285:12273)
[5532 ms]     at async Rc (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:285:12501)
[5532 ms]     at async Gc (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:390:1821)
[5532 ms]     at async XC (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:393:2228)
[5532 ms]     at async mtA (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:465:2425)
[5532 ms]     at async Pm (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:465:1856)
[5532 ms]     at async NH (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:465:610)
[5532 ms]     at async KtA (/root/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:482:3771)
[5542 ms] Exit code 1
tenthirtyam commented 1 month ago

.devcontainer/Dockerfile

# Copyright 2023-2024 Broadcom. All Rights Reserved.
# SPDX-License-Identifier: BSD-2

FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04

# Install additional packages unavailable in the base image or as a feature.
# Note: Unable to be installed used the "postCreateCommand" option.
RUN apt-get update && \
    apt-get install -y jq xorriso whois && \
    apt-get autoremove -y && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json

{
  "name": "Packer Examples for vSphere",
  "build": {
    "dockerfile": "Dockerfile"
  },
  "features": {
    "ghcr.io/devcontainers/features/powershell": {},
    "ghcr.io/devcontainers-contrib/features/packer-asdf": {},
    "ghcr.io/devcontainers-contrib/features/terraform-asdf": {},
    "ghcr.io/gickis/devcontainer-features/gomplate": {}
  },
  "postCreateCommand": "pwsh -Command 'Write-Host PowerShell Installed' && ansible --version && packer --version && terraform --version && gomplate --version",
  "customizations": {
    "vscode": {
      "extensions": [
        "EditorConfig.EditorConfig",
        "esbenp.prettier-vscode",
        "GitHub.remotehub",
        "GitHub.vscode-pull-request-github",
        "GitLab.gitlab-workflow",
        "hashicorp.hcl",
        "hashicorp.terraform",
        "ms-vscode.powershell",
        "redhat.ansible",
        "streetsidesoftware.code-spell-checker"
      ]
    }
  }
}
image
Running the postCreateCommand from devcontainer.json...

[260298 ms] Start: Run in container: /bin/sh -c pwsh -Command 'Write-Host PowerShell Installed' && ansible --version && packer --version && terraform --version && gomplate --version
PowerShell Installed
ansible 2.10.8
  config file = None
  configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]
Packer v1.11.2
Terraform v1.9.4
on linux_amd64
gomplate version 4.1.0
Done. Press any key to close the terminal.
tenthirtyam commented 2 days ago

Awaiting an update from OP, @erikspigle-payroc.