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

Check if vars are defined when rendering files #5

Closed jangel97 closed 2 years ago

jangel97 commented 2 years ago

What does this PR do?

Hi,

I am using the "ee_builder" role, but I do not need to install any kind of Python packages, Ansible collections or system dependencies on the execution environment. For that reason I do not set any of the vars ee_bindep, ee_python, ee_collections, ee_roles.

The problem is that if the three variables are not set, first task in the playbook fails. Also, if ee_jinja_templates_create is set to true, it will try to render bindep.txt, python_req.txt and requirements.yml. This is bad, because what if I have defined ee_python but not the ee_bindep?

I think better possible behaviour is to only render bindep.txt when ee_bindep is defined, same with the other vars.

Any thoughts on this?

Also, there is issue when running the ansible-builder and ee_bindep, ee_python, ee_collections, ee_roles are unset.

---
version: 1

build_arg_defaults:
  ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: "-v"
  EE_BASE_IMAGE: registry.redhat.io/ansible-automation-platform-21/ee-supported-rhel8:1.0.1-11

dependencies:

additional_build_steps:

  append:
    - RUN microdnf update
    - RUN microdnf reinstall tzdata --nodocs -y
    - RUN microdnf clean all
    - RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime
image

In order to fix this little issues, I have created my own fork and tested. Let me know if you think this makes sense.

Thanks in advance,