0

We are working on converting our project to Ansible. Due to the scale of the project, we will need a large amount of roles (30+). Where we're running into problems is how to store and manage these roles. Things we have considered:

1) Github repo per role -> This is unrealistic. We don't want to manage 30+ git repositories simply for the purpose of maintaining our roles 2) Ansible Galaxy -> This would be valuable if we could have a local instance of Ansible Galaxy, but the central instance won't work 3) We can simply store the roles in a flat directory, however we lose the benefit of being able to version them in this case. There is also the matter of how to automatically push our ansible roles directories to the ansible controller host into the correct directory

Is there a solution I'm missing?

2
  • Is there any issue having all the roles in a git repo? Is because you want to have a requirements.yml for those roles? Commented Nov 16, 2018 at 5:49
  • Are the roles truly functionally separate? If not, then it may make sense to combine some of them into a few roles using tags or conditionals to manage execution. Commented Nov 16, 2018 at 12:13

1 Answer 1

2

I would suggest keeping the roles in a single git repo.

For the automatic push to the ansible controller, you could either create a standalone playbook that uses the git module to retrieve the appropriate version of the roles. This could then be run on a regular basis (or scheduled via cron).

Alternatively, you could add the git retrieval to your existing playbooks, and then it would check/update the roles prior to executing them.

3
  • 1
    I concur. I had close to 100 different Ansible roles and around a dozen playbooks using those roles for one project I worked on. All of them were stored in a single repo. Worked just fine. I didn't automatically pick up the new roles when running the playbooks. I made sure the directory was up to date manually, but it was just me and one other. So, we didn't have to worry a lot about not knowing when there were updates. :)
    – Lewis M
    Commented Nov 16, 2018 at 12:34
  • One followup to this, is how do you manage individual versions of the roles? For example certain roles require significantly different configuration based off of the version (Tomcat is a good example). So to install a specific role version we need to be able to reference it by version
    – pasquers
    Commented Nov 16, 2018 at 14:49
  • @pasquers So typically I use Tagging, and/or Variables that will retrieve the specific configuration values that I want. Then you can have multiple variable files under /var or /default that get referenced based on Tags or Version settings. Using jinja templates would be another possiblity. Commented Nov 20, 2018 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.