0

I have a private Ansible git repo which I would like to use in another repo. So I installed the role locally using requirements.yml. my question now is, when I git push my requirements.yml, how will it be consumed by my other peers when executing in other environments? Will they have to manually run the Ansible galaxy Install command everytime to download the role locally?

suj
  • 507
  • 1
  • 8
  • 22

1 Answers1

0

Yes, they would need to run the ansible-galaxy command.

As an alternative you can use git submodules instead of galaxy. That way you can make sure that the correct versions of your dependencies are available at any time.

toydarian
  • 4,246
  • 5
  • 23
  • 35
  • 1
    "Once a developer had a dependency problem and decided to use git submodules to solve it. Now there are 2 problems to address" (freely adapted from an anonymous source I totally forgot on the web...) => my 2 cent: use `ansible-galaxy` with a requirement file. It is a much better way than git submodules to make sure your role dependencies have the correct version and that your team modifications (root project and dependent roles) are correctly committed, pushed and shared. This also lets you add other roles sources than your git repo and decide where you want to install them. – Zeitounator Apr 06 '21 at 11:08
  • Thank you toydarian and Zeitounator. I definitely want to use requirements.yml, however my open problem to solve is, is there a better way to avoid manually executing ansible-galaxy install -r requirements.yml everytime? – suj Apr 06 '21 at 23:40
  • I actually have a similar problem and haven't found a "clean" solution, yet. With submodules I only named an alternative, I didn't say it is better or even good (I'm not too happy with it, tbh). There are many pros and cons with submodules, galaxy etc. I don't like the way galaxy handles, tbh. Eg. I haven't found a "good" way to update a role installed by galaxy other than removing and re-installing it again. (I'm not saying it does not exist). Maybe @Zeitounator has a suggestion, but if you want to use galaxy, I don't see a way around executing that command. – toydarian Apr 07 '21 at 05:52
  • `ansible-galaxy role install -fgr roles/requirements.yml`. It does overwrite the existing roles though – Zeitounator Apr 07 '21 at 06:21