Jay Taylor's notes
back to listing indexHow to automatically install Ansible Galaxy roles?
[web search]
All my Ansible playbooks/roles are checked in to my git repo. However, for Ansible Galaxy roles I always have to explicitly download them one by one on every machine I want to run Ansible from. It's even tough to know in advance exactly which Ansible Galaxy roles are needed until Ansible complains about a missing role at runtime. How is one supposed to manage the Ansible Galaxy role dependencies? I would like to either have them checked into my git repo along with the rest of my ansible code or have them automatically be identified and downloaded when I run Ansible on a new machine. |
||||
You should use a
Then install them:
Here's a working example (installing OpenDaylight using Ansible as a Vagrant provisioner). See the relevant Ansible docs for more info. |
|||||||||
|
Another solution is to use git submodules. After all, Ansible Galaxy only is a directory of github repositories... I use this command to automatically add any Galaxy role as a submodule:
Commit the changes then to your git repo. When you clone your repo in future make sure to clone it with submodules, e.g. An advantage of this is, a git submodule is always referencing a specific version (git commit-hash). This will prevent you from running untested updates in your productive environment. A new version of a Galaxy role could have bugs or work completely different than before. With a git submodule you decide if and when you update a role to the new version. Also, you won't have to additionally take care of blacklisting galaxy roles in your |
||||
Some time ago I had exactly the same problem, and i have created a script for that. It gathers role dependencies from the meta/main.yml file, and then downloads them from ansible galaxy. You can find the script here: https://github.com/rtuin/ansible-install-dependencies I hope this is a solution for your problem. |
|||
As suggested, you can use ansible galaxy for this need. If you would like to further automate it then, you can add ansible galaxy inside your playbooks. For example:
|
|||
At this point in time, as far as I know there's no automatic way to download roles at runtime. Your best bet is to either commit them into your own repo or have a proper documentation listing all the requirements. You could even create a pre-flight playbook that installs your roles. :) |
|||||||||
|
Your Answer
Not the answer you're looking for? Browse other questions tagged ansible ansible-playbook ansible-galaxy or ask your own question.
asked |
1 year ago |
viewed |
3061 times |
active |
Get the weekly newsletter! In it, you'll get:
- The week's top questions and answers
- Important community announcements
- Questions that need answers
see an example newsletter
Related
Hot Network Questions
- About the notation of XOR-SAT
- Invoking a function without parentheses
- SSH gateway server
- Why was radio contact with Pioneer lost earlier than with Voyager?
- How to handle players who make unmotivated characters
- Can a functional be expressed by an inner product in an infinite-dimensional space?
- How is y’all’dn’t’ve pronounced
- Is it OK to go to postdocs for help?
- How to motivate students you supervise to produce high-quality research when other graduate students in the program don't?
- Right curly brace at the end of an equation
- Why do the characters in The Big Short talk directly to camera?
- Co-worker regularly placing his foot on my desk - how to get out of the situation?
- How can one point to one's consciousness?
- Hellish Rebuke reaction with zero hitpoints
- How did Luke get his lightsaber back after A New Hope?
- What is the point of using an open source and secure OS if you are running it on a machine with closed source firmware?
- Idiom or proverb that implies " the evidence contradicts what you claim"
- Is it good to read notes during a presentation?
- How long does it take to refuel a big jumbo jet?
- What is the difference between the mitotic spindle and microtubules?
- How do actors avoid looking into the camera?
- Which word is used incorrectly in this sentence?
- A skill that you have, but has little to no benefit for you
- Why does matter exist in 3 states (liquids, solid, gas)?
Technology | Life / Arts | Culture / Recreation | Science | Other | ||
---|---|---|---|---|---|---|