vagrant-awsinfo 0.0.3 → 0.0.4
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.
- data/CHANGELOG.md +5 -1
- data/README.md +6 -0
- data/lib/vagrant-awsinfo.rb +2 -0
- data/lib/vagrant-awsinfo/command.rb +25 -7
- data/lib/vagrant-awsinfo/version.rb +1 -1
- metadata +1 -1
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,12 @@
|
|
2
2
|
* Initial Release
|
3
3
|
|
4
4
|
# 0.0.2
|
5
|
-
* Added some more data to the output, such as
|
5
|
+
* Added some more data to the output, such as instance_id
|
6
6
|
|
7
7
|
# 0.0.3
|
8
8
|
|
9
9
|
* Output is now JSON rather then a ruby hash
|
10
|
+
|
11
|
+
# 0.0.4
|
12
|
+
|
13
|
+
* Supports returning only a single value, such as "host", "instance_id", ect
|
data/README.md
CHANGED
@@ -19,6 +19,12 @@ Examples:
|
|
19
19
|
```
|
20
20
|
% vagrant awsinfo
|
21
21
|
{:host=>"ec2-xxx-xxx-xxx-xxxx.compute-1.amazonaws.com", :ssh_port=>22, :username=>"root", :instance_id=>"i-3188a75e", :state=>"running"}
|
22
|
+
|
23
|
+
% vagrant awsinfo -k host
|
24
|
+
ec2-174-129-128-49.compute-1.amazonaws.com
|
25
|
+
|
26
|
+
% vagrant awsinfo -k host -m default
|
27
|
+
ec2-174-129-128-49.compute-1.amazonaws.com
|
22
28
|
```
|
23
29
|
|
24
30
|
## Contributing
|
data/lib/vagrant-awsinfo.rb
CHANGED
@@ -2,24 +2,42 @@ module VagrantAwsInfo
|
|
2
2
|
|
3
3
|
class Command < Vagrant.plugin(2, :command)
|
4
4
|
|
5
|
-
Settings = Struct.new(:machines)
|
5
|
+
Settings = Struct.new(:machines,:keys)
|
6
6
|
|
7
7
|
def execute
|
8
8
|
|
9
|
-
require "optparse"
|
10
|
-
|
11
9
|
settings = Settings.new
|
12
10
|
settings.machines = []
|
11
|
+
settings.keys = nil
|
13
12
|
|
14
13
|
options = OptionParser.new do |o|
|
15
14
|
o.banner = "Return SSH info from an AWS provisioned Vagrant machine"
|
15
|
+
|
16
16
|
o.on("-m MACHINE", "The machine to query.") do |value|
|
17
17
|
settings.machines << value
|
18
18
|
end
|
19
|
+
|
20
|
+
o.on("-k KEY", "single value to return.") do |value|
|
21
|
+
settings.keys = value
|
22
|
+
end
|
19
23
|
end
|
24
|
+
|
20
25
|
settings.machines = ["default"] if settings.machines.empty?
|
21
26
|
|
22
|
-
|
27
|
+
argv = parse_options(options)
|
28
|
+
|
29
|
+
instance_info = Hash[ get_info(settings.machines).map{ |k,v| [k.to_s,v] } ]
|
30
|
+
|
31
|
+
if settings.keys
|
32
|
+
if instance_info.has_key?(settings.keys)
|
33
|
+
@env.ui.info instance_info[settings.keys].gsub('"', '')
|
34
|
+
else
|
35
|
+
@env.ui.error "[WARNING] - Supplied key was not found"
|
36
|
+
return 1
|
37
|
+
end
|
38
|
+
else
|
39
|
+
@env.ui.info instance_info.to_json
|
40
|
+
end
|
23
41
|
|
24
42
|
end
|
25
43
|
|
@@ -36,10 +54,10 @@ module VagrantAwsInfo
|
|
36
54
|
instance_id: machine.id,
|
37
55
|
state: machine.provider.state.short_description,
|
38
56
|
}
|
39
|
-
return r
|
40
|
-
|
57
|
+
return r
|
41
58
|
else
|
42
|
-
|
59
|
+
@env.ui.error "[WARNING] - Sorry this plugin currently only supports machines using the AWS provider"
|
60
|
+
exit 1
|
43
61
|
end
|
44
62
|
end
|
45
63
|
end
|