When I googled how to install private roles using
ansible-galaxy, I found suggestions such as, "use git+https://github.com/..." or even better, "I am not sure what you're doing, but it works for me (since Ansible 2.2)".
So, since neither of these suggestions helped me and because I am unable to find documentation with obvious examples, here is how you achieve this.
Assuming you have your ssh key and configuration figured out, put this into
- name: namespace.role
src: [email protected]:my-organization/private-repository.git
ansible-galaxy install requirements.yml to
git-clone the role using your ssh key.
(Hello again. I haven't blogged in a while. But since I'm growing weary of platforms such as medium. Here we go.)
I've recently spent ~~too much~~ a lot of time with Ansible. Once I got into the rhythm of playbooks, roles and maybe modules/libraries, I desperately needed a way to test my YAML. And by testing, I didn't mean the annoying linting that Ansible ships with, but actual (integration) tests to verify everything works.
Enter Molecule (and TestInfra)
Molecule seems to be the go to in the Ansible universe. It's an odd project — primarily because it's so undocumented (and I don't mean Python class docs, but human-readable examples).
One of the fun things about Molecule are drivers. Drivers allow me to use Docker, VirtualBox or a cloud service (like AWS, Azure, DO, Hetzner ;-)) to start instances that my playbook is run on (and then TestInfra runs assertions and collects the results). In the a nutshell, this is what Molecule does — think of it as test-kitchen.
Drivers and switching them
Drivers are crucial to a scenario. You can't, or shouldn't attempt to create a scenario and then switch it to another driver. When a scenario is initialised using a driver, it creates
destroy.yml (playbook) files. These files are highly specific to the driver and Molecule doesn't play well when these are incorrect, or even missing.
It took me too long to figure this out. Hence, I'm leaving a note here.
I'll promise I'll blog more. Again. Thanks for reading!