The Ansible collections documentation provides a number of ways for installing collections. The primary focus is on installing from Ansible Galaxy.
However, I would like to host and install built collections (tar.gz) from an internal web server.
At this point, I am not interested in self-hosting a Galaxy server or installing the collections from a git repo (I don't want to have to deal with permissions).
Is there a way to specify a url as the collection source when using ansible-galaxy collection install
.
That is, can this work?
$ ansible-galaxy collection install http://example.com/collection-X.X.X.tar.gz
and would I be able to specify a url path in requirements.yml
?
This can be done directly on the command line and in the requirements file.
ansible-galaxy
supports installing a collection from a build (tar.gz) using
$ ansible-galaxy install <collection.tar.gz>
If the collection is hosted on a web server the source can be passed to the command
$ ansible-galaxy install http://example.com/collection-X.X.X.tar.gz
Downloading http://example.com/collection-X.X.X.tar.gz to <tmp directory>
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'collection:X.X.X' to '<collection folder>'
Ansible collections can be installed using a requirements file.
The documentation lists url
as a supported value for the type
key for collection entries.
Therefore to install the collection hosted at
http://example.com/collection-X.X.X.tar.gz
add the following entry to the
collections
key of the requirements file
---
# requirements.yml
collections: # Note: all collections must be listed under this key
- name: <namespace.collection>
type: url
source: http://example.com/collection-X.X.X.tar.gz
and install using
$ ansible-galaxy collection install -r requirements.yml
Starting galaxy collection install process
Process install dependency map
Downloading http://example.com/collection-X.X.X.tar.gz to <tmp directory>
Starting collection install process
Installing 'namespace.collection:X.X.X' to '<collections directory>'
namespace.collection:X.X.X was installed successfully
The version
key can be specified but the value provided must match the version in the
name of the archive.
---
# requirements.yml
collections: # Note: collections must be listed under this key
- name: <namespace.collection>
type: url
version: X.Y.Z # this will fail. value must be X.X.X
source: http://example.com/collection-X.X.X.tar.gz