How to automate ansible automation runs from Python?

Hi All,

I have some ansible role structure which I use through playbooks in one of my gitlab repositories. Every time a developer needs to add a new service which uses some role/-s I manually update the code (eg. add a playbook, add some entries to defaults/main.yml, whatever needed).

I would like to automate this process from Python as this is our main language in our devops team. One of my dev coworkers passed me info about https://github.com/cookiecutter/cookiecutter and it seems quite reasonable. I am only wondering if there are other better options.

Has anyone created this kind of a setup? Any hints?

Thanks in advance & have a nice day!

Best Regards,
Rafal.

Hey,

I have worked with cookiecutter, and it is nice. Bear in mind though, that the initial Project configuration needs some work and thought. But when you have everything setup, then it can really cut your project creation times.

I cannot not really advise you on how to do it, beacuse even though we are using ansible everyone, has git their own small differences in project setup. But the cookicutter doc is sufficient to adapt the tipps given there to ansible. From there you have to see how you want to setup everything and what works best for you.

Cheers

Lars

Rafal,

I use and maintain two cookiecutter templates for creating Ansible roles.

https://github.com/samdoran/cookiecutter-ansible-role-multi
https://github.com/samdoran/cookiecutter-ansible-role

They may serve as a useful example for how to use cookiecutter. I haven’t found a better tool, though I stopped looking once I found cookiecutter since it met my needs.