This repo is an experiement with creating a declarative IT automation and configuration management package for Golang. Think Ansible, but no Yaml, just plain Go. WOW - all teh power!
- Declarative - use
rules
to check and ensure state on any linuxhost
- Agentless - all work is done on remote hosts by issuing commands via SSH
- Efficient - leverage ready-made rules to kick-start your IT automation
The project is in a super-early state. I am looking for API/usage/naming convention input and ideas in general on how to approach this problem. Have a look at examples to get a feel for what I currently think it would look like to use the package. If you have any ideas please reach out through a GH issue.
The package has only a handful main concepts or building blocks.
The base building block of the declarative mindset baked into this experiment is the notion of a Rule. A rule is an interface with a single Ensure function. Ensure does what it sounds like: Ensure ensures the rule is adhered to on the target.
Ensuring is a two-step process - check and enforce. Enforcement is only done if the check was not successful.
An example of a rule is apt.Package. Check verifies if the apt package is installed or not, and enforcement is done by (un)installs the package.
Rules are made up of imperative code/logic, other declarative rules or a combination of both. Rules can be nested infinitely.
Rules
are applied to Targets
.
Implemented/example rules (just to show some ideas):
- file.Exists - creates an empty file if it does not exists
- apt.Package - install/uninstall apt packages
- base.Cmd - run shell commands as Check and Ensure. Check depends on the ExitStatus code.
- base.Meta - for constructing meta-rules on the fly. This is where imperative mode kicks in.
A Target is a bare-metal server, virtual machine or container. It can be localhost, a remote host (SSH) or a docker container on localhost.
(Current) Requirements
- Running Linux
- Bash shell available
- Sudo installed
- SSH'able (remote)
An Inventory is a list of Hosts.
Please remeber that this is very experimental
Prerequisites:
- Go
- Docker
This is what you do:
- Clone this repo
- Build and run a SSH enabled Ubuntu container by running
make docker
- Cd over to examples/random and try running it with
go run main.go
- Have a look at the output
- Modify the example script however you like and run again.
- Kill and remove the container using
make docker-down
I've recently listened to Pulumi: Infrastructure as Code with Joe Duffy on Software Engineering Daily. The vision and ideas behind Pulumi really resonated with me. The promise of no YAML or DSL - and just using a progamming language and tooling I allready enjoy - was very appealing. Combining a full-fledged programming language (with package management) with a declarative structural representation of the state sounds powerful and like something I would like to have.
Ansible has been my favorite CM tool for a while. It's awesome! But if I'm honest, I'm not really fond of all the YAML. I also find that I ofted need to do quite a lot of imperative things in the playbooks (register
& when
, I'm looking at you), which is awkward. What I do love about Ansible though, it it's simplicy and low learing curve and that it is agentless and does all it's work over SSH.
In essence, the experiment aims to take all the things I love about Ansible and bring all the nice things that Pulumi promises, but for configuration, not provisioning.
I think the Go language, typechecking, compile-time checks, standard library, package manager and simplicity makes it perfect starting point for nice configuration management tool.
Gossh building blocks allows commands and rules to run as other users. It is done using Sudo.
- 2020-03-28 Show me the gnarliest [Ansible] config you know?
- 2020-03-27 Declarative configuration management in Go? Need input on what you think Ansible with no YAML, only Go, should look like
This project is heavily inspired by
- Pulumi
- Puppet Bolt
- Ansible
- GOSS