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?

  • It sounds like you would prefer something with an imperative format, rather than the declarative interface that Ansible give you. Is this correct? May 27 '20 at 9:24
  • 1
    The closest I could come to a suggestion that respects your "straight python" requirement was pulumi. However, that doesn't remove the need for configuration management... May 27 '20 at 9:31
  • @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
    May 28 '20 at 21:46
  • 1
    fabric is straight python but I'm not sure it passes the "preserve some of those nice things from ansible" threshold. Jun 16 '20 at 0:54
  • Wouldn't writing your own modules be the way to express your wishes in straight python?
    – LLlAMnYP
    Jun 19 '20 at 19:29

pyinfra was designed for this purpose. Fabric can also be used to script configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.