# Ansible but with Python instead of YAML

**URL:** <https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590>\
**Category:** Ansible Project\
**Created:** [February 1, 2019, 10:42am UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590 "2019-02-01T10:42:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Guttler](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@Thomas\_Guttler](https://forum.ansible.com/u/Thomas_Guttler)\
**Post date:** [February 1, 2019, 10:42am UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590/1 "2019-02-01T10:42:53Z")

</div>

I am using a different config management tool up to now (not ansible).

I think about switching to ansible.

But I don’t like YAML.

I like Python.

Is it doable to use Python syntax instead of YAML?

Is it feasible to do this?

---

<div class="post-metadata">

**Author:** ![Sudheer\_S1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@Sudheer\_S1](https://forum.ansible.com/u/Sudheer_S1)\
**Post date:** [February 1, 2019, 11:33am UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590/2 "2019-02-01T11:33:33Z")

</div>

Ansible embraces YAML. Technically, yes. But you’ll hardly reap the benefits of Ansible without YAML.

---

<div class="post-metadata">

**Author:** ![Thomas\_Guttler](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@Thomas\_Guttler](https://forum.ansible.com/u/Thomas_Guttler)\
**Post date:** [February 1, 2019, 1:07pm UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590/3 "2019-02-01T13:07:25Z")

</div>

I know how to create dicts, lists, strings, multiline-strings with python. The syntax is easy and simple.

I am lazy. I just don’t know why I should learn a new language.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [February 1, 2019, 1:56pm UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590/4 "2019-02-01T13:56:35Z")

</div>

if you know that then its pretty easy to leanr YML. Specially when the ansible documents have a lot of examples.

---

<div class="post-metadata">

**Author:** ![Josh\_Smift2](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Josh\_Smift2](https://forum.ansible.com/u/Josh_Smift2)\
**Post date:** [February 1, 2019, 2:20pm UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590/5 "2019-02-01T14:20:14Z")

</div>

YAML is great; I was confused at first because I thought it was a “markup language” like HTML, but it’s just a way to represent data structures.

It’s not a programming language, though. If you want to write your system configuration in a programming language (Python, in this case :^), you might want to check out OpsMop ([https://opsmop.io/](https://opsmop.io/)), the latest thing by the guy who originally wrote Ansible. My impression is that it’s still pretty bleeding-edge, but looks like it has promise.

---

<div class="post-metadata">

**Author:** ![CaptainBrewing](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@CaptainBrewing](https://forum.ansible.com/u/CaptainBrewing)\
**Post date:** [February 1, 2019, 2:26pm UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590/6 "2019-02-01T14:26:20Z")

</div>

I would take a look at Troposphere. It is a Python project that creates JSON / YAML for Cloudformation scripts. Very similar to what you want to do. I have not heard of the same project for Ansible

[https://github.com/cloudtools/troposphere](https://github.com/cloudtools/troposphere)

---

<div class="post-metadata">

**Author:** ![Thomas\_Guttler](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@Thomas\_Guttler](https://forum.ansible.com/u/Thomas_Guttler)\
**Post date:** [February 1, 2019, 3:48pm UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590/7 "2019-02-01T15:48:06Z")

</div>

Thank you for this hint. This sounds interesting: [https://medium.com/@michaeldehaan/16-ways-opsmop-improves-on-ansible-number-17-is-an-off-by-one-error-bf989420edca](https://medium.com/@michaeldehaan/16-ways-opsmop-improves-on-ansible-number-17-is-an-off-by-one-error-bf989420edca)

---

<div class="post-metadata">

**Author:** ![Thomas\_Guttler](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@Thomas\_Guttler](https://forum.ansible.com/u/Thomas_Guttler)\
**Post date:** [February 1, 2019, 3:54pm UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590/8 "2019-02-01T15:54:37Z")

</div>

Seems specific to AWS Cloudformation. But good news, I am not the only one who prefers python over yaml.

---

<div class="post-metadata">

**Author:** ![Stuart\_Longland](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@Stuart\_Longland](https://forum.ansible.com/u/Stuart_Longland)\
**Post date:** [February 2, 2019, 11:49pm UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590/9 "2019-02-02T23:49:05Z")

</div>

It's not a language, it's a serialisation format like JSON, it's a  
superset of JSON in fact. Ansible uses its syntax to define a language  
on top.

They could have equally used XML or JSON to do this. They chose YAML.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 6, 2019, 8:58pm UTC](https://forum.ansible.com/t/ansible-but-with-python-instead-of-yaml/29590/10 "2019-02-06T20:58:59Z")

</div>

It didn't last long, it's already discontinued ref. [https://github.com/opsmop/opsmop](https://github.com/opsmop/opsmop)
