based on https://github.com/crosbymichael/slex uses https://github.com/MattAitchison/envconfig uses https://gist.github.com/MattAitchison/ea7664793653b8fa88dd
Usage: remotectl <flags> <query> [--] <cmd>
Providers:
[do]
Environment Vars:
REMOTECTL_USER="" # user to connect as
REMOTECTL_PROVIDER="do" # comma-sep list of provider modules to use for selecting hosts
REMOTECTL_NAMESPACE="" # namespace is a prefix which is matched and removed from hosts
REMOTECTL_PREFIX="{{.Name}}: " # prefix template for host log output
REMOTECTL_PORT="22" # port used to connect to each host
SSH_AUTH_SOCK="" # ssh agent socket
REMOTECTL_IDENTITY="" # file from which the identity (private key) for public key authentication is read.
Flags:
-help
show this help message
-list
lists selected ips and names. /etc/hosts friendly output
-profile string
bash profile to source for env config
-version
show version
# run uptime on all hosts
remotectl -- uptime
# run uptime on all hosts tagged foo
remotectl foo uptime
# list all hosts
remotectl -list
# add hosts tagged "app" into /etc/hosts
remotectl -list app >> /etc/hosts
# show configuration using a profile (no query or cmd)
remotectl -profile myprofile
go template prefix for host output.
- .Name - name of host
- .IP - ip of host
- .Index - numerical index of host in run
- .Group - group index (if groups mode is used)
Providers may implement different query string semantics. However, there is an ideal convention set forth by builtin providers:
Queries are treated as "tag" lookups first. If no hosts exist with
this tag, query is treated as a "name" lookup. This optimizes for
primary use case of multiple hosts, but still works to reference
individual hosts.
Key-value attributes can be provided in the form `<key>:<value>`.
Providers implement more detailed semantics around this convention.
DO_ACCESS_TOKEN
REMOTECTL_NAMESPACE
will limit to DO hosts prefixed with namespace. Allows queries within a namespace since DO has no tags/attributes/vpcs.
Use with clients. Public mentions on Twitter.
-
-verbose
,-v
shows status output more like capistrano or fabric. otherwise, focuses only on output of remote hosts. -
-env
,-e <key=value>
sets environment variable to be set in remote shell. -
-local
,-L
doesn't use ssh, but shells out locally to run . replaces string "{}" in with each host ip. used for rsync, etc. also allows using system ssh. -
-first
,-1
limits list of hosts returned to just the first host. can be combined with --random to pick random host.
REMOTECTL_BASHENV
REMOTECTL_AGENT
REMOTECTL_PREFIX
REMOTECTL_NAMESPACE
REMOTECTL_SHELLENV
file to copy and source on remote sideREMOTECTL_AGENT
boolean to forward agent. defaults to true?
- ec2
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
EC2_FILTER
apply ec2 filtersEC2_IPDOMAIN
public / private which ip to use (ie, private when using bastion/gateway)
# broadcast docker image to hosts tagged "app" via stdin
docker save myimage | remotectl app docker load
# wait for all "app" hosts to be ssh reachable
remotectl --wait app
Screencast!
- Bastion/gateway
- Modes
- Random flag
- Wait flag
-
REMOTECTL_GATEWAY
selector to use as bastion host. optional prefix "@" to specify bastion user. -
REMOTECTL_MODE
execution mode options (based on ruby sshkit):-
parallel
runs commands in parallel. default. -
sequence[:<wait-duration>]
runs in sequence with option duration between. ex: REMOTECTL_MODE=sequence:2s -
groups:<limit>[:<wait-duration>]
runs in parallel on hosts, grouped sequential. ex: REMOTECTL_MODE=group:4:2s
-
-
--random
,-r
randomizes the list of hosts returned from query from any sorting or bias of the provider. -
--timeout
,-t <wait-duration>
global timeout val -
--wait
,-w
polls hosts until they're all ready to receive ssh commands. can be used with or without . is only performed when all hosts are ready.
MIT