Skip to content
/ gossh Public

Configuration management tool inspired by Ansible, but with no yaml - just Go

License

Notifications You must be signed in to change notification settings

krilor/gossh

Repository files navigation

GOSSH

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 linux host
  • 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.

Building blocks

The package has only a handful main concepts or building blocks.

Rules

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.

Target

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)

Inventories

An Inventory is a list of Hosts.

Usage - give it a spin using docker

Please remeber that this is very experimental

Prerequisites:

  • Go
  • Docker

This is what you do:

  1. Clone this repo
  2. Build and run a SSH enabled Ubuntu container by running make docker
  3. Cd over to examples/random and try running it with go run main.go
  4. Have a look at the output
  5. Modify the example script however you like and run again.
  6. Kill and remove the container using make docker-down

Motivation

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.

Docs

SUDO

Gossh building blocks allows commands and rules to run as other users. It is done using Sudo.

References

Early feedback Reddit threads

Inspiration

This project is heavily inspired by

  • Pulumi
  • Puppet Bolt
  • Ansible
  • GOSS

Licence

GNU General Public License v3.0

About

Configuration management tool inspired by Ansible, but with no yaml - just Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages