nanocms_runners

package
v0.0.0-...-7574d5e Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ERR_OK      = 0
	ERR_FAILED  = 1
	ERR_TIMEOUT = 2 // Prepared, but unprocessed
	ERR_INIT    = 255
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseRunner

type BaseRunner struct {
	wzlib_logger.WzLogger
	// contains filtered or unexported fields
}

func (*BaseRunner) AddStateRoots

func (br *BaseRunner) AddStateRoots(roots ...string) *BaseRunner

AddStateRoots of the collections

func (*BaseRunner) Errcode

func (br *BaseRunner) Errcode() int

Errcode returns an error code of the runner

func (*BaseRunner) Response

func (br *BaseRunner) Response() *RunnerResponse

Response returns a map of string/any structure for further processing

func (*BaseRunner) Run

func (br *BaseRunner) Run(state *nanocms_state.Nanostate) bool

Run the compiled and loaded nanostate

type IBaseRunner

type IBaseRunner interface {
	// contains filtered or unexported methods
}

type LocalRunner

type LocalRunner struct {
	BaseRunner
	// contains filtered or unexported fields
}

func NewLocalRunner

func NewLocalRunner() *LocalRunner

func (*LocalRunner) SetChrootPath

func (lr *LocalRunner) SetChrootPath(root string) *LocalRunner

SetChrootPath to where explicitly chroot running modules

func (*LocalRunner) SetPyInterpreter

func (lr *LocalRunner) SetPyInterpreter(pyexe string) *LocalRunner

SetPyInterpreter to the local runner's Python written modules in Ansible. This is used to resolve Python dependencies, where Ansible library is mainly installed

type Runner

type Runner interface {
	// Run the compiled and loaded nanostate
	Run(state *nanocms_state.Nanostate) error

	// Response returns a map of string/any structure for further processing
	Response() map[string]interface{}

	// Errcode returns an error code of the runner
	Errcode() int
}

Interface for the runner

type RunnerHostResult

type RunnerHostResult struct {
	Host     string
	Response map[string]RunnerStdResult
}

type RunnerResponse

type RunnerResponse struct {
	Id          string
	Description string
	Groups      []RunnerResponseGroup
}

func (*RunnerResponse) JSON

func (rr *RunnerResponse) JSON() string

JSON output of the response structure

func (*RunnerResponse) PrettyJSON

func (rr *RunnerResponse) PrettyJSON() string

JSON output of the response structure

func (*RunnerResponse) Serialise

func (rr *RunnerResponse) Serialise() map[string]interface{}

Serialise to a map/interface object

type RunnerResponseGroup

type RunnerResponseGroup struct {
	GroupId  string
	Errcode  int
	Errmsg   string
	Response []RunnerResponseModule
}

type RunnerResponseModule

type RunnerResponseModule struct {
	Module   string
	Errcode  int
	Errmsg   string
	Response []RunnerHostResult
}

type RunnerStdResult

type RunnerStdResult struct {
	Stdout  string
	Stderr  string
	Errmsg  string
	Errcode int
	Json    map[string]interface{}
}

type SSHRunner

type SSHRunner struct {
	BaseRunner
	// contains filtered or unexported fields
}

func NewSSHRunner

func NewSSHRunner() *SSHRunner

func (*SSHRunner) AddHost

func (shr *SSHRunner) AddHost(fqdn string) *SSHRunner

AddHost appends another remote host

func (*SSHRunner) SetPermanentMode

func (shr *SSHRunner) SetPermanentMode(root string) *SSHRunner

SetPermanentMode takes a root path where it will will create the following structure:

  $ROOT/bin
	   /etc
	   /modules

In "bin" directory local runners are stored; "etc" contains possible configurations, if any; "modules" will stockpile on demand remote modules, if they are downloaded.

func (*SSHRunner) SetRSAKeys

func (shr *SSHRunner) SetRSAKeys(rsapath string) *SSHRunner

SetRSAKeys will set a root directory to the RSA keypair and "known_hosts" database file. If an empty string is provided, "$HOME/.ssh" is used instead.

func (*SSHRunner) SetRemoteUsername

func (shr *SSHRunner) SetRemoteUsername(username string) *SSHRunner

SetRemoteUserame sets remote username.

func (*SSHRunner) SetSSHHostVerification

func (shr *SSHRunner) SetSSHHostVerification(hvf bool) *SSHRunner

SetSSHHostVerification enables (true, default) or disables (false) the remote host verification, based on the "known_hosts" database.

func (*SSHRunner) SetSSHPort

func (shr *SSHRunner) SetSSHPort(port int) *SSHRunner

SetSSHPort sets an alternative SSH port if needed. Default is 22.

func (*SSHRunner) SetStaticDataRoot

func (shr *SSHRunner) SetStaticDataRoot(root string) *SSHRunner

SetStaticDataRoot is a directory where runners and other client-related data is located. Static directory should have a specified structure. For example, for runners it should be "runners/<ARCH>/", e.g. "runners/x86_64/", "runners/arm/" etc.

func (*SSHRunner) SetUserRSAKeys

func (shr *SSHRunner) SetUserRSAKeys(username string) *SSHRunner

SetUserRSAKeys will set a root directory to the RSA keypair and "known_hosts" database file based on "$HOME/.ssh" from the given username. If an empty string passed, current user is chosen.

type SSHSession

type SSHSession struct {
	Session *ssh.Session
	Id      string
	Outbuff bytes.Buffer
	Errbuff bytes.Buffer
}

func NewSSHSession

func NewSSHSession(ctx *ssh.Client) *SSHSession

func (*SSHSession) Run

func (ss *SSHSession) Run(cmd string) (string, error)

Run a command

type SshShell

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

func NewSshShell

func NewSshShell(rsa string) *SshShell

Constructor. Needs to be given a location of SSH keys, including "known_hosts". As an example: "/home/someuser/.ssh".

func (*SshShell) Connect

func (ns *SshShell) Connect() *SshShell

Connect opens an SSH connection to the remote machine

func (*SshShell) Disconnect

func (ns *SshShell) Disconnect() *SshShell

Disconnect closes the SSH connection

func (*SshShell) GetFQDN

func (ns *SshShell) GetFQDN() string

GetFQDN of the remote host

func (*SshShell) NewSession

func (ns *SshShell) NewSession() *SSHSession

func (*SshShell) SetFQDN

func (ns *SshShell) SetFQDN(fqdn string) *SshShell

SetFQDN of the node that is going to be staged

func (*SshShell) SetHostVerification

func (ns *SshShell) SetHostVerification(hv bool) *SshShell

SetHostVerification to true or false on SSH connection. Default is set to True.

func (*SshShell) SetPort

func (ns *SshShell) SetPort(port int) *SshShell

SetPort the opened SSH port on the node that is going to be staged. Default is a standard 22.

func (*SshShell) SetRSAPrivKey

func (ns *SshShell) SetRSAPrivKey(name string) *SshShell

SetRSAPrivKey sets a path to the private RSA key for the SSH connection.

func (*SshShell) SetRSAPubKey

func (ns *SshShell) SetRSAPubKey(name string) *SshShell

SetRSAPubKey sets a path to the public RSA key for the SSH connection. This key should be deployed to the target node.

func (*SshShell) SetRemotePassword

func (ns *SshShell) SetRemotePassword(password string) *SshShell

SetRemotePaassword sets remote password for the username. If password is not set, keypair authentication is used instead.

func (*SshShell) SetRemoteUsername

func (ns *SshShell) SetRemoteUsername(username string) *SshShell

SetRemoteUsername sets remote username. Default is the current username.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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