How to develop and run collection locally

I have all the collections I work on checked out in a ansible_collections directory structure that’s both part of my work directory (where all my git projects are checked out) and my ANSIBLE_COLLECTIONS_PATH. Basically what is described here: How to test a collection PR — Ansible Documentation

This allows me to directly use the collections I am working on in ansible-core without having to install them.

It does mean though that I have to manually take care of the collection’s dependencies. For the collections I work on this isn’t a problem, most don’t have dependencies at all, or these are also collections I (sometimes) work on, so I have them checked out anyway. Of course you can also install some of the dependencies manually with ansible-galaxy collection install somewhere else.

One alternative to the above is to check out the collection foo.bar to in a directory collections/ansible_collections/foo/bar relative to your playbook directory. Then you can modify the collection and directly use them in your playbooks. (You could of course also keep that collection in this directory structure in the same git repo as your playbooks. Whether that makes sense depends on your situation…)

4 Likes