# Ansible and ease of use in Python

**URL:** <https://forum.ansible.com/t/ansible-and-ease-of-use-in-python/16774>\
**Category:** Ansible Developer\
**Created:** [November 13, 2014, 1:25pm UTC](https://forum.ansible.com/t/ansible-and-ease-of-use-in-python/16774 "2014-11-13T13:25:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pripravto\_zd](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@pripravto\_zd](https://forum.ansible.com/u/pripravto_zd)\
**Post date:** [November 13, 2014, 1:25pm UTC](https://forum.ansible.com/t/ansible-and-ease-of-use-in-python/16774/1 "2014-11-13T13:25:29Z")

</div>

Hello,

several months ago together with my brother we have started to work on [Ansiblator](https://pypi.python.org/pypi/ansiblator)\> Python wrapper modul which makes Ansible more easy to use in Python itself. It is just base class which should make other corresponing efforts to be quicker and easier. Other part is DictToInventory converter.

```auto
import ansiblator.api as an
ans = an.Ansiblator()
ans.run("uname -a", now=True)
ans.run("uptime")
ans.run_all()
ans.user(name="hugo", sudo=True)
ans.copy(src="/tmp/aabc.csv", dest="/tmp/",pattern="pc",now=True)

```

Before I had talked with project leader by email (mainly about license). Main thing why I am writing here is because, now it feels, that it could be improved more, for example maybe somehow implemented inside of Ansible modules. Another thing is to improve it itself. Ansiblator always always uses new runner for each run, it can get really slow beacause it is not using playbooks-runner (it continues to stay in connection). So the question if somehow we could improve this, to be Ansible more usefull inside Python it self. For example I think that Fabric api is more clean and more nicer to use in Python itself.

another main use are custom classes:

`

```auto
class Automatization(Ansiblator):

    def update_server(self, su=True,sudo=False):
        self.run("apt-get update", su=su, sudo=sudo)
        self.run("apt-get upgrade -y", su=su, sudo=sudo)

```

#use custom class and more patterns together:

```auto
ans = Automatization(pattern=['servers', 'production', 'test', 'pc'], sudo=True)
ans.update_server()

```

`

There is probably another similar project on [https://pypi.python.org/pypi/suitable/](https://pypi.python.org/pypi/suitable/)

Anyway, we will continue on work for ansiblator, as we are already using it for our service, where we need direct control from Python.

Regards,  
zd

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 14, 2014, 6:05pm UTC](https://forum.ansible.com/t/ansible-and-ease-of-use-in-python/16774/2 "2014-11-14T18:05:12Z")

</div>

Hi, we’re currently refactoring Ansible in a “v2/” tree which will change the way the Runner API works a bit.

Please stay tuned.

The above project will most definitely be broken by this change.

---

<div class="post-metadata">

**Author:** ![pripravto\_zd](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@pripravto\_zd](https://forum.ansible.com/u/pripravto_zd)\
**Post date:** [November 14, 2014, 6:45pm UTC](https://forum.ansible.com/t/ansible-and-ease-of-use-in-python/16774/3 "2014-11-14T18:45:33Z")

</div>

Hello,

well that’s good to hear. And if it will make main Ansible API for Python more attractive and easier, then it’s probably perfect and better than this project.  
Anyway, thanks for information. Do you already have some kind of plan/idea how it will turn out, and if it will be more useful in Python itself?

Thanks

---

<div class="post-metadata">

**Author:** ![Chris\_Church1](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Church1](https://forum.ansible.com/u/Chris_Church1)\
**Post date:** [November 15, 2014, 9:04pm UTC](https://forum.ansible.com/t/ansible-and-ease-of-use-in-python/16774/4 "2014-11-15T21:04:39Z")

</div>

The v2 tree Michael mentioned is in the ansible repo, so you can at least  
see where things are headed:

[https://github.com/ansible/ansible/tree/devel/v2/ansible](https://github.com/ansible/ansible/tree/devel/v2/ansible)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 16, 2014, 12:15am UTC](https://forum.ansible.com/t/ansible-and-ease-of-use-in-python/16774/5 "2014-11-16T00:15:21Z")

</div>

Yeah, no top end Runner API established just yet.

Soon.
