genesis

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2016 License: MIT Imports: 6 Imported by: 0

README

Genesis

Genesis is a Go library for building stand-alone installers. It is intended as a configuration management utility for embedded systems, but it can be used for pretty much any system.

Genesis can install, uninstall (reverse all installation steps), and report status. You can construct groups of tasks, define sections, and have tasks/groups/sections run conditionally based on the actions of other tasks/groups/sections. You can tell it to re-run certain steps or sections, and/or to skip some.

Status

This is experimental software, with high API instability. However, I am currently using it in my own work.

Motivation

Traditional configuration management systems (chef, ansible, etc.) don't work well for embedded systems because they tend to assume:

  • the target is accessible by network and the network has been configured
  • the target is running an ssh server
  • supporting software has been installed (python, chef client, etc).

Genesis is designed to configure a system from scratch. See the doc directory for more information.

Example

Here is a very simple example:

package main

import (
    "github.com/wx13/genesis/installer"
    "github.com/wx13/genesis/modules"
)

func main() {

    inst := installer.New()
    defer inst.Done()

    inst.AddTask(modules.Mkdir{Path: "/tmp/genesis_example"})

    aptSection := installer.NewSection("Install some debian packages.")
    pkgs := []string{"git", "gitk", "tig", "screen"}
    for _, pkg := range pkgs {
        aptSection.AddTask(modules.Apt{Name: pkg})
    }
    inst.Add(aptSection)

}

which produces this:

genesis screenshot

See the example directory for more examples.

Build

To build the installer, first zip up the supporting files:

zip -r files.zip files

Now build the executable and append the zip file:

go build my_installer.go
cat files.zip >> my_installer
zip -A my_installer

This packages the zip file into the installer binary, so that it is completely standalone. Run the binary with the -install, -status, or -remove flags to install / check status / remove.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoerHash

func DoerHash(doer Doer) string

func ExpandHome

func ExpandHome(name string) string

ExpandHome expands a leading tilde to the user's home directory.

func FileExists

func FileExists(path string) bool

FileExists is a helper function to check if a file exists.

func IsRunning added in v0.2.0

func IsRunning(pattern string) (bool, error)

IsRunning checks to see if a process is running.

func StringHash

func StringHash(id string) string

Types

type Doer

type Doer interface {
	Do() (bool, error)
	Undo() (bool, error)
	Status() (Status, error)
	ID() string
}

Doer can do and undo things.

type Facts

type Facts struct {
	Arch     string
	ArchType string
	OS       string
	Hostname string
	Username string
}

Facts stores discovered information about the target system.

type Module

type Module interface {
	Install() (string, error)
	Remove() (string, error)
	Status() (Status, string, error)
	Describe() string
	ID() string
}

Module is an interface for all the modules.

type Status

type Status int

Status represents a Pass/Fail/Unknown.

const (
	StatusPass Status = iota
	StatusFail
	StatusUnknown
)

Directories

Path Synopsis
example
laptop command
simple command
Package installer is the installer for the genesis package.
Package installer is the installer for the genesis package.
Package modules provides some installer modules for the genesis package.
Package modules provides some installer modules for the genesis package.
Package store provides support for keeping track of changes to files.
Package store provides support for keeping track of changes to files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL