redhat-cop / ee_utilities

This ansible collection includes a number of roles and tools which can be useful for managing Ansible Execution Environments.
https://galaxy.ansible.com/infra/ee_utilities
GNU General Public License v3.0
57 stars 34 forks source link

ee_bulder: build_files not implemented #132

Closed erichyde closed 5 months ago

erichyde commented 1 year ago

Summary

Attempting to use the Execution Environment definition build_files to copy additional_build_files to the build context directory, doesn't work. After searching this collection, I can see the build_files variable is templated out to execution_environment.yml file, but the actual files are never copied into the build context. It's like this step was missed.

Issue Type

Ansible, Collection, Docker/Podman details

> ansible --version
ansible [core 2.15.0]
  config file = /home/myuser/ee-builder/ansible.cfg
  configured module search path = ['/home/myuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/myuser/venv/ee-builder/lib/python3.10/site-packages/ansible
  ansible collection location = /home/myuser/ee-builder/collections
  executable location = /home/myuser/venv/ee-builder/bin/ansible
  python version = 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (/home/myuser/venv/ee-builder/bin/python3)
  jinja version = 3.1.2
  libyaml = True

> ansible-galaxy collection list

# /home/myuser/ee-builder/collections/ansible_collections
Collection         Version
------------------ -------
containers.podman  1.10.3 
infra.ee_utilities 3.1.2  

> podman --version
podman version 4.6.2

OS / ENVIRONMENT

Ubuntu 22.04.3 LTS, Running in WSL 2 on Windows 10

Desired Behavior

build_files should be copied into ee_builder_dir/context folder

Actual Behavior

There is no code to copy build_files to ee_builder_dir/context folder

Please give some details of what is actually happening. Include a [minimum complete verifiable example] with:

Something like this could be added to ee_builder/tasks/00_build_ee.yml:

`- name: copy additional_build_files ansible.builtin.copy: src: '{{ item.src }}' dest: '{{ ee_builder_dir | default(build_dir.path) }}/context/{{ item.dest }}' mode: '0655' loop: '{{ __execution_environment_definition.build_files }}' when:

djdanielsson commented 1 year ago

@sean-m-sullivan any thoughts?

sean-m-sullivan commented 12 months ago

I just tested this to make sure it worked like I wrote it.

        build_files:
          - src: /home/user/controller_configuration/changelogs/fragments/checkmode.yml
            dest: configs
        build_steps:
          prepend_final:
            - ADD _build/configs/checkmode.yml /etc/ansible/checkmode.yml

If you give the absolute address it copies it, the problem I am seeing is when you have relative paths, the source will change and even the destination will change.

I tried this


- name: Install, configure, and start Apache
  block:
    - name: Create a context directory if it does not exist
      ansible.builtin.file:
        path: '{{ ee_builder_dir | default(build_dir.path) }}/context/' 
        state: directory
        mode: '0755'

    - name: copy additional_build_files
      ansible.builtin.copy:
        src: '{{ item.src }}'
        dest: '{{ ee_builder_dir | default(build_dir.path) }}/context/{{ item.dest }}' 
        mode: '0655'
      loop: '{{ __execution_environment_definition.build_files }}'
  when: 
    - __execution_environment_definition.build_files is defined 
    - __execution_environment_definition.build_files|length

and it led me into a special level of frustration as the src/dest of ansible-builder doesn't work 1:1 with the ansible.builtin.copy.

I do think that documentation needs to be added on the using the absolute path, and if we could figure it out add this in. But right now taking a break from trying to figure it out.

sean-m-sullivan commented 11 months ago

adding an option in the PR above that should fix this.