epas 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +8 -0
- data/README.rdoc +2 -2
- data/VERSION +1 -1
- data/epas.gemspec +5 -2
- data/lib/epas.rb +14 -1
- data/test/epas/test_auto_signer.rb +16 -5
- metadata +18 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,6 +6,7 @@ GEM
|
|
6
6
|
http_connection
|
7
7
|
uuidtools
|
8
8
|
xml-simple
|
9
|
+
columnize (0.3.2)
|
9
10
|
git (1.2.5)
|
10
11
|
http_connection (1.4.1)
|
11
12
|
i18n (0.6.0)
|
@@ -13,6 +14,7 @@ GEM
|
|
13
14
|
bundler (~> 1.0)
|
14
15
|
git (>= 1.2.5)
|
15
16
|
rake
|
17
|
+
linecache (0.43)
|
16
18
|
mocha (0.9.12)
|
17
19
|
rake (0.9.2)
|
18
20
|
rcov (0.9.9)
|
@@ -22,6 +24,11 @@ GEM
|
|
22
24
|
sexp_processor (~> 3.0)
|
23
25
|
roodi (2.1.0)
|
24
26
|
ruby_parser
|
27
|
+
ruby-debug (0.10.4)
|
28
|
+
columnize (>= 0.1)
|
29
|
+
ruby-debug-base (~> 0.10.4.0)
|
30
|
+
ruby-debug-base (0.10.4)
|
31
|
+
linecache (>= 0.3)
|
25
32
|
ruby2ruby (1.2.5)
|
26
33
|
ruby_parser (~> 2.0)
|
27
34
|
sexp_processor (~> 3.0)
|
@@ -44,3 +51,4 @@ DEPENDENCIES
|
|
44
51
|
rcov
|
45
52
|
reek (~> 1.2.8)
|
46
53
|
roodi (~> 2.1.0)
|
54
|
+
ruby-debug
|
data/README.rdoc
CHANGED
@@ -31,12 +31,12 @@ Example contents of "~/.awssecret":
|
|
31
31
|
You can also pass another file as an argument:
|
32
32
|
|
33
33
|
# Example cron job 1.
|
34
|
-
* * * * * /bin/bash -l -c '
|
34
|
+
* * * * * /bin/bash -l -c '`which ec2-puppet-autosigner` /path/to/aws_credentials'
|
35
35
|
|
36
36
|
By defaults it checks all avaliable regions, but you can also pass the regions you want to check as parameters:
|
37
37
|
|
38
38
|
# Example cron job 2.
|
39
|
-
* * * * * /bin/bash -l -c '
|
39
|
+
* * * * * /bin/bash -l -c '`which ec2-puppet-autosigner` /path/to/aws_credentials eu-west-1 us-east-1'
|
40
40
|
|
41
41
|
== Contributing to epas
|
42
42
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/epas.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{epas}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ramon Salvad\303\263"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-08}
|
13
13
|
s.default_executable = %q{ec2-puppet-autosigner}
|
14
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
15
|
s.email = %q{rsalvado@gnuine.com}
|
@@ -50,6 +50,7 @@ Gem::Specification.new do |s|
|
|
50
50
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
51
51
|
s.add_development_dependency(%q<reek>, ["~> 1.2.8"])
|
52
52
|
s.add_development_dependency(%q<roodi>, ["~> 2.1.0"])
|
53
|
+
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
53
54
|
else
|
54
55
|
s.add_dependency(%q<aws>, [">= 0"])
|
55
56
|
s.add_dependency(%q<i18n>, [">= 0"])
|
@@ -59,6 +60,7 @@ Gem::Specification.new do |s|
|
|
59
60
|
s.add_dependency(%q<rcov>, [">= 0"])
|
60
61
|
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
61
62
|
s.add_dependency(%q<roodi>, ["~> 2.1.0"])
|
63
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
62
64
|
end
|
63
65
|
else
|
64
66
|
s.add_dependency(%q<aws>, [">= 0"])
|
@@ -69,6 +71,7 @@ Gem::Specification.new do |s|
|
|
69
71
|
s.add_dependency(%q<rcov>, [">= 0"])
|
70
72
|
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
71
73
|
s.add_dependency(%q<roodi>, ["~> 2.1.0"])
|
74
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
72
75
|
end
|
73
76
|
end
|
74
77
|
|
data/lib/epas.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'syslog'
|
1
2
|
require 'active_support/core_ext/object/blank'
|
2
3
|
require 'active_support/core_ext/kernel/reporting'
|
3
4
|
require 'aws'
|
@@ -50,10 +51,17 @@ module Epas
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def sign_instance(hostname)
|
53
|
-
|
54
|
+
# TODO: Run with sudo if not root
|
55
|
+
result = system("puppet cert --sign #{hostname}")
|
56
|
+
if result
|
57
|
+
log "Server with hostname: #{hostname} signed succesfully."
|
58
|
+
else
|
59
|
+
log "Failed to sign server with hostname: #{hostname}"
|
60
|
+
end
|
54
61
|
end
|
55
62
|
|
56
63
|
def get_awaiting_sign_instances
|
64
|
+
# TODO: Run with sudo if not root
|
57
65
|
`puppetca --list`.split("\n")
|
58
66
|
end
|
59
67
|
|
@@ -74,6 +82,11 @@ module Epas
|
|
74
82
|
system("which #{command} > /dev/null 2>&1")
|
75
83
|
end
|
76
84
|
|
85
|
+
def log(message)
|
86
|
+
# $0 is the current script name
|
87
|
+
Syslog.open($0, Syslog::LOG_PID | Syslog::LOG_CONS) { |s| s.warning message }
|
88
|
+
end
|
89
|
+
|
77
90
|
end
|
78
91
|
|
79
92
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'tempfile'
|
3
3
|
require 'aws'
|
4
|
+
require 'syslog'
|
4
5
|
|
5
6
|
class TestAutoSigner < Test::Unit::TestCase
|
6
7
|
|
@@ -45,19 +46,29 @@ class TestAutoSigner < Test::Unit::TestCase
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def test_should_sign_our_ec2_instances_certificate_requests
|
49
|
+
with_ec2_testcase
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_should_log_when_signing_instances
|
53
|
+
with_ec2_testcase do
|
54
|
+
Syslog.expects(:open).twice
|
55
|
+
end
|
56
|
+
end
|
48
57
|
|
58
|
+
private
|
59
|
+
|
60
|
+
def with_ec2_testcase
|
49
61
|
@instances_by_region.each do |region, instances|
|
50
|
-
|
62
|
+
Aws::Ec2.expects(:new).with(@aws_id, @aws_key, :region => region).returns(stub(:describe_instances => instances))
|
51
63
|
end
|
52
64
|
|
53
65
|
Epas::AutoSigner.any_instance.expects(:`).with('puppetca --list').returns(@awaiting_sign_instances)
|
54
66
|
|
55
|
-
Epas::AutoSigner.any_instance.expects(
|
56
|
-
Epas::AutoSigner.any_instance.expects(
|
57
|
-
|
67
|
+
Epas::AutoSigner.any_instance.expects(:system).with("puppet cert --sign appserver.i-qwerty.example.com").once
|
68
|
+
Epas::AutoSigner.any_instance.expects(:system).with("puppet cert --sign dbserver.i-uiop.com").once
|
69
|
+
yield if block_given?
|
58
70
|
autosigner = Epas::AutoSigner.new(@credentials_file.path, @regions)
|
59
71
|
autosigner.sign_ec2_instance_requests!
|
60
|
-
|
61
72
|
end
|
62
73
|
|
63
74
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Ramon Salvad\xC3\xB3"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-08 00:00:00 +02:00
|
19
19
|
default_executable: ec2-puppet-autosigner
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -138,6 +138,20 @@ dependencies:
|
|
138
138
|
name: roodi
|
139
139
|
version_requirements: *id008
|
140
140
|
prerelease: false
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
type: :development
|
143
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
hash: 3
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
version: "0"
|
152
|
+
name: ruby-debug
|
153
|
+
version_requirements: *id009
|
154
|
+
prerelease: false
|
141
155
|
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
156
|
email: rsalvado@gnuine.com
|
143
157
|
executables:
|