Execution Environments Setup Reference docs (latest)

Hey there!

I was struggling for a while to get my custom EE built with ansible-builder v3.0.0, until I noticed that I was using an example from the official AAP 4.4 docs that is not working for me at all:

https://docs.ansible.com/automation-controller/latest/html/userguide/ee_reference.html#execution-environment-definition

More precisely, the example in section 16.1 says:

---
version: 3

build_arg_defaults:
  ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: '--pre'

dependencies:
  galaxy: requirements.yml
  python:
    - six
    - psutil
  system: bindep.txt

images:
  base_image:
    name: registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel8:latest

additional_build_files:
    - src: files/ansible.cfg
      dest: configs

additional_build_steps:
  prepend_galaxy:
    - ADD _build/configs/ansible.cfg ~/.ansible.cfg

  prepend_final: |
    RUN whoami
    RUN cat /etc/os-release
  append_final:
    - RUN echo This is a post-install command!
    - RUN ls -la /etc

But this way, ansible-builder did not find the ~/.ansible.cfg file on the EE image during the build, so it ended up switching to /etc/ansible.cfg (which obviously had not any of my customizations):

 ---> Running in 616ee7feb423
Using /etc/ansible.cfg as config file
Starting galaxy collection install process
Process install dependency map
ERROR! Failed to resolve the requested dependencies map. Could not satisfy the following requirements:

Finally, I fixed it by replacing ~./ansible.cfg with /home/runner/.ansible.cfg on the execution_environment.yml, like this:

additional_build_steps:
  prepend_galaxy:
    - ADD _build/configs/ansible.cfg /home/runner/.ansible.cfg

So ~/.ansible.cfg was found during the build:

 ---> Running in b52ce6947398
Using /home/runner/.ansible.cfg as config file
Starting galaxy collection install process
Process install dependency map
Starting collection install process

Now that I got my EE built & running, and before I blame the documentation for the struggle… Does anyone know if relative paths should be working when used on the execution_environment.yml file, or it’s just that the guide has this little -yet annoying- flaw, and instead of relative paths we should be using always absolute paths?

Cheers!

4 Likes

I don’t recall which documentation I followed, but I notice a few differences with the one for AAP 2.4 (AAC 4.4) you linked:

---
version: 3
[...]
additional_build_files:
  - src: ansible.cfg
    dest: configs

additional_build_steps:
  prepend_galaxy:
    - COPY _build/configs/ansible.cfg /etc/ansible/ansible.cfg

How additional_build_files and addidtional_build_steps interact is still a mystery to me.

3 Likes

Use COPY not ADD in the builder examples · Issue #607 · ansible/ansible-builder · GitHub suggests you’re correct that the docs should use COPY instead of ADD here. This blog also suggests any files added need to be relative to the location of the execution-environment.yml file.
@Andersson007 @cidrblock - does this sound correct to you? We can get the various docs updated once we get a nod from you on this…

2 Likes

Thanks for researching further on this matter @samccann , I’ll take a closer look on the provided links myself. In the meantime let’s see what they say :slight_smile:

1 Like

ok if I read the docs further, it’s described at Execution environment definition — Ansible Builder Documentation

Specifies the source file(s) to copy into the build context directory. 
This may either be an absolute path (e.g., /home/user/.ansible.cfg), 
or a path that is relative to the execution environment file. 
Relative paths may be a glob expression matching one 
or more files (e.g. files/*.cfg). Note that an absolute path 
may not include a regular expression. 
If src is a directory, the entire contents of that directory are 
copied to dest.
1 Like

…aaand I think I answered the wrong question there lol… now that I go back, the question was about the additional build steps…digging further

1 Like

Okay this PR fixed the example in the builder docs, but we haven’t moved this update to the controller docs - Update version 3 definition docs (#572) · ansible/ansible-builder@babf314 · GitHub

2 Likes

Wow that was efficient to say the least! Now I believe I could have dig further into the issue myself, so you hadn’t to do all the research. I’ll try to get more familiarised with all the docs & stuff regarding EE’s from now on… Anyway, thanks for your answers! I’m happy I could lend a hand also :blush:

3 Likes

this thread helped us realize we weren’t in sync in various places so was very helpful, thanks!

4 Likes

Hello everyone,

@jbericat thanks for the issue!

  1. I’ve just submitted a PR against the controller doc to replace its definition related content with a reference to the same Builder doc. If someone already did it, sorry. @samccann could you please take a look? The replaced content is just a copy-paste of the Builder’s one.
  2. Does anyone want to implement that easy fix issue Sandra created?

Thanks

3 Likes