sonic-screwdriver 1.4.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/bin/commit_docs.sh +26 -0
- data/.circleci/config.yml +72 -0
- data/.gitignore +2 -1
- data/CHANGELOG.md +29 -3
- data/Gemfile +3 -3
- data/Guardfile +17 -10
- data/LICENSE.txt +2 -2
- data/README.md +25 -28
- data/Rakefile +9 -2
- data/docs/_config.yml +3 -0
- data/docs/_docs/help.md +1 -1
- data/docs/_docs/install-bastion.md +5 -15
- data/docs/_docs/install.md +3 -13
- data/docs/_docs/next-steps.md +1 -1
- data/docs/_docs/settings.md +42 -56
- data/docs/_docs/tutorial-ecs-exec.md +16 -20
- data/docs/_docs/tutorial-ecs-sh.md +73 -0
- data/docs/_docs/tutorial-execute.md +106 -38
- data/docs/_docs/tutorial-ssh.md +15 -19
- data/docs/_docs/why-ec2-run-command.md +1 -1
- data/docs/_includes/commands.html +5 -5
- data/docs/_includes/content.html +5 -0
- data/docs/_includes/css/main.css +15 -9
- data/docs/_includes/css/sonic.css +7 -5
- data/docs/_includes/example.html +4 -4
- data/docs/_includes/footer.html +6 -4
- data/docs/_includes/reference.md +1 -0
- data/docs/_includes/subnav.html +2 -1
- data/docs/_reference/sonic-completion.md +44 -0
- data/docs/_reference/sonic-completion_script.md +25 -0
- data/docs/_reference/sonic-ecs-exec.md +30 -0
- data/docs/_reference/sonic-ecs-help.md +21 -0
- data/docs/_reference/sonic-ecs-sh.md +35 -0
- data/docs/_reference/sonic-ecs.md +25 -0
- data/docs/_reference/sonic-execute.md +85 -0
- data/docs/_reference/sonic-list.md +40 -0
- data/docs/_reference/sonic-ssh.md +86 -0
- data/docs/_reference/sonic-version.md +21 -0
- data/docs/bin/web +1 -1
- data/docs/img/tutorials/ec2-console-run-command.png +0 -0
- data/docs/quick-start.md +17 -22
- data/docs/reference.md +12 -0
- data/{bin → exe}/sonic +3 -3
- data/lib/bash_scripts/docker-exec.sh +1 -0
- data/lib/bash_scripts/docker-run.sh +8 -1
- data/lib/sonic.rb +11 -3
- data/lib/sonic/{aws_services.rb → aws_service.rb} +6 -1
- data/lib/sonic/base_command.rb +82 -0
- data/lib/sonic/checks.rb +2 -2
- data/lib/sonic/cli.rb +41 -29
- data/lib/sonic/command.rb +8 -22
- data/lib/sonic/completer.rb +161 -0
- data/lib/sonic/completer/script.rb +6 -0
- data/lib/sonic/completer/script.sh +10 -0
- data/lib/sonic/core.rb +15 -0
- data/lib/sonic/default/settings.yml +9 -16
- data/lib/sonic/docker.rb +30 -2
- data/lib/sonic/ecs.rb +22 -0
- data/lib/sonic/execute.rb +203 -51
- data/lib/sonic/help.rb +9 -0
- data/lib/sonic/help/command/send.md +10 -0
- data/lib/sonic/help/completion.md +22 -0
- data/lib/sonic/help/completion_script.md +3 -0
- data/lib/sonic/help/ecs/exec.md +8 -0
- data/lib/sonic/help/ecs/sh.md +13 -0
- data/lib/sonic/help/execute.md +59 -0
- data/lib/sonic/help/list.md +17 -0
- data/lib/sonic/help/ssh.md +60 -0
- data/lib/sonic/list.rb +5 -2
- data/lib/sonic/setting.rb +47 -0
- data/lib/sonic/ssh.rb +42 -23
- data/lib/sonic/ssh/identifier_detector.rb +7 -3
- data/lib/sonic/ui.rb +2 -2
- data/lib/sonic/version.rb +1 -1
- data/sonic.gemspec +14 -9
- data/spec/lib/cli_spec.rb +11 -11
- data/spec/lib/sonic/execute_spec.rb +1 -2
- data/spec/spec_helper.rb +18 -10
- metadata +115 -19
- data/Gemfile.lock +0 -134
- data/docs/_docs/tutorial-ecs-run.md +0 -100
- data/lib/sonic/cli/help.rb +0 -152
- data/lib/sonic/settings.rb +0 -115
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
title: sonic list
|
3
|
+
reference: true
|
4
|
+
---
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
sonic list [FILTER]
|
9
|
+
|
10
|
+
## Description
|
11
|
+
|
12
|
+
Lists ec2 instances.
|
13
|
+
|
14
|
+
A filter must be provided. The filter can be a mix of instance ids and ec2 tags. sonic list will auto-detect the what type of filter it is. The filter is optional.
|
15
|
+
|
16
|
+
## Examples
|
17
|
+
|
18
|
+
$ sonic list
|
19
|
+
$ sonic list hi-web-prod
|
20
|
+
$ sonic list hi-web-prod,hi-clock-prod
|
21
|
+
$ sonic list i-09482b1a6e330fbf7
|
22
|
+
|
23
|
+
## Example Output
|
24
|
+
|
25
|
+
$ sonic list --header i-09482b1a6e330fbf7
|
26
|
+
Instance Id Public IP Private IP Type
|
27
|
+
i-09482b1a6e330fbf7 54.202.152.168 172.31.21.108 t2.small
|
28
|
+
$
|
29
|
+
|
30
|
+
You cannot mix instance ids and tag names in the filter.
|
31
|
+
|
32
|
+
|
33
|
+
## Options
|
34
|
+
|
35
|
+
```
|
36
|
+
[--header], [--no-header] # Displays header
|
37
|
+
[--verbose], [--no-verbose]
|
38
|
+
[--noop], [--no-noop]
|
39
|
+
```
|
40
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
---
|
2
|
+
title: sonic ssh
|
3
|
+
reference: true
|
4
|
+
---
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
sonic ssh [IDENTIFER]
|
9
|
+
|
10
|
+
## Description
|
11
|
+
|
12
|
+
Ssh into a instance using identifier. identifer can be several things: instance id, ec2 tag, ECS service name, etc.
|
13
|
+
|
14
|
+
* EC2 instance id. Example: i-067c5e3f026c1e801
|
15
|
+
* EC2 tag value. Any tag value is search, the tag key does not matter only the tag value matters. Example: hi-web
|
16
|
+
* ECS service. Example: my-ecs-service
|
17
|
+
* ECS container instance id. Example: 7fbc8c75-4675-4d39-a5a4-0395ff8cd474
|
18
|
+
* ECS task id. Example: 1ed12abd-645c-4a05-9acf-739b9d790170
|
19
|
+
|
20
|
+
When using ecs identifiers the `--cluster` option is required or can be set in ~/.sonic/settings.yml.
|
21
|
+
|
22
|
+
Examples:
|
23
|
+
|
24
|
+
$ sonic ssh i-067c5e3f026c1e801
|
25
|
+
$ sonic ssh hi-web
|
26
|
+
$ sonic ssh --cluster my-cluster my-ecs-service
|
27
|
+
$ sonic ssh 7fbc8c75-4675-4d39-a5a4-0395ff8cd474
|
28
|
+
$ sonic ssh 1ed12abd-645c-4a05-9acf-739b9d790170
|
29
|
+
|
30
|
+
Sonic ssh builds up the ssh command and shells out to it. For example, the following commands:
|
31
|
+
|
32
|
+
sonic ssh i-027363802c6ff314f
|
33
|
+
|
34
|
+
Translates to:
|
35
|
+
|
36
|
+
ssh ec2-user@ec2-52-24-216-170.us-west-2.compute.amazonaws.com
|
37
|
+
|
38
|
+
You can also tack on any command to be run at the end of the command. Example:
|
39
|
+
|
40
|
+
$ sonic ssh i-027363802c6ff314f uptime
|
41
|
+
=> ssh ec2-user@ec2-52-24-216-170.us-west-2.compute.amazonaws.com uptime
|
42
|
+
15:57:02 up 18:21, 0 users, load average: 0.00, 0.01, 0.00
|
43
|
+
|
44
|
+
## Specifying pem keys
|
45
|
+
|
46
|
+
The recommended way to specify custom private keys is to use ssh-agent as covered here: https://blog.boltops.com/2017/09/21/3-ssh-tips-ssh-agent-tunnel-and-escaping-from-the-dead
|
47
|
+
|
48
|
+
But you can also specify the pem key to use with the -i option. Example:
|
49
|
+
|
50
|
+
$ sonic ssh -i ~/.ssh/id_rsa-custom ec2-user@ec2-52-24-216-170.us-west-2.compute.amazonaws.com
|
51
|
+
|
52
|
+
## Retry option
|
53
|
+
|
54
|
+
For newly launched instances, the instance's ssh access might not be quite ready. Typically, you must press up enter repeatedly until the instance is ready. Sonic ssh has a retry option that automates this. Example:
|
55
|
+
|
56
|
+
$ sonic ssh -r i-027363802c6ff314f
|
57
|
+
|
58
|
+
Bastion Host Support
|
59
|
+
|
60
|
+
Sonic ssh also supports a bastion host.
|
61
|
+
|
62
|
+
$ sonic ssh --bastion bastion.domain.com i-027363802c6ff314f
|
63
|
+
$ sonic ssh --bastion user@bastion.domain.com i-027363802c6ff314f
|
64
|
+
|
65
|
+
Here's what the output looks like:
|
66
|
+
|
67
|
+
$ sonic ssh --bastion 34.211.223.3 i-0f7f833131a51ce35 uptime
|
68
|
+
=> ssh -At ec2-user@34.211.223.3 ssh ec2-user@10.10.110.135 uptime
|
69
|
+
17:57:59 up 37 min, 0 users, load average: 0.00, 0.02, 0.00
|
70
|
+
Connection to 34.211.223.3 closed.
|
71
|
+
$
|
72
|
+
|
73
|
+
You can also set the bastion host and other options with a [settings file](http://sonic-screwdriver.cloud/docs/settings/).
|
74
|
+
|
75
|
+
|
76
|
+
## Options
|
77
|
+
|
78
|
+
```
|
79
|
+
-i, [--keys=KEYS] # comma separated list of ssh private key paths
|
80
|
+
-r, [--retry], [--no-retry] # keep retrying the server login until successful. Useful when on newly launched instances.
|
81
|
+
[--bastion=BASTION] # Bastion jump host to use. Defaults to no bastion server.
|
82
|
+
[--cluster=CLUSTER] # ECS Cluster to use. Default cluster is default
|
83
|
+
[--verbose], [--no-verbose]
|
84
|
+
[--noop], [--no-noop]
|
85
|
+
```
|
86
|
+
|
data/docs/bin/web
CHANGED
Binary file
|
data/docs/quick-start.md
CHANGED
@@ -6,36 +6,31 @@ In a hurry? No sweat! Here's a quick overview of how to use sonic.
|
|
6
6
|
|
7
7
|
### Install
|
8
8
|
|
9
|
-
|
10
|
-
gem install sonic-screwdriver
|
11
|
-
```
|
9
|
+
gem install sonic-screwdriver
|
12
10
|
|
13
11
|
### Usage
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
sonic ssh
|
18
|
-
sonic ssh
|
19
|
-
sonic ssh
|
20
|
-
sonic ssh
|
21
|
-
sonic ssh 7fbc8c75-4675-4d39-a5a4-0395ff8cd474 --cluster stag # ECS container id
|
22
|
-
sonic ssh 1ed12abd-645c-4a05-9acf-739b9d790170 --cluster stag # ECS task id
|
13
|
+
# ssh into an instance
|
14
|
+
sonic ssh i-0f7f833131a51ce35
|
15
|
+
sonic ssh demo-web # ec2 tag
|
16
|
+
sonic ssh demo-web --cluster staging # ecs service name
|
17
|
+
sonic ssh 7fbc8c75-4675-4d39-a5a4-0395ff8cd474 --cluster staging # ECS container id
|
18
|
+
sonic ssh 1ed12abd-645c-4a05-9acf-739b9d790170 --cluster staging # ECS task id
|
23
19
|
|
24
|
-
# docker exec to a running ECS docker container
|
25
|
-
sonic ecs
|
20
|
+
# docker exec to a running ECS docker container
|
21
|
+
sonic ecs exec demo-web
|
26
22
|
|
27
|
-
# docker run with same environment as the ECS docker running containers
|
28
|
-
sonic ecs
|
23
|
+
# docker run with same environment as the ECS docker running containers
|
24
|
+
sonic ecs sh demo-web
|
29
25
|
|
30
|
-
# run command on 1 instance
|
31
|
-
sonic execute i-0f7f833131a51ce35 uptime
|
26
|
+
# run command on 1 instance
|
27
|
+
sonic execute --instance-ids i-0f7f833131a51ce35 uptime
|
32
28
|
|
33
|
-
# run command on all instances tagged with
|
34
|
-
sonic execute
|
29
|
+
# run command on all instances tagged with demo-web and worker
|
30
|
+
sonic execute --tags Name=demo-web,demo-worker uptime
|
35
31
|
|
36
|
-
# list ec2 instances
|
37
|
-
sonic list
|
38
|
-
```
|
32
|
+
# list ec2 instances
|
33
|
+
sonic list demo-web
|
39
34
|
|
40
35
|
Congratulations! You now know the basic sonic screwdriver commands now.
|
41
36
|
|
data/docs/reference.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
title: CLI Reference
|
3
|
+
---
|
4
|
+
{% include reference.md %}
|
5
|
+
|
6
|
+
* [sonic completion]({% link _reference/sonic-completion.md %})
|
7
|
+
* [sonic completion_script]({% link _reference/sonic-completion_script.md %})
|
8
|
+
* [sonic ecs]({% link _reference/sonic-ecs.md %})
|
9
|
+
* [sonic execute]({% link _reference/sonic-execute.md %})
|
10
|
+
* [sonic list]({% link _reference/sonic-list.md %})
|
11
|
+
* [sonic ssh]({% link _reference/sonic-ssh.md %})
|
12
|
+
* [sonic version]({% link _reference/sonic-version.md %})
|
data/{bin → exe}/sonic
RENAMED
@@ -12,4 +12,11 @@ CONTAINER_IMAGE=$(cat /tmp/sonic/docker-image.txt)
|
|
12
12
|
cp /tmp/sonic/env-file.txt ~/
|
13
13
|
rm -rf /tmp/sonic
|
14
14
|
|
15
|
-
|
15
|
+
if [ $# -eq 0 ]; then
|
16
|
+
COMMAND=bash
|
17
|
+
else
|
18
|
+
COMMAND=$@
|
19
|
+
fi
|
20
|
+
|
21
|
+
set -x
|
22
|
+
exec docker run -ti --env-file ~/env-file.txt "$CONTAINER_IMAGE" $COMMAND
|
data/lib/sonic.rb
CHANGED
@@ -1,16 +1,24 @@
|
|
1
1
|
$:.unshift(File.expand_path("../", __FILE__))
|
2
|
+
require "rainbow/ext/string"
|
2
3
|
require "sonic/version"
|
3
|
-
require "colorize"
|
4
4
|
|
5
5
|
module Sonic
|
6
|
-
autoload :
|
6
|
+
autoload :Core, 'sonic/core'
|
7
|
+
autoload :Help, 'sonic/help'
|
8
|
+
autoload :AwsService, 'sonic/aws_service'
|
7
9
|
autoload :CLI, 'sonic/cli'
|
10
|
+
autoload :BaseCommand, 'sonic/base_command'
|
8
11
|
autoload :Command, 'sonic/command'
|
9
12
|
autoload :Docker, 'sonic/docker'
|
10
13
|
autoload :Execute, 'sonic/execute'
|
11
14
|
autoload :List, 'sonic/list'
|
12
|
-
autoload :
|
15
|
+
autoload :Setting, 'sonic/setting'
|
13
16
|
autoload :Ssh, 'sonic/ssh'
|
14
17
|
autoload :UI, 'sonic/ui'
|
15
18
|
autoload :Checks, 'sonic/checks'
|
19
|
+
autoload :Completion, "sonic/completion"
|
20
|
+
autoload :Completer, "sonic/completer"
|
21
|
+
autoload :Ecs, "sonic/ecs"
|
22
|
+
|
23
|
+
extend Core
|
16
24
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require "aws-sdk-ec2"
|
2
2
|
require "aws-sdk-ecs"
|
3
3
|
require "aws-sdk-ssm"
|
4
|
+
require "aws-sdk-s3"
|
4
5
|
|
5
6
|
module Sonic
|
6
|
-
module
|
7
|
+
module AwsService
|
7
8
|
def ecs
|
8
9
|
@ecs ||= Aws::ECS::Client.new
|
9
10
|
end
|
@@ -19,5 +20,9 @@ module Sonic
|
|
19
20
|
def ssm
|
20
21
|
@ssm ||= Aws::SSM::Client.new
|
21
22
|
end
|
23
|
+
|
24
|
+
def s3
|
25
|
+
@s3 ||= Aws::S3::Client.new
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
# Override thor's long_desc identation behavior
|
4
|
+
# https://github.com/erikhuda/thor/issues/398
|
5
|
+
class Thor
|
6
|
+
module Shell
|
7
|
+
class Basic
|
8
|
+
def print_wrapped(message, options = {})
|
9
|
+
message = "\n#{message}" unless message[0] == "\n"
|
10
|
+
stdout.puts message
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Sonic
|
17
|
+
class BaseCommand < Thor
|
18
|
+
class << self
|
19
|
+
def dispatch(m, args, options, config)
|
20
|
+
# Allow calling for help via:
|
21
|
+
# sonic command help
|
22
|
+
# sonic command -h
|
23
|
+
# sonic command --help
|
24
|
+
# sonic command -D
|
25
|
+
#
|
26
|
+
# as well thor's normal way:
|
27
|
+
#
|
28
|
+
# sonic help command
|
29
|
+
help_flags = Thor::HELP_MAPPINGS + ["help"]
|
30
|
+
if args.length > 1 && !(args & help_flags).empty?
|
31
|
+
args -= help_flags
|
32
|
+
args.insert(-2, "help")
|
33
|
+
end
|
34
|
+
|
35
|
+
# sonic version
|
36
|
+
# sonic --version
|
37
|
+
# sonic -v
|
38
|
+
version_flags = ["--version", "-v"]
|
39
|
+
if args.length == 1 && !(args & version_flags).empty?
|
40
|
+
args = ["version"]
|
41
|
+
end
|
42
|
+
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
# Override command_help to include the description at the top of the
|
47
|
+
# long_description.
|
48
|
+
def command_help(shell, command_name)
|
49
|
+
meth = normalize_command_name(command_name)
|
50
|
+
command = all_commands[meth]
|
51
|
+
alter_command_description(command)
|
52
|
+
super
|
53
|
+
end
|
54
|
+
|
55
|
+
def alter_command_description(command)
|
56
|
+
return unless command
|
57
|
+
|
58
|
+
# Add description to beginning of long_description
|
59
|
+
long_desc = if command.long_description
|
60
|
+
"#{command.description}\n\n#{command.long_description}"
|
61
|
+
else
|
62
|
+
command.description
|
63
|
+
end
|
64
|
+
|
65
|
+
# add reference url to end of the long_description
|
66
|
+
unless website.empty?
|
67
|
+
full_command = [command.ancestor_name, command.name].compact.join('-')
|
68
|
+
url = "#{website}/reference/sonic-#{full_command}"
|
69
|
+
long_desc += "\n\nHelp also available at: #{url}"
|
70
|
+
end
|
71
|
+
|
72
|
+
command.long_description = long_desc
|
73
|
+
end
|
74
|
+
private :alter_command_description
|
75
|
+
|
76
|
+
# meant to be overriden
|
77
|
+
def website
|
78
|
+
"http://sonic-screwdriver.cloud"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/sonic/checks.rb
CHANGED
@@ -3,7 +3,7 @@ module Sonic
|
|
3
3
|
def check_cluster_exists!
|
4
4
|
cluster = ecs.describe_clusters(clusters: [@cluster]).clusters.first
|
5
5
|
unless cluster
|
6
|
-
UI.error "The #{@cluster.green} cluster does not exist. Are you sure you specified the right cluster?"
|
6
|
+
UI.error "The #{@cluster.color(:green)} cluster does not exist. Are you sure you specified the right cluster?"
|
7
7
|
exit 1
|
8
8
|
end
|
9
9
|
end
|
@@ -20,7 +20,7 @@ module Sonic
|
|
20
20
|
|
21
21
|
service = resp.services.first
|
22
22
|
unless service
|
23
|
-
UI.error "The #{@service.green} service does not exist in #{@cluster.green} cluster. Are you sure you specified the right service and cluster?"
|
23
|
+
UI.error "The #{@service.color(:green)} service does not exist in #{@cluster.color(:green)} cluster. Are you sure you specified the right service and cluster?"
|
24
24
|
exit 1
|
25
25
|
end
|
26
26
|
end
|
data/lib/sonic/cli.rb
CHANGED
@@ -1,49 +1,61 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'sonic/cli/help'
|
3
2
|
|
4
3
|
module Sonic
|
5
|
-
class CLI <
|
4
|
+
class CLI < BaseCommand
|
5
|
+
desc "ecs SUBCOMMAND", "ecs subcommands"
|
6
|
+
long_desc Help.text(:ecs)
|
7
|
+
subcommand "ecs", Ecs
|
8
|
+
|
9
|
+
# desc "command SUBCOMMAND", "command subcommands"
|
10
|
+
# long_desc Help.text(:command)
|
11
|
+
# subcommand "command", Command
|
12
|
+
|
6
13
|
class_option :verbose, type: :boolean
|
7
14
|
class_option :noop, type: :boolean
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
method_option :retry, :aliases => '-r', :type => :boolean, :desc => "keep retrying the server login until successful. Useful when on newly launched instances."
|
15
|
+
|
16
|
+
desc "ssh [IDENTIFER]", "Ssh into a instance using identifier. identifer can be several things: instance id, ec2 tag, ECS service name, etc."
|
17
|
+
long_desc Help.text(:ssh)
|
18
|
+
option :keys, :aliases => '-i', :desc => "comma separated list of ssh private key paths"
|
19
|
+
option :retry, :aliases => '-r', :type => :boolean, :desc => "keep retrying the server login until successful. Useful when on newly launched instances."
|
20
|
+
option :bastion, desc: "Bastion jump host to use. Defaults to no bastion server."
|
21
|
+
option :cluster, desc: "ECS Cluster to use. Default cluster is default"
|
16
22
|
def ssh(identifier, *command)
|
17
23
|
Ssh.new(identifier, options.merge(command: command)).run
|
18
24
|
end
|
19
25
|
|
20
|
-
desc "
|
21
|
-
long_desc Help.
|
22
|
-
def ecs_exec(service, *command)
|
23
|
-
Docker.new(service, options.merge(command: command)).exec
|
24
|
-
end
|
25
|
-
|
26
|
-
# Cannot name the command run because that is a reserved Thor keyword :(
|
27
|
-
desc "ecs-run [ECS_SERVICE]", "docker run with the service on a container instance"
|
28
|
-
long_desc Help.ecs_run
|
29
|
-
def ecs_run(service, *command)
|
30
|
-
Docker.new(service, options.merge(command: command)).run
|
31
|
-
end
|
32
|
-
|
33
|
-
desc "execute [FILTER] [COMMAND]", "runs command across fleet of servers via AWS Run Command"
|
34
|
-
long_desc Help.execute
|
26
|
+
desc "execute [FILTER] [COMMAND]", "Runs command across fleet of servers via AWS Run Command."
|
27
|
+
long_desc Help.text("execute")
|
35
28
|
option :zero_warn, type: :boolean, default: true, desc: "Warns user when no instances found"
|
36
29
|
# filter - Filter ec2 instances by tag name or instance_ids separated by commas
|
37
|
-
|
38
|
-
|
30
|
+
option :instance_ids, desc: %Q|Instance ids to execute command on. Format: --instance-ids "i-111,i-222"|
|
31
|
+
option :tags, desc: %Q|Tags used to determine what instances to execute command on. Format: --tags "Key1=v1,v2;Key2=v3"|
|
32
|
+
def execute(*command)
|
33
|
+
Execute.new(command, options).execute
|
39
34
|
end
|
40
35
|
|
41
|
-
desc "list [FILTER]", "
|
42
|
-
long_desc Help.list
|
36
|
+
desc "list [FILTER]", "Lists ec2 instances."
|
37
|
+
long_desc Help.text(:list)
|
43
38
|
option :header, type: :boolean, desc: "Displays header"
|
44
39
|
# filter - Filter ec2 instances by tag name or instance_ids separated by commas
|
45
40
|
def list(filter)
|
46
41
|
List.new(options.merge(filter: filter)).run
|
47
42
|
end
|
43
|
+
|
44
|
+
desc "completion *PARAMS", "Prints words for auto-completion."
|
45
|
+
long_desc Help.text("completion")
|
46
|
+
def completion(*params)
|
47
|
+
Completer.new(CLI, *params).run
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "completion_script", "Generates a script that can be eval to setup auto-completion."
|
51
|
+
long_desc Help.text("completion_script")
|
52
|
+
def completion_script
|
53
|
+
Completer::Script.generate
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "version", "prints version"
|
57
|
+
def version
|
58
|
+
puts VERSION
|
59
|
+
end
|
48
60
|
end
|
49
61
|
end
|