epas 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +46 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +55 -0
- data/Rakefile +67 -0
- data/VERSION +1 -0
- data/bin/ec2-puppet-autosigner +14 -0
- data/epas.gemspec +74 -0
- data/lib/epas.rb +78 -0
- data/test/epas/test_auto_signer.rb +63 -0
- data/test/helper.rb +18 -0
- metadata +198 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
|
9
|
+
gem "aws"
|
10
|
+
gem "i18n"
|
11
|
+
gem "activesupport"
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem "bundler", "~> 1.0.0"
|
15
|
+
gem "jeweler", "~> 1.6.0"
|
16
|
+
gem "rcov", ">= 0"
|
17
|
+
gem "reek", "~> 1.2.8"
|
18
|
+
gem "roodi", "~> 2.1.0"
|
19
|
+
end
|
20
|
+
|
21
|
+
group :test do
|
22
|
+
gem "mocha"
|
23
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.0.7)
|
5
|
+
aws (2.5.3)
|
6
|
+
http_connection
|
7
|
+
uuidtools
|
8
|
+
xml-simple
|
9
|
+
git (1.2.5)
|
10
|
+
http_connection (1.4.1)
|
11
|
+
i18n (0.6.0)
|
12
|
+
jeweler (1.6.2)
|
13
|
+
bundler (~> 1.0)
|
14
|
+
git (>= 1.2.5)
|
15
|
+
rake
|
16
|
+
mocha (0.9.12)
|
17
|
+
rake (0.9.2)
|
18
|
+
rcov (0.9.9)
|
19
|
+
reek (1.2.8)
|
20
|
+
ruby2ruby (~> 1.2)
|
21
|
+
ruby_parser (~> 2.0)
|
22
|
+
sexp_processor (~> 3.0)
|
23
|
+
roodi (2.1.0)
|
24
|
+
ruby_parser
|
25
|
+
ruby2ruby (1.2.5)
|
26
|
+
ruby_parser (~> 2.0)
|
27
|
+
sexp_processor (~> 3.0)
|
28
|
+
ruby_parser (2.0.6)
|
29
|
+
sexp_processor (~> 3.0)
|
30
|
+
sexp_processor (3.0.5)
|
31
|
+
uuidtools (2.1.2)
|
32
|
+
xml-simple (1.0.16)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
activesupport
|
39
|
+
aws
|
40
|
+
bundler (~> 1.0.0)
|
41
|
+
i18n
|
42
|
+
jeweler (~> 1.6.0)
|
43
|
+
mocha
|
44
|
+
rcov
|
45
|
+
reek (~> 1.2.8)
|
46
|
+
roodi (~> 2.1.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Ramon Salvadó
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
= epas
|
2
|
+
|
3
|
+
The <b>epas<b> acronym stands for EC2 Puppet Auto Signer.
|
4
|
+
|
5
|
+
This gem provides a simple script to autosign ec2 instances into puppet. This way you can launch new instances in ec2 and avoid having to sign them manually.
|
6
|
+
|
7
|
+
First it checks to see if there is any pending sign request, if there is it makes a query to AWS to obtain the instance_id of all machines. If any of this ids matches with the hostname of the request it signs it.
|
8
|
+
|
9
|
+
For example if we launch a new ec2 server whose instance id is i-12345 and we insert this id into the hostname (using user-data for example), and this server makes a request to our puppet master, this script will autosign the request.
|
10
|
+
|
11
|
+
# user-data script example
|
12
|
+
# Helper functions
|
13
|
+
die() { status=$1; shift; echo "FATAL: $*"; exit $status; }
|
14
|
+
instance_id="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`"
|
15
|
+
# 1) Proper hostname setup (to be used by puppet)
|
16
|
+
hostname="${instance_id}"
|
17
|
+
echo $hostname > /proc/sys/kernel/hostname
|
18
|
+
sed -i "s|localhost.localdomain|$hostname|g" /etc/sysconfig/network
|
19
|
+
sed -i "s|localhost.localdomain|localhost.localdomain $hostname|g" /etc/hosts
|
20
|
+
service puppet start
|
21
|
+
|
22
|
+
It expects to be run in a puppet-master server in a cron job or similar.
|
23
|
+
|
24
|
+
By default it reads aws credentials from "~/.awssecret" which should be a file with the aws id and the aws secret in separate lines.
|
25
|
+
|
26
|
+
Example contents of "~/.awssecret":
|
27
|
+
|
28
|
+
1D43DD69O8EJGS3X2WR2
|
29
|
+
zDWZH14jYZU0KBn09dCTHRQUJFAvpPz155o23Qu7
|
30
|
+
|
31
|
+
You can also pass another file as an argument:
|
32
|
+
|
33
|
+
# Example cron job 1.
|
34
|
+
* * * * * ec2-puppet-autosigner /path/to/aws_credentials
|
35
|
+
|
36
|
+
By defaults it checks all avaliable regions, but you can also pass the regions you want to check as parameters:
|
37
|
+
|
38
|
+
# Example cron job 2.
|
39
|
+
* * * * * ec2-puppet-autosigner /path/to/aws_credentials eu-west-1 us-east-1
|
40
|
+
|
41
|
+
== Contributing to epas
|
42
|
+
|
43
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
44
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
45
|
+
* Fork the project
|
46
|
+
* Start a feature/bugfix branch
|
47
|
+
* Commit and push until you are happy with your contribution
|
48
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
49
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
50
|
+
|
51
|
+
== Copyright
|
52
|
+
|
53
|
+
Copyright (c) 2011 Ramon Salvadó. See LICENSE.txt for
|
54
|
+
further details.
|
55
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "epas"
|
18
|
+
gem.homepage = "http://github.com/rsalvado/epas"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Script to autosign ec2 instances into puppet.}
|
21
|
+
gem.description = %Q{To be run in a cron script or a daemon. Autosigns ec2 instances based on hostname and instance_id, it expects instance_id as part of the ec2 instance hostname.}
|
22
|
+
gem.email = "rsalvado@gnuine.com"
|
23
|
+
gem.authors = ["Ramon Salvadó"]
|
24
|
+
gem.executables = ["ec2-puppet-autosigner"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rcov/rcovtask'
|
37
|
+
Rcov::RcovTask.new do |test|
|
38
|
+
test.libs << 'test'
|
39
|
+
test.pattern = 'test/**/test_*.rb'
|
40
|
+
test.verbose = true
|
41
|
+
test.rcov_opts << '--exclude "gems/*"'
|
42
|
+
end
|
43
|
+
|
44
|
+
require 'reek/rake/task'
|
45
|
+
Reek::Rake::Task.new do |t|
|
46
|
+
t.fail_on_error = true
|
47
|
+
t.verbose = false
|
48
|
+
t.source_files = 'lib/**/*.rb'
|
49
|
+
end
|
50
|
+
|
51
|
+
require 'roodi'
|
52
|
+
require 'roodi_task'
|
53
|
+
RoodiTask.new do |t|
|
54
|
+
t.verbose = false
|
55
|
+
end
|
56
|
+
|
57
|
+
task :default => :test
|
58
|
+
|
59
|
+
require 'rake/rdoctask'
|
60
|
+
Rake::RDocTask.new do |rdoc|
|
61
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
62
|
+
|
63
|
+
rdoc.rdoc_dir = 'rdoc'
|
64
|
+
rdoc.title = "epas #{version}"
|
65
|
+
rdoc.rdoc_files.include('README*')
|
66
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
67
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'epas'
|
5
|
+
rescue LoadError
|
6
|
+
require 'rubygems'
|
7
|
+
require 'epas'
|
8
|
+
end
|
9
|
+
|
10
|
+
credentials_file = ARGV[0] || "~/.awssecret"
|
11
|
+
ec2_regions = ARGV.drop(1)
|
12
|
+
|
13
|
+
# TODO: Add proper command line arguments handling
|
14
|
+
Epas::AutoSigner.new(credentials_file, ec2_regions)
|
data/epas.gemspec
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{epas}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Ramon Salvad\303\263"]
|
12
|
+
s.date = %q{2011-06-07}
|
13
|
+
s.default_executable = %q{ec2-puppet-autosigner}
|
14
|
+
s.description = %q{To be run in a cron script or a daemon. Autosigns ec2 instances based on hostname and instance_id, it expects instance_id as part of the ec2 instance hostname.}
|
15
|
+
s.email = %q{rsalvado@gnuine.com}
|
16
|
+
s.executables = ["ec2-puppet-autosigner"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/ec2-puppet-autosigner",
|
30
|
+
"epas.gemspec",
|
31
|
+
"lib/epas.rb",
|
32
|
+
"test/epas/test_auto_signer.rb",
|
33
|
+
"test/helper.rb"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/rsalvado/epas}
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.6.2}
|
39
|
+
s.summary = %q{Script to autosign ec2 instances into puppet.}
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<aws>, [">= 0"])
|
46
|
+
s.add_runtime_dependency(%q<i18n>, [">= 0"])
|
47
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
|
50
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<reek>, ["~> 1.2.8"])
|
52
|
+
s.add_development_dependency(%q<roodi>, ["~> 2.1.0"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<aws>, [">= 0"])
|
55
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
56
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
57
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
58
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
59
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
60
|
+
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
61
|
+
s.add_dependency(%q<roodi>, ["~> 2.1.0"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<aws>, [">= 0"])
|
65
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
66
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
67
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
68
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
69
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
70
|
+
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
71
|
+
s.add_dependency(%q<roodi>, ["~> 2.1.0"])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
data/lib/epas.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'active_support/core_ext/object/blank'
|
2
|
+
require 'active_support/core_ext/kernel/reporting'
|
3
|
+
|
4
|
+
module Epas
|
5
|
+
|
6
|
+
class UnavailableEC2Credentials < StandardError; end
|
7
|
+
class UnavailablePuppet < StandardError; end
|
8
|
+
|
9
|
+
class AutoSigner
|
10
|
+
|
11
|
+
# Creates a new auto_signer object tied to the specific ec2 account and regions provided.
|
12
|
+
#
|
13
|
+
# ==== Attributes
|
14
|
+
#
|
15
|
+
# * +file+ - Path to a file containing only the EC2 id and secret access_keys in the two first lines and in this order. Defaults to "~/.awssecret".
|
16
|
+
# * +regions+ - Array containing all EC2 regions to check, defaults to all available.
|
17
|
+
#
|
18
|
+
# ==== Examples
|
19
|
+
#
|
20
|
+
# Epas::Autosigner.new
|
21
|
+
# Epas::AutoSigner.new myfile, [ 'eu-west-1', 'eu-east-1']
|
22
|
+
def initialize(file = "~/.awssecret", regions = nil)
|
23
|
+
raise UnavailablePuppet unless command?('puppet') && command?('puppetca')
|
24
|
+
@aws_id, @aws_key = read_aws_credentials(file)
|
25
|
+
@regions = regions || get_all_ec2_regions
|
26
|
+
@awaiting_sign_instances = get_awaiting_sign_instances
|
27
|
+
end
|
28
|
+
|
29
|
+
# Signs all pending requests in puppet initiated by ec2 machines.
|
30
|
+
def sign_ec2_instance_requests!
|
31
|
+
# TODO: Add logging to syslog
|
32
|
+
unless @awaiting_sign_instances.blank?
|
33
|
+
get_all_ec2_instances_ids.each do |instance_id|
|
34
|
+
@awaiting_sign_instances.each do |hostname|
|
35
|
+
sign_instance(hostname) if hostname.match /#{instance_id}/
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def read_aws_credentials(file)
|
44
|
+
file = File.expand_path(file)
|
45
|
+
raise UnavailableEC2Credentials unless File.exists?(file)
|
46
|
+
id, key = File.read(file).split("\n")
|
47
|
+
raise UnavailableEC2Credentials if id.blank? || key.blank?
|
48
|
+
[id, key]
|
49
|
+
end
|
50
|
+
|
51
|
+
def sign_instance(hostname)
|
52
|
+
`puppet cert --sign #{hostname}`
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_awaiting_sign_instances
|
56
|
+
`puppetca --list`.split("\n")
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_all_ec2_regions
|
60
|
+
%w(eu-west-1 us-east-1 ap-northeast-1 us-west-1 ap-southeast-1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_all_ec2_instances_ids
|
64
|
+
instances = @regions.map do |region|
|
65
|
+
silence_stream STDOUT do
|
66
|
+
Aws::Ec2.new(@aws_id, @aws_key, :region => region).describe_instances
|
67
|
+
end
|
68
|
+
end.flatten
|
69
|
+
ids = instances.map { |i| i[:aws_instance_id] }
|
70
|
+
end
|
71
|
+
|
72
|
+
def command?(command)
|
73
|
+
system("which #{command} > /dev/null 2>&1")
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'aws'
|
4
|
+
|
5
|
+
class TestAutoSigner < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@awaiting_sign_instances = %w( appserver.i-qwerty.example.com dbserver.i-uiop.com ).join("\n")
|
9
|
+
@eu_instances = [ { :aws_instance_id => 'i-qwerty' } ]
|
10
|
+
@us_instances = [ { :aws_instance_id => 'i-uiop' } ]
|
11
|
+
@regions = %w(eu-west-1 us-east-1)
|
12
|
+
@instances_by_region = {
|
13
|
+
@regions[0] => @eu_instances,
|
14
|
+
@regions[1] => @us_instances
|
15
|
+
}
|
16
|
+
@aws_id = 'myid'
|
17
|
+
@aws_key = 'mykey'
|
18
|
+
@credentials_file = Tempfile.new('credentials')
|
19
|
+
@credentials_file.write "#{@aws_id}\n#{@aws_key}"
|
20
|
+
@credentials_file.close
|
21
|
+
Epas::AutoSigner.any_instance.expects(:system).with("which puppet > /dev/null 2>&1").returns(true)
|
22
|
+
Epas::AutoSigner.any_instance.expects(:system).with("which puppetca > /dev/null 2>&1").returns(true)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_should_raise_exception_when_ec2_credentials_unavailable
|
26
|
+
assert_raise Epas::UnavailableEC2Credentials do
|
27
|
+
unexistant_file = '1232wqewqdscdslkdsakdowqowqoewqoewqieoiwqoewq'
|
28
|
+
Epas::AutoSigner.new(unexistant_file)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_should_raise_exception_when_null_credentials
|
33
|
+
file = Tempfile.open('credentials')
|
34
|
+
assert_raise Epas::UnavailableEC2Credentials do
|
35
|
+
Epas::AutoSigner.new(file.path)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_should_raise_exception_when_invalid_credentials
|
40
|
+
Epas::AutoSigner.any_instance.expects(:`).with('puppetca --list').returns(@awaiting_sign_instances)
|
41
|
+
assert_raise Aws::AwsError do
|
42
|
+
as = Epas::AutoSigner.new(@credentials_file.path)
|
43
|
+
as.sign_ec2_instance_requests!
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_should_sign_our_ec2_instances_certificate_requests
|
48
|
+
|
49
|
+
@instances_by_region.each do |region, instances|
|
50
|
+
::Aws::Ec2.expects(:new).with(@aws_id, @aws_key, :region => region).returns(stub(:describe_instances => instances))
|
51
|
+
end
|
52
|
+
|
53
|
+
Epas::AutoSigner.any_instance.expects(:`).with('puppetca --list').returns(@awaiting_sign_instances)
|
54
|
+
|
55
|
+
Epas::AutoSigner.any_instance.expects(:`).with("puppet cert --sign appserver.i-qwerty.example.com").once
|
56
|
+
Epas::AutoSigner.any_instance.expects(:`).with("puppet cert --sign dbserver.i-uiop.com").once
|
57
|
+
|
58
|
+
autosigner = Epas::AutoSigner.new(@credentials_file.path, @regions)
|
59
|
+
autosigner.sign_ec2_instance_requests!
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'mocha'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
15
|
+
require 'epas'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: epas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "Ramon Salvad\xC3\xB3"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-06-07 00:00:00 +02:00
|
19
|
+
default_executable: ec2-puppet-autosigner
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
type: :runtime
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
name: aws
|
33
|
+
version_requirements: *id001
|
34
|
+
prerelease: false
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
type: :runtime
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
name: i18n
|
47
|
+
version_requirements: *id002
|
48
|
+
prerelease: false
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
type: :runtime
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
name: activesupport
|
61
|
+
version_requirements: *id003
|
62
|
+
prerelease: false
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
type: :development
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 23
|
71
|
+
segments:
|
72
|
+
- 1
|
73
|
+
- 0
|
74
|
+
- 0
|
75
|
+
version: 1.0.0
|
76
|
+
name: bundler
|
77
|
+
version_requirements: *id004
|
78
|
+
prerelease: false
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
type: :development
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ~>
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 15
|
87
|
+
segments:
|
88
|
+
- 1
|
89
|
+
- 6
|
90
|
+
- 0
|
91
|
+
version: 1.6.0
|
92
|
+
name: jeweler
|
93
|
+
version_requirements: *id005
|
94
|
+
prerelease: false
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
type: :development
|
97
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
name: rcov
|
107
|
+
version_requirements: *id006
|
108
|
+
prerelease: false
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
type: :development
|
111
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ~>
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 15
|
117
|
+
segments:
|
118
|
+
- 1
|
119
|
+
- 2
|
120
|
+
- 8
|
121
|
+
version: 1.2.8
|
122
|
+
name: reek
|
123
|
+
version_requirements: *id007
|
124
|
+
prerelease: false
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
type: :development
|
127
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ~>
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
hash: 11
|
133
|
+
segments:
|
134
|
+
- 2
|
135
|
+
- 1
|
136
|
+
- 0
|
137
|
+
version: 2.1.0
|
138
|
+
name: roodi
|
139
|
+
version_requirements: *id008
|
140
|
+
prerelease: false
|
141
|
+
description: To be run in a cron script or a daemon. Autosigns ec2 instances based on hostname and instance_id, it expects instance_id as part of the ec2 instance hostname.
|
142
|
+
email: rsalvado@gnuine.com
|
143
|
+
executables:
|
144
|
+
- ec2-puppet-autosigner
|
145
|
+
extensions: []
|
146
|
+
|
147
|
+
extra_rdoc_files:
|
148
|
+
- LICENSE.txt
|
149
|
+
- README.rdoc
|
150
|
+
files:
|
151
|
+
- .document
|
152
|
+
- Gemfile
|
153
|
+
- Gemfile.lock
|
154
|
+
- LICENSE.txt
|
155
|
+
- README.rdoc
|
156
|
+
- Rakefile
|
157
|
+
- VERSION
|
158
|
+
- bin/ec2-puppet-autosigner
|
159
|
+
- epas.gemspec
|
160
|
+
- lib/epas.rb
|
161
|
+
- test/epas/test_auto_signer.rb
|
162
|
+
- test/helper.rb
|
163
|
+
has_rdoc: true
|
164
|
+
homepage: http://github.com/rsalvado/epas
|
165
|
+
licenses:
|
166
|
+
- MIT
|
167
|
+
post_install_message:
|
168
|
+
rdoc_options: []
|
169
|
+
|
170
|
+
require_paths:
|
171
|
+
- lib
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
none: false
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
hash: 3
|
178
|
+
segments:
|
179
|
+
- 0
|
180
|
+
version: "0"
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
hash: 3
|
187
|
+
segments:
|
188
|
+
- 0
|
189
|
+
version: "0"
|
190
|
+
requirements: []
|
191
|
+
|
192
|
+
rubyforge_project:
|
193
|
+
rubygems_version: 1.6.2
|
194
|
+
signing_key:
|
195
|
+
specification_version: 3
|
196
|
+
summary: Script to autosign ec2 instances into puppet.
|
197
|
+
test_files: []
|
198
|
+
|