Create guidelines for collection python requirements

Summary

When packaging an ansible collection/role, there currently is no standard way of specifying python requirements, primarily the hard requirements of plugins. Some people use requirements.txt, but there is no standard guidelines for role and collection authors that I could find. It would be nice to have this documented and discussed somewhere.

This discussion started in this community-topic but stalled a bit I think. Please read that and then let’s continue the discussion here - how do we move forward on this one?

I would presume that requirements.txt and bindep.txt should go in the root of a collection tree (same dir as galaxy.yml), so that they can be picked up by ansible-builder during EE builds.

It would be nice if that was actually part of Collection structure — Ansible Community Documentation.

It would also be nice if ansible-galaxy and maybe some other ansible tools could validate python/system requirements whenever those *.txt files are present in collections. Then warn/fail when dependencies are missing. It would definitely be cool if there was a parameter/switch for auto-installing missing dependencies (if bindep/pip are available in $PATH at least). For e.g. AWX’s dynamic collection install feature works great for collections, but it doesn’t install missing dependencies. I’m not sure how feasible it would be to enable/allow dynamically updating dependencies in EE’s on the fly like AWX does with collections, but at least getting warnings about missing dependencies might be nice.

ansible-builder allows to configure where the requirements files are in meta/execution-environment.yml (see for example community.docker/meta/execution-environment.yml at main · ansible-collections/community.docker · GitHub).

Generally such requirements files only work well for smaller, focussed collections, and you can quickly end up in dependency hell if collections specify too specific version requirements (Make EE a proper EE with dependencies installed by felixfontein · Pull Request #22 · ansible-community/images · GitHub didn’t have a chance because of that).

In any case, there’s a lot of material in the linked GitHub issue, if anyone is interested in details, please read that first :slight_smile: