pluginssh

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

README

ssh Plugin

This plugin connects to a remote system and performs a block of commands. It can extract variables from the shell back to the output of its enclosing step.

Configuration

An action of type ssh requires the following kind of configuration:

action:
  type: ssh
  configuration:
    # user name connecting to the machine
    user: ubuntu
    # target machine
    target: frontend.ha.example.org
    # intermediate machines
    hops:
    - bastion.example.org
    # the commands to be executed, with variable declarations for value extraction
    script: |-
      PID=$(systemctl show --property MainPID {{.input.serviceName}} | cut -d= -f2)
      SERVICE_UPTIME=$(ps -h -p ${PID} -o etimes)
    # value extraction
    result: 
      pid: $PID
      uptime: $SERVICE_UPTIME
    # credentials
    ssh_key: '{{.config.mySSHKey}}'

The output resulting from this configuration will be:

{
  "pid": "1234",
  "uptime": "876123"
}

Requirements

None by default. Ssh credentials should be retrieved from {{.config.[sshkey]}} rather than hardcoded on the template.

Documentation

Index

Constants

View Source
const (
	MaxHops     = 10
	ConnTimeout = 10 * time.Second
)

connection configuration values

Variables

View Source
var (
	Plugin = taskplugin.New("ssh", "0.1", execssh,
		taskplugin.WithConfig(configssh, ConfigSSH{}),
	)
)

ssh plugin opens an ssh connection and runs commands on target machine

Functions

This section is empty.

Types

type ConfigSSH

type ConfigSSH struct {
	User             string            `json:"user"`
	Target           string            `json:"target"`
	Hops             []string          `json:"hops"`
	Script           string            `json:"script"`
	Result           map[string]string `json:"result"`
	Key              string            `json:"ssh_key"`
	KeyPassphrase    string            `json:"ssh_key_passphrase"`
	AllowExitNonZero bool              `json:"allow_exit_non_zero"`
}

ConfigSSH is the data needed to perform an SSH action

Jump to

Keyboard shortcuts

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