ansible-galaxy download roles for offline installs

Hello all-

I’m using Ansible at work to automate various workflows, and one of the requirements is deterministic repeatable installs of the ansible environment. As part of this, all installations need to be able to install in an isolated network environment (ie., no external internet connections). Ansible galaxy provides a means to install roles from local tarballs, but no obvious way to obtain those tarballs directly from the ansible galaxy tool.

I’ve added a new “download” command (borrowing heavily from the install command) that will retrieve the role tarballs (and optionally their dependencies) and save them locally. A user can then use these tarballs to accomplish an offline install at some later point.

The changes are rather minor (only 2 files: lib/ansible/cli/galaxy.py, and lib/ansible/galaxy/role.py). Changes can be viewed in my fork:

https://github.com/Mojofreem/ansible/tree/download-for-offline-install

s this something that would be considered worthy of upstream inclusion?

If so, Is there anything I should do prior to submitting a pull request?

Regards,
Liam Chasteen

A few months ago I did a small server intended for private roles that might help you (https://github.com/Feverup/ansible-library). It allows to download tarballs not on github but requires a small patch to ansible to work (https://github.com/ansible/ansible/pull/14779).
It does proxy standard roles, but does not cache them, so for your use case the easiest should be to manually download roles and then upload into the library. If you decide to give a try, contact me if the small documentation is (likely) not enough.