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

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

Owner
Kristoffer Lorentsen
Kristoffer Lorentsen
Similar Resources

go-wrk - a HTTP benchmarking tool based in spirit on the excellent wrk tool (https://github.com/wg/wrk)

go-wrk - an HTTP benchmarking tool go-wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CP

Jan 5, 2023

Fortio load testing library, command line tool, advanced echo server and web UI in go (golang). Allows to specify a set query-per-second load and record latency histograms and other useful stats.

Fortio load testing library, command line tool, advanced echo server and web UI in go (golang). Allows to specify a set query-per-second load and record latency histograms and other useful stats.

Fortio Fortio (Φορτίο) started as, and is, Istio's load testing tool and now graduated to be its own project. Fortio is also used by, among others, Me

Jan 2, 2023

Go Interface Mocking Tool

Charlatan Percolate's Go Interface Mocking Tool. Please read our introductory blog post. Installation go get github.com/percolate/charlatan Usage c

Nov 3, 2022

A tool for generating self-contained, type-safe test doubles in go

counterfeiter When writing unit-tests for an object, it is often useful to have fake implementations of the object's collaborators. In go, such fake i

Jan 5, 2023

Lightweight service virtualization/API simulation tool for developers and testers

Lightweight service virtualization/API simulation tool for developers and testers

API simulations for development and testing Hoverfly is a lightweight, open source API simulation tool. Using Hoverfly, you can create realistic simul

Dec 28, 2022

Powerful mock generation tool for Go programming language

Summary Minimock generates mocks out of Go interface declarations. The main features of minimock are: It generates statically typed mocks and helpers.

Dec 17, 2022

A next-generation testing tool. Orion provides a powerful DSL to write and automate your acceptance tests

Orion is born to change the way we implement our acceptance tests. It takes advantage of HCL from Hashicorp t o provide a simple DSL to write the acceptance tests.

Aug 31, 2022

Stress testing and benchmarking tool for the NEAR EVM

evm-bully --- stress testing and benchmarking tool for the NEAR EVM

May 30, 2022

HTTP load testing tool and library. It's over 9000!

HTTP load testing tool and library. It's over 9000!

Vegeta Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a

Jan 7, 2023
Comments
  • Add plugin support

    Add plugin support

    Hey,

    So here is the PR to add plugin support. I created a folder called recipes and store different states there. To use them in the code:

    • go to one of the recipe directories and run go build -buildmode=plugin. This will create a .so file with the directory name. (mysql.so or tree.so)

    • Gossh has a flag now for the recipeName. ./gossh -recipeName recipes/tree/tree.so, will install that plugin to the program and print it.

    • You can distribute .so files independently from the code (put not from OS) and just put them near your binary.


    Feel free to ignore the PR, it's just an exploration around your code with respect to #1

  • Great project, can run in parallel

    Great project, can run in parallel

    Hello, great project !!! I wrote a something similar for Kubernetes state in https://github.com/atakanyenel/Passa.

    • One improvement I realised so far, you can use goroutines in state.Apply(). All machines are connected separately and don't need to wait for each other. This will improve the setup time when there are many machines with slower connections.

    • One extension process can be to use golang plugins, instead of compiling the state in the binary itself. That way , you deploy a single binary and people can give their state via plugins. Your interface for now is pretty stable, so it would be easy. It might contradict with your way of "no YAML", but it's still go code with type safe.

    • One configuration you can do is to get sudopass for ssh through env variable. Because currently a decompilation of the executable will give the plaintext password with the address.

    I will be following this project and contribute to it if I can :)

Create your own mock server with just a JSON file!

Gmocker Run a blazing fast mock server in just seconds! ?? All you need is to make a json file that contains path and response mapping. See an example

Dec 21, 2022
Create your own blazing fast mock server with just a JSON file!

Gmocker Run a blazing fast mock server in just seconds! ?? All you need is to make a json file that contains path and response mapping. See an example

Dec 21, 2022
Rest API to receive solana tokens in testnet just like a faucet

solana-example Rest API to receive solana tokens in testnet just like a faucet Running go run main.go Test Request airdrop curl --header "Content-Type

Oct 14, 2021
Just Dance Unlimited mock-up server written on Golang and uses a popular Gin framework for Go.

BDCS Just Dance Unlimited mock-up server written on Golang and uses a popular Gin framework for Go. Features Security Authorization works using UbiSer

Nov 10, 2021
This is just a repository to play around with Generics and Fuzzing, two big things coming with go 1.18!

This is just a repository to play around with Generics and Fuzzing, two big things coming with go 1.18!

Feb 6, 2022
A yaml data-driven testing format together with golang testing library

Specimen Yaml-based data-driven testing Specimen is a yaml data format for data-driven testing. This enforces separation between feature being tested

Nov 24, 2022
go-test-trace is like go test but it also generates distributed traces.
go-test-trace is like go test but it also generates distributed traces.

go-test-trace go-test-trace is like go test but it also generates distributed traces. Generated traces are exported in OTLP to a OpenTelemetry collect

Jan 5, 2023
Clean database for testing, inspired by database_cleaner for Ruby

DbCleaner Clean database for testing, inspired by database_cleaner for Ruby. It uses flock syscall under the hood to make sure the test can runs in pa

Nov 17, 2022
API testing framework inspired by frisby-js
API testing framework inspired by frisby-js

frisby REST API testing framework inspired by frisby-js, written in Go Proposals I'm starting to work on frisby again with the following ideas: Read s

Sep 27, 2022
ESME is a go library that allows you to mock a RESTful service by defining the configuration in json format

ESME is a go library that allows you to mock a RESTful service by defining the configuration in json format. This service can then simply be consumed by any client to get the expected response.

Mar 2, 2021