Gosible is a simple tool for batch remote task execution implemented in go language, just like ansible.
Installing
Using Gosible is easy. Use go get
to install the latest version of the library. This command will install the gosible
generator executable along with the library and its dependencies:
go get -u gitee.com/kevinxc/gosible/cmd/gosible
Usage
Gosible usage can be viewed using gosible -h
. currently, it supports the execution of SCP and SSH commands on batch nodes using SSH connections.
Example
gosible -h:
A simple tool for batch remote task execution implemented in go language
Usage:
gosible [command]
Available Commands:
completion generate the autocompletion script for the specified shell
help Help about any command
run Perform some operations
Flags:
-h, --help help for gosible
-v, --verbose Print detailed information (default true)
Use "gosible [command] --help" for more information about a command.
gosible run task -h:
Execute tasks on multiple remote hosts
Usage:
gosible run task [flags]
Flags:
-f, --file string Specify a config file path
-h, --help help for task
-p, --parralel Whether to execute tasks in parallel
-r, --restries int Command execution failed retries number (default 0)
-t, --timeout int Command execution timeout (seconds) (default 60)
Global Flags:
-v, --verbose Print detailed information (default true)
Use gosible run task -f config.yaml
to run batch tasks. An example of config.yaml is as follows:
spec:
# Fill in the remote node information, including name, address, user name, password, port (22 by default), etc
hosts:
- {name: node1, address: 1.1.1.1, user: root, password: 123456}
- {name: node2, address: 1.1.1.2, user: root, password: 123456, port: 22}
gosible:
# Define SCP and SSH commands that need to be executed remotely. SCP only supports file copying, not folders
# Tasks are executed sequentially
tasks:
- {type: scp, src: "res/prerequisites.tar.gz", dst: "/data/prerequisites.tar.gz"}
- {type: ssh, cmd: "tar -xzvf /data/prerequisites.tar.gz -C /data/"}
- {type: ssh, cmd: "cd /data/prerequisites && ./install.sh"}
License
Gosible is released under the Apache 2.0 license.