ansible / ansible-builder

An Ansible execution environment builder
Other
287 stars 93 forks source link

BUG: Using a base image with microdnf causes ansible-builder failure for dnf path #690

Closed netopsengineer closed 1 month ago

netopsengineer commented 1 month ago

Team,

The docs for ansible-dev-tools suggest creating a custom execution-environment.yml with the following:

---
version: 3

images:
  base_image:
    name: ghcr.io/ansible/community-ansible-dev-tools:latest

dependencies:
  galaxy: requirements.yml
  python: requirements.txt

However, this looks to create the following error during the build where ansible-builder is expecting to find /usr/bin/dnf, but it appears the image is using /usr/bin/microdnf instead:

3.069 /output/scripts/assemble: line 163: /usr/bin/dnf: No such file or directory
------
Dockerfile:57
--------------------
  55 |     COPY _build/requirements.txt requirements.txt
  56 |     RUN $PYCMD /output/scripts/introspect.py introspect --user-pip=requirements.txt --write-bindep=/tmp/src/bindep.txt --write-pip=/tmp/src/requirements.txt
  57 | >>> RUN /output/scripts/assemble
  58 |
  59 |     # Final build stage
--------------------
ERROR: failed to solve: process "/bin/sh -c /output/scripts/assemble" did not complete successfully: exit code: 127

Adding the following to the execution-environment.yml resolves it:

options:
  package_manager_path: /usr/bin/microdnf

I originally opened an issue on ansible-dev-tools and was referred here https://github.com/ansible/ansible-dev-tools/issues/284 by @ssbarnea

Shrews commented 1 month ago

Your modification of the execution-environment.yml file to resolve the issue is the proper way of dealing with this.

Because the package manager is used within the dynamically built Containerfile with a RUN instruction (for example, to install the user's selected version of Python), and we do not do any sort of probing of the selected container image itself, it is required that you define the package manager within the EE file. If the assemble script were the only place the package manager was used, we could programmatically figure out which one exists because it is run within the container.

As such, your original bug report to ansible-dev-tools is completely valid, and I'll be closing this one.