4

I have this requirements.yml snippet:

- name: myrole
  scm: git
  src: git@gitlab.mygitlab.com:category/project.git
  version: master

When I install it using ansible-galaxy install -r requirements.yml, the repository is cloned properly, but the submodules are not initialised. This can possibly be resolved using some sort of local action task, but that means I have to keep track of what dependencies every role I want to include needs which is far from ideal. Is there a better solution?

sudosensei
  • 387
  • 5
  • 14

1 Answers1

0

As defined in the documentation, if the dependencies are taken from Galaxy, you have to specify them under the meta/main.yml file as:

dependencies:
  - geerlingguy.apache
  - geerlingguy.ansible

If they are in your own repo:

dependencies:
  - src: geerlingguy.ansible
  - src: git+https://github.com/geerlingguy/ansible-role-composer.git
    version: 775396299f2da1f519f0d8885022ca2d6ee80ee8
    name: composer
imjoseangel
  • 3,543
  • 3
  • 22
  • 30
  • 1
    I am already using `meta/main.yml`. The problem is that one of my repositories includes a git submodule that is not initialised when Ansible clones the repo. This causes the tasks in the role to fail. I have managed to work around the issue by replacing the submodule with a subtree which ensures that files are there during simple `git clone` operations. – sudosensei May 08 '18 at 20:00
  • Not helpful at all when the dependency is a custom module, not another role. – Jack Jun 12 '19 at 19:28
  • Of course this is for roles only. For modules, check the new Collections functionality in Ansible 2.8 at https://galaxy.ansible.com/docs/contributing/creating_collections.html (Experimental Feature) – imjoseangel Jun 12 '19 at 20:48