nanocms_state

package
v0.0.0-...-eaafa95 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

NanoNanostate implementation. Nanostate example:

---------------------------------------------- id: some-Nanostate descr: This describes what this Nanostate is for.

state:

  maintain-database:
	- sshrunner:
	  - stop-db: systemctl stop postgresql.service
	  - backup-db: pg-backup /var/lib/pgsql/data /opt/backups/
	  - start-db: systemctl start postgresql.service
	- somemodule:
	  keyparam: valueparam
	  keyparam2: valueparam2
	  keyparam3: valueparam3

  some-other-group:
	- sshrunner:
	  - uptime: uptime
	  - id : cat /etc/machine-id

----------------------------------------------

In the example above, three fields are required:

  • id This an ID of the Nanostate. It is used for the reporting at the end.
  • descr: Description of the Nanostate. Also reporting.
  • state: This is the entire tree of the Nanostate structure. It has twofold tree: a group IDs with a list of modules and the params or commands below.

Currently only one module is implemented: sshrunner, which performs a series of synchronous commands in the order they were placed for orchestration purposes.

In the nanoNanostate groups are asynchronous, but the commands inside the groups are synchronous.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NanoStateIndex

type NanoStateIndex struct {
	// contains filtered or unexported fields
}

func NewNanoStateIndex

func NewNanoStateIndex() *NanoStateIndex

func (*NanoStateIndex) AddStateRoot

func (nsf *NanoStateIndex) AddStateRoot(pth string) *NanoStateIndex

AddStateRoot is used to chain-add another state root

func (*NanoStateIndex) AddStateRoots

func (nsf *NanoStateIndex) AddStateRoots(pth ...string) *NanoStateIndex

AddStateRoots is used to chain-add another state roots (array)

func (*NanoStateIndex) GetStateByFileName

func (nsf *NanoStateIndex) GetStateByFileName(name string) *NanoStateMeta

func (*NanoStateIndex) GetStateById

func (nsf *NanoStateIndex) GetStateById(id string) *NanoStateMeta

func (*NanoStateIndex) Index

func (nsf *NanoStateIndex) Index()

Index all the files in the all roots

type NanoStateMeta

type NanoStateMeta struct {
	Id       string
	Filename string
	Path     string
	Info     *os.FileInfo
}

type Nanostate

type Nanostate struct {
	Id     string
	Descr  string
	Groups []*StateGroup
}

func NewNanostate

func NewNanostate() *Nanostate

func (*Nanostate) Load

func (pb *Nanostate) Load(tree map[string]interface{}) error

Load Nanostate tree, which is already compiled statically and vaildated.

type StateGroup

type StateGroup struct {
	Id    string
	Group []*StateModule
}

type StateModule

type StateModule struct {
	Module       string
	Instructions []interface{}          // For modules that might be called multiple times. Usually a shell command.
	Args         map[string]interface{} // Modules, that are called only once.
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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