ppsh

package module
v0.0.0-...-e6febe7 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 11 Imported by: 0

README

ppsh -- Pull/Push via SSH

PPSH is a Ansible-like Tool and Library written in Go. Ansible is a radically simple IT automation system, and it is Awesome, but it is written in Python and needs Python installed and sometime annoyed configurations, so here comes PPSH. You just need the precompile bin file and a well defined YAML file (see more examples in app/file) to run it, and for simple tasks you even just run it with the well defined arguments. PPSH is also a library and can be easily integrated into your application. More detail will come soon...

Build

make

App Usage

$ ./ppsh help
NAME:
   ppsh - Pull or Push via SSH in your cluster hosts.

USAGE:
   ppsh [global options] command [command options] [arguments...]

VERSION:
   0.0.1

COMMANDS:
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --hosts HOST[;HOST], -H HOST[;HOST]                       host list, in the form of HOST[;HOST]
   --cmds CMD[;CMD], -c CMD[;CMD]                            command list, in the form of CMD[;CMD]
   --ciphers CIPHER[;CIPHER], -C CIPHER[;CIPHER]             cipher list, in the form of CIPHER[;CIPHER]
   --ip-range IP-IP[;{IP-IP|IP/XX}, -I IP-IP[;{IP-IP|IP/XX}  ip range, in the form of IP-IP[;{IP-IP|IP/XX}
   --user USER, -u USER                                      ssh login USER (default: "root")
   --password PASSWORD, -w PASSWORD                          ssh login PASSWORD
   --cert-key FILE, -k FILE                                  ssh private key FILE
   --playbook FILE, -p FILE                                  load playbook from path FILE
   --taskbook FILE, -t FILE                                  load taskbook from path FILE
   --format PLAIN|JSON, -f PLAIN|JSON                        output as PLAIN|JSON (default: "plain")
   --platform LINUX|OTHER, -S LINUX|OTHER                    platform as LINUX|OTHER (default: "linux")
   --output STDOUT|FILE, -o STDOUT|FILE                      output to STDOUT|FILE (default: "stdout")
   --timeout TIMEOUT, -s TIMEOUT                             TIMEOUT in second (default: 30)
   --port PORT, -P PORT                                      ssh PORT (default: 22)
   --max-run-count COUNT, -n COUNT                           max runing COUNT (default: 20)
   --help, -h                                                show help
   --version, -v                                             print the version

See more examples in app/file/test.txt.

As Library

See more details in godoc.

Roadmap

  • Upload files
  • Download files

License

MIT License, see detail in LICENSE.

Documentation

Index

Constants

View Source
const (
	LINUX = "linux"
	OTHER = "other"
)

Variables

This section is empty.

Functions

func Do

func Do(user, password, host, key string, port int, timeout int, ciphers, cmds []string, flatform string, ch chan Result)

func ParseIPRange

func ParseIPRange(addrs string) (ips []string)

ParseIPRange parses addr(s) into a list of IPs.

Types

type Format

type Format int
const (
	JSON Format = iota + 1
	PLAIN
)

type Host

type Host struct {
	UUID     string   `yaml:"-"`
	IP       string   `yaml:"ip"`
	Port     int      `yaml:"port"`
	User     string   `yaml:"user"`
	Password string   `yaml:"password"`
	CertKey  string   `yaml:"cert-key"`
	Ciphers  []string `yaml:"ciphers"`
	Tasks    []string `yaml:"tasks"`
	Taskbook string   `yaml:"taskbook"`
	Result   Result   `yaml:"-"`
	Platform string   `yaml:"platform"`
	Timeout  int      `yaml:"timeout"`
}

func (*Host) ParseTaskbook

func (h *Host) ParseTaskbook() error

type Platform

type Platform string

type Playbook

type Playbook struct {
	Path   string
	Hosts  []Host
	Out    io.Writer
	Format Format
	MaxNum int
}

Playbook is a book to be played.

func NewPlaybook

func NewPlaybook(path string, out io.Writer, format Format, max int) *Playbook

NewPlaybook return a new playbook.

func (*Playbook) Parse

func (p *Playbook) Parse() error

Parse parse the playbook.

func (*Playbook) Play

func (p *Playbook) Play() []Result

Play executes the palybook.

func (*Playbook) StreamOut

func (p *Playbook) StreamOut()

StreamOut show the results.

type Result

type Result struct {
	UUID    string `json:"uuid,omitempty"`
	Host    string `json:"host"`
	Cmd     string `json:"cmd"`
	Success bool   `json:"success"`
	Code    int    `json:"code,omitempty"`
	Detail  string `json:"detail,omitempty"`
	Error   string `json:"error,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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