Uninstall not needed collections when using ansible-builder

Is There a way to unistall not needed collections?.

  • when run ansible-builder it uses execution-environment.yml file to read collections you want.
  • But if i use base iamge, it comes with bunch of collections i dont need.
  • awx-ee:23.5.0 comes with theforeman.foreman, ovirt.ovirt and others.
  • i got some issues dealing with dependencies, sometime they dont match.

I would apreciate if you can give some advice on it or the best aproach to improve building execution environments.

regards
Marcelo

If you want to only have the collections you prefer in your image, then you should either use a proper base image (fedora/centos/ubi, I think ansible-builder recently added support for other distros as well, you just have to define the package manager commands); or you could use the community-minimal-ee which contains only 3 ansible.* collections.

You should also consider using multiple EE’s. The AWX-EE has everything it needs for AWX to function. This should be the control plane’s EE (i.e. control_plane_ee_image). Your custom EE’s can be added as extra execution environments and you can set them as the default EE for your Org, while still allowing the AWX itself to use its own EE.

1 Like

If awx-ee is the closest thing to what you need but has some extras, you can use it as a base image but remove extra collections by running rm -rf /path/to/collection inside additional_build_step key of the execution-environment.yml:

https://ansible.readthedocs.io/projects/builder/en/latest/definition/#additional-build-steps

append_galaxy sub key should do the trick, if not, use append_final.