On-prem ansible galaxy
Generic ansible roles can be shared through ansible galaxy though in many cases we can not use ansible galaxy as its hosted publicly. Solution is to host something similar to ansible galaxy on-prem.
On-prem galaxy repository
- For this blog I am considering stash (https://stash.company.com) but gitlab, gogs or similar should work as well
- Create a new project on stash
Ansible Galaxy
with keyAG
- Create repo for each generic ansbile role.
- We can browse through all the generic ansbile roles at https://stash.company.com/projects/AG
- Now these roles can be used with multiple ansible playbooks.
Usage
- Create a new file
requirements.yml
alongside ansibleplaybook.yml
. - For this blog purposes I am considering
awscli
as an generic ansible role with its own repo, which resides in our newly created stash projectAnsible Galaxy (AG)
Copy/paste below content to
requirements.yml
--- name: awscli src: git+https://stash.company.com/scm/ag/awscli version: master path: ~/.ansible/roles # name - name of role # src - location of role # version - which branch the role should be installed from # path - where we want to install roles
The
requirements.yml
files acts as a role dependency list for ourplaybook.yml
Installation
Once we define our ansible playbook dependencies, its time to install them.
sudo ansible-galaxy install -r requirements.yml # NOTE: no need to install ansible-galaxy seperately, it ships with default ansible installation
Done! all the roles are now installed and ready to be used by our
playbook.yml