vagrant-aws-stack 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/Rakefile +4 -0
- data/lib/vagrant/aws/stack.rb +139 -0
- data/lib/vagrant/aws/stack/version.rb +7 -0
- data/vagrant-aws-stack.gemspec +23 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0c3df7c4ea991814f49ad8adcd6567c371bb7e34
|
4
|
+
data.tar.gz: 65fc050365046abbfaebd60921f852aed33b267a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2fda763318ccf2a6197b4502cdd966be47831d0115770c9e30e097e22b3f45bf5e3c48d7fcff312f0ca1e834c57418d33834dee9142ba4f0fe2b03e4a75cc0bd
|
7
|
+
data.tar.gz: d10c542c1404474813e152f26ea71c5ac56e9eb49c1135ffdc3a21fe8f057076e8e60d9d0169e2e3a60c376536fb8ccbca90220dc92e72721a83b858be55b0ba
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Leon Strong
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Vagrant::Aws::Stack
|
2
|
+
|
3
|
+
This plugin allows the use of some global variables when
|
4
|
+
used in conjunction with the vagrant aws plugin.
|
5
|
+
|
6
|
+
This is to allow developer testing and inserting VM's into
|
7
|
+
particular cloudformation stack environmnets alot easier.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
vagrant plugin install vagrant-aws-stack
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
in your vagrant file add :
|
16
|
+
|
17
|
+
stack_hash = AWSUtils::get_vagrant_hash("StackName")
|
18
|
+
|
19
|
+
you can use the hash values.
|
20
|
+
|
21
|
+
## Contributing
|
data/Rakefile
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
require_relative "stack/version"
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Vagrant
|
5
|
+
def self.stack_info(stack_name=nil)
|
6
|
+
end
|
7
|
+
module Aws
|
8
|
+
module Stack
|
9
|
+
@stack_id = nil
|
10
|
+
AWS_BINARY=`which aws`.chomp;
|
11
|
+
|
12
|
+
def self.stack_id=(id)
|
13
|
+
@stack_id = id
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.stack_id
|
17
|
+
return @stack_id
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.run_aws_cmd(cmd=nil)
|
21
|
+
|
22
|
+
result = nil
|
23
|
+
|
24
|
+
json = %x[#{AWS_BINARY} #{cmd} 2>&1]
|
25
|
+
|
26
|
+
status = $?
|
27
|
+
|
28
|
+
if status.exitstatus != 0
|
29
|
+
json.gsub! /\n|\r/,""
|
30
|
+
logger.error "error: #{status.exitstatus} - #{json}"
|
31
|
+
return
|
32
|
+
end
|
33
|
+
if json and json != ""
|
34
|
+
begin
|
35
|
+
result = JSON.parse( json )
|
36
|
+
rescue JSON::ParserError => err
|
37
|
+
logger.error "Unable to parse result after command #{cmd} #{json} - #{err}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
return result
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.get_vpc(name=nil)
|
45
|
+
@vpc_data = run_aws_cmd('ec2 describe-vpcs')["Vpcs"] unless @vpc_data
|
46
|
+
vpcs = get_records(:id_key => "VpcID", :logical_id => name, :data => @vpc_data )
|
47
|
+
return vpcs
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.get_sg(name=nil)
|
51
|
+
sgs = Array.new
|
52
|
+
@sg_data = run_aws_cmd('ec2 describe-security-groups')["SecurityGroups"] unless @sg_data
|
53
|
+
sgs = get_records(:id_key => "GroupID", :logical_id => name, :data => @sg_data )
|
54
|
+
|
55
|
+
return sgs
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.get_subnet(name=nil)
|
59
|
+
|
60
|
+
@subnet_data = run_aws_cmd('ec2 describe-subnets')["Subnets"] unless @subnet_data
|
61
|
+
subnets = get_records(:id_key => "SubnetID", :logical_id => name, :data => @subnet_data )
|
62
|
+
|
63
|
+
return subnets
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.get_records(opts)
|
67
|
+
raise ArgumentError, "must provide :id_field_name" unless opts[:id_key]
|
68
|
+
raise ArgumentError, "must provide :id_field_name" unless opts[:data]
|
69
|
+
|
70
|
+
id_key = opts[:id_key]
|
71
|
+
name = opts[:logical_id]
|
72
|
+
|
73
|
+
results = Array.new
|
74
|
+
|
75
|
+
opts[:data].each do |data|
|
76
|
+
|
77
|
+
next unless data["Tags"]
|
78
|
+
|
79
|
+
stack = get_tag(data["Tags"],"aws:cloudformation:stack-name") unless @stack_id.nil?
|
80
|
+
logical_id = get_tag(data["Tags"],"aws:cloudformation:logical-id")
|
81
|
+
|
82
|
+
next unless "#{stack}" == "#{@stack_id}"
|
83
|
+
|
84
|
+
if name.nil?
|
85
|
+
results << { :id => data[id_key], :stack => stack, :name => logical_id }
|
86
|
+
next
|
87
|
+
end
|
88
|
+
|
89
|
+
if name.is_a?(Array)
|
90
|
+
name.each do |cur_name|
|
91
|
+
next unless logical_id == cur_name
|
92
|
+
results << { :id => data[id_key], :stack => stack, :name => logical_id }
|
93
|
+
end
|
94
|
+
next
|
95
|
+
end
|
96
|
+
|
97
|
+
next unless logical_id == name
|
98
|
+
|
99
|
+
return { :id => data[id_key], :stack => stack, :name => logical_id }
|
100
|
+
|
101
|
+
end
|
102
|
+
return results
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.get_tag(tags,tag_key)
|
106
|
+
raise ArgumentError, "must provide the actual keys hash!" unless tags.is_a?(Array)
|
107
|
+
return false unless tags
|
108
|
+
tags.each do |tag|
|
109
|
+
if tag['Key'] == tag_key
|
110
|
+
return tag['Value']
|
111
|
+
end
|
112
|
+
end
|
113
|
+
return false
|
114
|
+
end
|
115
|
+
|
116
|
+
def get_instances(i)
|
117
|
+
|
118
|
+
data = i['Instances']
|
119
|
+
|
120
|
+
data.each do |i|
|
121
|
+
state = i['State']['Name']
|
122
|
+
stack = get_tag(i['Tags'],"aws:cloudformation:stack-id")
|
123
|
+
name = get_tag(i['Tags'],"Name")
|
124
|
+
next unless stack
|
125
|
+
|
126
|
+
@stacks["#{stack}"] = [] unless @stacks.has_key? "#{stack}"
|
127
|
+
|
128
|
+
next if state =~ /terminated/
|
129
|
+
|
130
|
+
if name
|
131
|
+
@stacks["#{stack}"] << "#{i['ImageId']}/#{i['InstanceId']} Name : #{name} / #{state} http://#{i['PublicIpAddress']}"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant/aws/stack/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-aws-stack"
|
8
|
+
spec.version = Vagrant::Aws::Stack::VERSION
|
9
|
+
spec.authors = ["Leon Strong"]
|
10
|
+
spec.email = ["lstrong@oss.co.nz"]
|
11
|
+
spec.summary = %q{add ability to query values for AWS stack information}
|
12
|
+
spec.description = %q{get subnet/vpc information}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-aws-stack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leon Strong
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: get subnet/vpc information
|
42
|
+
email:
|
43
|
+
- lstrong@oss.co.nz
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/vagrant/aws/stack.rb
|
54
|
+
- lib/vagrant/aws/stack/version.rb
|
55
|
+
- vagrant-aws-stack.gemspec
|
56
|
+
homepage: ''
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.2.2
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: add ability to query values for AWS stack information
|
80
|
+
test_files: []
|