ecl 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +95 -1
- data/lib/eclair/config.rb +1 -0
- data/lib/eclair/instance.rb +9 -1
- data/lib/eclair/version.rb +1 -1
- data/templates/eclrc.template +12 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd0af5acd07853220020290c73b35f7bbc773a1b
|
4
|
+
data.tar.gz: 5a4dbfbf94ee66e3f1902eb966b348921fa5c459
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 924ffb85cc063b48ae5bc179fe4f3e41fe56dc252ca998e85aa8a52c4c2ed03384002b68112c9dbe1cc2dd8e20ac265f9eecab5b24e3a8022258f8b4707d13b0
|
7
|
+
data.tar.gz: 547ba1905a506123dc861c61d93ebbd6adff9251878fd5e0776db61bde472313fac60cffeb3a7d11aa27bdb7c18936ed8eb9a5e1d40a2b6e836011a195d2e6c6
|
data/README.md
CHANGED
@@ -5,15 +5,109 @@ Simple ssh helper for Amazon EC2
|
|
5
5
|
## Requirements
|
6
6
|
|
7
7
|
tmux
|
8
|
+
~/.aws/credentials (created by AWS CLI)
|
8
9
|
|
9
10
|
## Installation
|
10
11
|
|
11
|
-
$ gem install
|
12
|
+
$ gem install ecl
|
12
13
|
|
13
14
|
## Usage
|
14
15
|
|
15
16
|
$ ecl
|
16
17
|
|
18
|
+
First execution will create ~/.eclrc file. Edit this file and run again.
|
19
|
+
|
20
|
+
## Configurations
|
21
|
+
|
22
|
+
### aws_region
|
23
|
+
|
24
|
+
AWS region to connect.
|
25
|
+
|
26
|
+
config.aws_region = "ap-northeast-1"
|
27
|
+
|
28
|
+
### columns
|
29
|
+
|
30
|
+
Max number of columns displayed in eclair.
|
31
|
+
|
32
|
+
$ config.columns = 4
|
33
|
+
|
34
|
+
### ssh_username
|
35
|
+
|
36
|
+
Function to find username from image.
|
37
|
+
Returns username of given image.
|
38
|
+
Uses image data from [EC2::Client#describe_images](https://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/Client.html#describe_images-instance_method) API call
|
39
|
+
|
40
|
+
config.ssh_username = lambda do |image|
|
41
|
+
case image.name
|
42
|
+
when /ubuntu/
|
43
|
+
"ubuntu"
|
44
|
+
else
|
45
|
+
"ec2-user"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
### group_by
|
50
|
+
|
51
|
+
Function to find group name from instance.
|
52
|
+
Returns group name from instance data.
|
53
|
+
Uses instance data from [EC2::Client#describe_instances](https://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/Client.html#describe_instances-instance_method) API call.
|
54
|
+
|
55
|
+
Example)
|
56
|
+
Group by security groups.
|
57
|
+
|
58
|
+
config.group_by = lambda do |instance|
|
59
|
+
if instance.security_groups.first
|
60
|
+
instance.security_groups.first.group_name
|
61
|
+
else
|
62
|
+
"no_group"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
Group by instance name.
|
67
|
+
|
68
|
+
config.group_by = lambda do |instance|
|
69
|
+
nametag = instance.tags.find{|t| t.key == "Name"}
|
70
|
+
return "Noname" unless nametag
|
71
|
+
case nametag.value
|
72
|
+
when /^production/
|
73
|
+
"production servers"
|
74
|
+
when /^test/
|
75
|
+
"test servers"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
Do not group instances.
|
80
|
+
|
81
|
+
config.group_by = nil
|
82
|
+
|
83
|
+
|
84
|
+
### ssh_ports
|
85
|
+
Port numbers to try ssh.
|
86
|
+
|
87
|
+
config.ssh_ports = [1234, 22]
|
88
|
+
|
89
|
+
|
90
|
+
### ssh_options
|
91
|
+
Extra options passed to ssh.
|
92
|
+
|
93
|
+
config.ssh_options = "-o ConnectTimeout=1 -o StrictHostKeyChecking=no"
|
94
|
+
|
95
|
+
### ssh_hostname
|
96
|
+
Hostname to use in ssh.
|
97
|
+
Choose from :public_dns_name, :public_ip_address, :private_dns_name, :private_ip_address
|
98
|
+
|
99
|
+
config.ssh_hostname = :public_ip_address
|
100
|
+
|
101
|
+
|
102
|
+
### ssh_keys
|
103
|
+
Hash of EC2 keypair name => key_path in local.
|
104
|
+
If your key has been already registered in ssh-agent, you don't have to configure this.
|
105
|
+
|
106
|
+
config.ssh_keys = {
|
107
|
+
"keypair1" => "/path/to/key1",
|
108
|
+
"keypair2" => "/path/to/key2",
|
109
|
+
}
|
110
|
+
|
17
111
|
## License
|
18
112
|
|
19
113
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/eclair/config.rb
CHANGED
data/lib/eclair/instance.rb
CHANGED
@@ -71,9 +71,17 @@ module Eclair
|
|
71
71
|
config.ssh_username.call(image(force: true))
|
72
72
|
end
|
73
73
|
|
74
|
+
def key_cmd
|
75
|
+
if config.ssh_keys[key_name]
|
76
|
+
"-i #{config.ssh_keys[key_name]}"
|
77
|
+
else
|
78
|
+
""
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
74
82
|
def ssh_cmd
|
75
83
|
cmd = config.ssh_ports.map{ |port|
|
76
|
-
"ssh #{config.ssh_options} -p#{port} #{username}@#{hostname}"
|
84
|
+
"ssh #{config.ssh_options} -p#{port} #{key_cmd} #{username}@#{hostname}"
|
77
85
|
}.join(" || ")
|
78
86
|
|
79
87
|
"echo Attaching to #{name}: #{username}@#{hostname} && (#{cmd})"
|
data/lib/eclair/version.rb
CHANGED
data/templates/eclrc.template
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
Eclair.configure do |config|
|
2
|
-
# aws_region - region to connect
|
2
|
+
# aws_region - AWS region to connect.
|
3
3
|
# This overrides AWS_REGION environment variable, so you can comment out this line if you set this in environment variable.
|
4
4
|
config.aws_region = "ap-northeast-1"
|
5
5
|
|
6
|
-
# columns -
|
6
|
+
# columns - Max number of columns displayed in eclair.
|
7
7
|
config.columns = 4
|
8
8
|
|
9
9
|
# ssh_username - Function to find username from image
|
10
|
-
# You can
|
10
|
+
# You can use image data from EC2::Client#describe_images API call
|
11
11
|
# https://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/Client.html#describe_images-instance_method
|
12
12
|
config.ssh_username = lambda do |image|
|
13
13
|
case image.name
|
@@ -18,10 +18,15 @@ Eclair.configure do |config|
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
#
|
21
|
+
# ssh_keys - Hash of key_name => key_path in local.
|
22
|
+
# If your key has been already registered in ssh-agent, you don't have to configure this.
|
23
|
+
config.ssh_keys = {
|
24
|
+
}
|
25
|
+
|
26
|
+
# group_by - Function to find group name from instance.
|
22
27
|
# Make a function that returns group name from instance data
|
23
|
-
# You can access response data extracted from EC2::Client#
|
24
|
-
# https://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/Client.html#
|
28
|
+
# You can access response data extracted from EC2::Client#describe_instances API call
|
29
|
+
# https://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/Client.html#describe_instances-instance_method
|
25
30
|
|
26
31
|
# If you want to group instances by security group, uncomment example below. (default option)
|
27
32
|
# config.group_by = lambda do |instance|
|
@@ -51,7 +56,7 @@ Eclair.configure do |config|
|
|
51
56
|
# Eclair will try to ssh specified ports in order with ConnectTimeout below.
|
52
57
|
config.ssh_ports = [22]
|
53
58
|
|
54
|
-
# ssh_options -
|
59
|
+
# ssh_options - Extra options passed to ssh.
|
55
60
|
# ConnectTimeout should exist when you want to connect to multiple ports.
|
56
61
|
config.ssh_options = "-o ConnectTimeout=1 -o StrictHostKeyChecking=no"
|
57
62
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Devsisters
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|