Skip to main content

Turn your infrastructure up to eleven!

Project description

decibel - Turn your Infrastructure up to 11!

Are you that IT-rockstar that Sophos makes commercials about, but you are stuck writing long-winding and full-of-boilerplate YAML files to set up your IT environment?

Do you wish your Infrastructure as Code-repository actually contained code, and not some Chomsky Type-2 markup language that requires you to carefully place everything in the right order?

Fear not, hear us out what decibel has to offer!

Python-based configuration with hard dependencies

Decibel uses Python for its configuration, basing it on classes and simple functions to define how things should run. Python decorators are used for controlling the flow of configuration, eliminating the need to define things in a certain order.

from decibel import Runbook
from decibel.ansible import apt, template, command
from decibel.flow import after, notify

class HAProxy(Runbook):
    def run_install(self):
        apt(
            name="haproxy",
            state="installed"
        )

    @after("run_install")
    def run_configure(self):
        template(
            src="files/haproxy.cfg.j2",
            dest="/etc/haproxy/haproxy.cfg"
        )
        if self.vars.datacenter.value() == "dc1":
            command("program --datacenter {{ datacenter }}")

    def reload_service(self):
        service(
            name="haproxy",
            state="restarted"
        )

Decibel resolves all dependencies between Runbooks and Runnables, and calculates the most optimal way to perform the configuration. Runbooks exist to group together certain steps of an installation, and can be used to parameterize common steps. Variables are both available to the Python-code, but are also exported to all tasks that run within a Runbook and can be used in Jinja2.

from haproxy import HAProxy
from decibel import Decibel


with Decibel() as ds:
    with ds.hosts("localhost", become=True):
        HAProxy(
            datacenter="dc1",
            backends=[
                "one.example.com",
                "two.example.com"
            ]
        )
    ds.run()

Forcing idempotence on the user

Ansible strives to have configuration be idempotent, and most modules are indeed that. There are however cases where simple modules are not idempotent by default because they require the user to configure not only what command to run, but the desired state the command should bring you to. Decibel will be default warn you of such cases, and provide helper functions to easily make your configurations desired-state based.

from decibel.ansible import command, stat
from decibel.dsl import gets

class Database(Runbook):
    def run_import(self):
        gets(
            stat(path="/tmp/mysql-import.log").stat.exists,
            command("mysql -e 'SELECT * FROM db'").ok
        ).via(
            command("mysql-import file.sql")
        )

Why is it called Decibel?

Well, see, I tried to name it DSLible, because the goal was to create a more DSL-like language to use for Ansible. But DSLible is very hard to say, and the most important thing about project names is how easy you can fit it into a workplace discussion. Decibel sounded close enough, and also happens to lay the ground for a really cheeky slogan.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydecibel-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydecibel-0.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file pydecibel-0.1.0.tar.gz.

File metadata

  • Download URL: pydecibel-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for pydecibel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 553d854b43ad41006e6a15b65edcec7735571cf731842ae95d1e3e751a33015a
MD5 8f5923ef414a59a8d9a8100972023ad0
BLAKE2b-256 15f45b9346e7f5fb4012acc97b860eccbd37c51ae88d79e773c9d95a3dcfe05b

See more details on using hashes here.

File details

Details for the file pydecibel-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pydecibel-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for pydecibel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0849f5b7430e560c1aa2efee438893f1245bd081f65a4dd6111b99fe3eda5dea
MD5 fa760afb66e8b5f802a975ac02ca87df
BLAKE2b-256 570de2612350f5bc56e7121e76bbdb918f6eb4f54716276c14083fae93627552

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page