Giter VIP home page Giter VIP logo

pysible's Introduction

Beautiful Pythonic Ansible (RFC)

Ansible's declarative style makes it very easy to do configuration management. While the idea of ansible is a pretty good one, its YAML playbooks often confuse people. With the addition of blocks in Ansible 5.3, Ansible is looking more and more like a programming language.

However, readability is key and Ansible sometimes fails to deliver the user experience you would like to. Imagine a much simpler workflow. Instead of:

- name: Clone git repositories
  git: repo={{ item.repo }}
       dest={{ item.path }}
       clone=yes
       update=yes
  register: repository_update
  with_items:
    - { repo: "{{ repo1 }}", path: "/foo" }
    - { repo: "{{ repo2 }}", path: "/bar" }

- name: Next task

you could just write:

from pysible.modules import git

# Clone git repositories
for repo, dest in [(REPO, '/foo'), (REPO2, '/bar')]:
    last_update = git(repo=REPO, dest=REPO, clone=True, update=True)

# Next task

This allows for a lot more flexibility. Instead of includes you use simple functions and instead of roles... Well don't even get me started on that. I think that instead of using a pseudo language in YAML, using Python has the advantage of clean proper coding with all the advantages a language like Python comes in. Additionally we don't really have to give up Ansible features. We can use handlers, includes and modules like before. Just with a slightly different API.

It would be a brave new world, but finally there would be beautiful deployment code!

Running would be as simple as running Ansible. A simple command pysible <playbook> -i <hosts-file> would be enough to trigger execution on a few hosts. This command would ensure that host files could still be used (including host/group variables).

Implementation

At the moment there is a proof of concept that I won't publish, yet. However if you would like to see this, start a conversation in the issue tracker or star the repository.

The current implementation is merely 30 lines long, because I'm using ansible's internal APIs. I'm thinking about publishing this tool.

pysible's People

Contributors

davidhalter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

pombredanne

pysible's Issues

How to handle indempotency and a declarative approach

One problem I see with your proposed new pythonic approach is that when you start using a fully fledged programming language to describe your infrastructure it becomes much harder to guarantee indempotency of your playbooks and to keep a declarative approach to configuration management. IMO this is the main reason why most (all?) configuration management implement their own DSL (Domain specific language).

By declarative approach I mean that you want to describe the state your infrastructure should have instead of how to get there.

Publish?

I would definitely like to see this. It sounds like it would be fairly easy to support if there's so little code.

So publish it already...

There's already at least one other project like this. Yours may have the value of "more simplicity". But who knows, we can't see it.

thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.