Introspective peek into your infrastructure guts
Currently the most widely used tools for testing your infrastructure are serverspec and infrataster.
However these tools being written in ruby carry a decent amount of runtime an gem dependencies. Writing a simple tool in Go programming language would help to address runtime dependency "issue" and would further simplify the ditribution and speed of deployment of infrastructure.
Current project design might be a bit of an overkill mostly because of my Go incompetence or because the projects tries to create abstractions on top of already existing abstractions (package managers, commands etc.). Turns out modelling this is not that easy :-/
Project currently provides support for various package managers: apt
, yum
, apk
, gem
and pip
as well as file and service inspections. More resources will be added later as the project moves on [if].
The project does not offer a single program to run as it stands right now. Instead a simple API is provided that allows you to build your own go
binaries that can then be used to test your infrastrucure. Statically linked binary alleviates a necessity to have any language runtime available on the tested infrastructure servers. Obviously, you have an option to create your own _test.go
files that can be run using go test
, but like already said you will need to have the go
tool chain available on the tested server. The choice is really up to you, but my recommendation is to build and shipt the binaries.
Get the package:
$ go get github.com/milosgajdos/servpeek
Write a go program that does some testing:
package main
import (
"log"
"github.com/milosgajdos/servpeek/file"
"github.com/milosgajdos/servpeek/pkg"
)
func main() {
// Test if a gem package is installed
gemPkg, err := pkg.NewPackage("gem", "bundler", "1.10.6")
if err != nil {
log.Fatal(err)
}
if err := pkg.IsInstalled(gemPkg); err != nil {
log.Fatal(err)
}
// Test if /etc/hosts is a regular file
f := file.NewFile("/etc/hosts")
if err := file.IsRegular(f); err != nil {
log.Fatal(err)
}
}
You can find a more elaborate example program in the examples directory.