Generic ansible roles can be shared through ansible galaxy, however, its hard to access ansible-galaxy from within corporate network. A good alternative is to host something similar to ansible-galaxy on-prem.
On-prem galaxy repository
- For this blog stash is considered (https://stash.company.com), however, gitlab, gogs or similar should work as well
- Create a new project on stash
Ansible Galaxywith key
- Create repo for each generic ansbile role.
- All generic ansbile roles can be browsed at https://stash.company.com/projects/AG
- Now these roles can be used with multiple ansible playbooks.
- Create a new file
- For this blog purposes I am considering
awsclias an generic ansible role with its own repo, which resides in our newly created stash project
Ansible Galaxy (AG)
- Copy/paste below content to
--- 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
requirements.ymlfiles acts as a role dependency list for our
- 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