<p><a href="https://pyinfra.com/" rel="nofollow noreferrer">pyinfra</a> was designed for this purpose. <a href="https://www.fabfile.org/" rel="nofollow noreferrer">Fabric</a> can also be used to script configuration.</p>

CC BY-SA 4.0
2021-02-11T14:44:16.617Z
2021-02-11T14:44:16.617Z
eradman
<p>Can anyone recommend an alternative to Ansible that lets one write straight Python code? In my group, we're finding that expressing pretty simple logic in Ansible ends up being too time-consuming and ugly to specify. Also, the bunny trails that you end up going down to debug simple Ansible problems take way too much time.</p>

<p>Sometimes it takes hours to do (or debug) something that would take 30 seconds in straight Python.</p>

<p>The nice things about Ansible are:</p>

<ul>
<li>A nice set of concepts like roles, hosts, tasks, and playbooks.</li>
<li>A nice library of preexisting modules.</li>
</ul>

<p>.. but if one were looking for something that preserves some of those nice things from Ansible, but allows one to write straight Python for all of the configuration and logic, are there any recommendations?</p>

CC BY-SA 4.0
2020-05-27T09:24:48.197Z
It sounds like you would prefer something with an imperative format, rather than the declarative interface that Ansible give you. Is this correct?
Bruce Becker
CC BY-SA 4.0
2020-05-27T09:31:12.490Z
The closest I could come to a suggestion that respects your "straight python" requirement was [pulumi](https://www.pulumi.com/docs/intro/vs/chef_puppet_etc/). However, that doesn't remove the need for _configuration management_...
Bruce Becker
CC BY-SA 4.0
2020-05-28T21:46:04.427Z
@BruceBecker Yeah, either that or some combination where you use an imperative language to build up the "this is the state I want" data structure.
Mike
CC BY-SA 4.0
2020-06-16T00:54:22.453Z
[fabric](http://www.fabfile.org/) is straight python but I'm not sure it passes the "preserve some of those nice things from ansible" threshold.
Zeitounator
CC BY-SA 4.0
2020-06-19T19:29:41.897Z
Wouldn't writing your own modules be the way to express your wishes in straight python?
LLlAMnYP
CC BY-SA 4.0
2021-02-12T21:40:35.663Z
Better use your own module or run your scripts over ansible. You will enjoy both flavor simultaneously
again
CC BY-SA 4.0
2024-11-25T08:48:43.550Z
I personally used [Fabric](https://www.fabfile.org/) and [Attune](https://attuneops.io/) for writing in Python language.
chase
<ansible><configuration-management>
straight python alternative to ansible
Mike
# straight python alternative to ansible

(Asked by: username_0 on 2020-05-26)

Can anyone recommend an alternative to Ansible that lets one write straight Python code? In my group, we're finding that expressing pretty simple logic in Ansible ends up being too time-consuming and ugly to specify. Also, the bunny trails that you end up going down to debug simple Ansible problems take way too much time.

Sometimes it takes hours to do (or debug) something that would take 30 seconds in straight Python.

The nice things about Ansible are:

* A nice set of concepts like roles, hosts, tasks, and playbooks.
* A nice library of preexisting modules.

.. but if one were looking for something that preserves some of those nice things from Ansible, but allows one to write straight Python for all of the configuration and logic, are there any recommendations?

**Tags:** ansible, configuration-management

> **Comments:**
> **username_1**: It sounds like you would prefer something with an imperative format, rather than the declarative interface that Ansible give you. Is this correct?  
> **username_1**: The closest I could come to a suggestion that respects your "straight python" requirement was [pulumi](https://www.pulumi.com/docs/intro/vs/chef_puppet_etc/). However, that doesn't remove the need for _configuration management_...  
> **username_0**: @BruceBecker Yeah, either that or some combination where you use an imperative language to build up the "this is the state I want" data structure.  
> **username_2**: [fabric](http://www.fabfile.org/) is straight python but I'm not sure it passes the "preserve some of those nice things from ansible" threshold.  
> **username_3**: Wouldn't writing your own modules be the way to express your wishes in straight python?  
> **username_4**: Better use your own module or run your scripts over ansible. You will enjoy both flavor simultaneously  
> **username_5**: I personally used [Fabric](https://www.fabfile.org/) and [Attune](https://attuneops.io/) for writing in Python language.  

---

## 1 answers

### Answer by username_6 on 2021-02-11. Score: 3 | Accepted answer

[pyinfra](https://pyinfra.com/) was designed for this purpose. [Fabric](https://www.fabfile.org/) can also be used to script configuration.


---

