Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2021-02-11T14:44:16.617Z
Answers: 2021-02-11T14:44:16.617Z
Answers: eradman
Body: <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>
  
Comments: CC BY-SA 4.0
Comments: 2020-05-27T09:24:48.197Z
Comments: It sounds like you would prefer something with an imperative format, rather than the declarative interface that Ansible give you. Is this correct?
Comments: Bruce Becker
Comments: CC BY-SA 4.0
Comments: 2020-05-27T09:31:12.490Z
Comments: 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_...
Comments: Bruce Becker
Comments: CC BY-SA 4.0
Comments: 2020-05-28T21:46:04.427Z
Comments: @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.
Comments: Mike
Comments: CC BY-SA 4.0
Comments: 2020-06-16T00:54:22.453Z
Comments: [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.
Comments: Zeitounator
Comments: CC BY-SA 4.0
Comments: 2020-06-19T19:29:41.897Z
Comments: Wouldn't writing your own modules be the way to express your wishes in straight python?
Comments: LLlAMnYP
Comments: CC BY-SA 4.0
Comments: 2021-02-12T21:40:35.663Z
Comments: Better use your own module or run your scripts over ansible. You will enjoy both flavor simultaneously
Comments: again
Comments: CC BY-SA 4.0
Comments: 2024-11-25T08:48:43.550Z
Comments: I personally used [Fabric](https://www.fabfile.org/) and [Attune](https://attuneops.io/) for writing in Python language.
Comments: chase
Tags: <ansible><configuration-management>
Title: straight python alternative to ansible
UserDisplayName: Mike
ThreadText: # 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**: @username_1 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.
  
  
  ---
  
  