# How to automate ansible automation runs from Python?

**URL:** <https://forum.ansible.com/t/how-to-automate-ansible-automation-runs-from-python/34190>\
**Category:** Ansible Project\
**Created:** [November 12, 2020, 5:00pm UTC](https://forum.ansible.com/t/how-to-automate-ansible-automation-runs-from-python/34190 "2020-11-12T17:00:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafal\_Radecki](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@Rafal\_Radecki](https://forum.ansible.com/u/Rafal_Radecki)\
**Post date:** [November 12, 2020, 5:00pm UTC](https://forum.ansible.com/t/how-to-automate-ansible-automation-runs-from-python/34190/1 "2020-11-12T17:00:12Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![Lars\_Liedtke](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Lars\_Liedtke](https://forum.ansible.com/u/Lars_Liedtke)\
**Post date:** [November 13, 2020, 8:10am UTC](https://forum.ansible.com/t/how-to-automate-ansible-automation-runs-from-python/34190/2 "2020-11-13T08:10:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sdoran](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@sdoran](https://forum.ansible.com/u/sdoran)\
**Post date:** [November 17, 2020, 2:57pm UTC](https://forum.ansible.com/t/how-to-automate-ansible-automation-runs-from-python/34190/3 "2020-11-17T14:57:48Z")

</div>

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-multi)  
[https://github.com/samdoran/cookiecutter-ansible-role](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.
