befehl

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

README

befehl

Run arbitrary commands over ssh in mass

  • run the given payload(s) in PWD on host(s) in config.json.. up to 2000 at a time.

./befehl execute --runconfig config.json --routines 2000

Output of each payload run for every node will be in the log directory (by default, its $HOME/befehl/logs) in a file named after the machine it ran on.

An example runconfig (config.json shown above) is shown below:

{
  "payload": "integration_tests/examples/payload",
  "user": "root",
  "hosts": [{
      "host": "127.0.0.1",
      "port": 1000
    },
    {
      "host": "127.0.0.1",
      "port": 1001,
      "user": "snowflake",
      "payload": "integration_tests/examples/payload-override"
    },
    {
      "host": "127.0.0.1",
      "port": 1002
    },
    {
      "host": "127.0.0.1",
      "port": 1003
    },
    {
      "host": "127.0.0.1",
      "port": 1004
    }
  ]
}

As you can see, you can override the payload from the default, as 127.0.0.1:1001 is doing in the example above.

Configuration

You can configure befehl with a config file (~/.befehl.[toml|json|yaml]) any serialization format that upstream viper supports befehl supports for the config file. Valid configuration options:

[general]
logdir = "/home/ssullivan/log-special"
[ssh]
privatekeyfile = "/home/ssullivan/alt/id_rsa"
knownhostspath = "/home/asullivan/alt/.ssh/known_hosts"
hostkeyverificationenabled = true

Unless enabled as shown above, ssh known host verification is disabled.

Obtaining prebuilt binaries

Head on over to the releases page to get prebuilt binaries for your platform.

Building

Once you have your Go environment setup, it should be as simple as cloning this git repo and running make. The resulting binary will be located at _exe/befehl.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

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

func New

func New(options *Options) (*Instance, error)

func (*Instance) Execute

func (instance *Instance) Execute(routines int) error

type Options

type Options struct {
	PrivateKeyFile   string
	LogDir           string
	SshHostKeyConfig SshHostKeyConfig
	RunConfigPath    string
}

type RuntimeConfig added in v0.0.6

type RuntimeConfig struct {
	Payload string              `json:"payload"`
	Hosts   []RuntimeConfigHost `json:"hosts"`
	User    string              `json:"user"`
}

func GetRuntimeConfig added in v0.0.6

func GetRuntimeConfig(pathToRuntimeConfig string) (config RuntimeConfig, err error)

type RuntimeConfigHost added in v0.0.6

type RuntimeConfigHost struct {
	Host    string `json:"host"`
	Port    int    `json:"port"`
	User    string `json:"user"`
	Payload string `json:"payload"`
}

type SshHostKeyConfig

type SshHostKeyConfig struct {
	Enabled        bool
	KnownHostsPath string
}

Directories

Path Synopsis
cmd
helpers
integration_tests

Jump to

Keyboard shortcuts

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