A wrapper for ansible-galaxy that allows you to define role dependencies inside a requirements.yml
Project description
Molecule Ansible Galaxy Wrapper
An Ansible Galaxy wrapper to serve as a molecule dependency plugin with intra-dependencies support.
Motivation
Imagine the scenario, you have a Role named child
that depends on a role called parent
and parent
depends on grandparent
.
To install child
you need to have parent
and grandparent
in your roles_path
:
child -> parent -> grandparent
Ansible Galaxy is smart enough to figure that out, all you have to do is define grandparent
as a dependency of parent
role inside meta/main.yml
and then parent
as a dependency inside child
role meta/main.yml
file.
The problem is that molecule enforces tracking role dependencies inside a requirements.yml
file, in that case, you have two options:
- Include both
parent
andchild
in yourrequirements.yml
and simply ignoremeta/main.yml
- Include
parent
insiderequirements.yml
and duplicate the same content insidemeta/main.yml
First approach might look reasonable in a scenarion like this, but you might have a more complex dependency relationship and in that case you will soon have big problems.
The latter looks ugly but at least you can delegate the responsability of figuring out the dependency tree to Ansible Galaxy.
Enter the Dirty Hack
At some point we will forget to append dependencies to both requirements.yml
and meta/main.yml
. To avoid this issue I've created this tiny wrapper that does basically two things:
- Copy the content of
requirements.yml
intometa/main.yml
requirements list - Run
ansible-galaxy install
Usage
Install molecule-galaxy wrapper
:
pip install molecule-galaxy-wrapper
Configure molecule.yml
to use the warpper:
dependency:
name: shell
command: galaxywrapper
driver:
name: docker
...
Test it by running:
molecule dependency
Now you can maintain role dependencies inside your requirements.yml
file.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for molecule-galaxy-wrapper-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2257f43067d43f694485040db0ee5194378c37427db209475370fe970913f450 |
|
MD5 | b1af848223554e227de6dd094b382f31 |
|
BLAKE2b-256 | 78a4ed81ae13946b6fdcd33cafee58c467e8e718fc0520941710fd3f1f503055 |
Hashes for molecule_galaxy_wrapper-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5465519b4023d71a47c5733b0686a4313d05ca8e794ec08df0fca8299dc85342 |
|
MD5 | 83b5a1153f65cb69352fc42c8d29737d |
|
BLAKE2b-256 | 377c1e31c4f047f710a8e8c7741f63a41883a2241bc66e0543a314e369caa6be |