echelon_chef 0.0.1
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 +0 -0
- data/README.md +0 -0
- data/echelon_chef.gemspec +14 -0
- data/lib/echelon_chef.rb +1 -0
- data/lib/echelon_chef/echelon_chef.rb +49 -0
- data/lib/echelon_chef/version.rb +3 -0
- metadata +51 -0
data/CHANGELOG.md
ADDED
File without changes
|
data/README.md
ADDED
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) + '/lib/'
|
2
|
+
require 'echelon_chef/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'echelon_chef'
|
6
|
+
s.version = EchelonChef::VERSION
|
7
|
+
s.summary = 'Chef interaction helper'
|
8
|
+
s.author = 'Heavy Water'
|
9
|
+
s.email = 'chris@hw-ops.com'
|
10
|
+
s.homepage = 'http://github.com/heavywater/echelon_chef'
|
11
|
+
s.description = "Chef interaction helper"
|
12
|
+
s.require_path = 'lib'
|
13
|
+
s.files = Dir.glob('**/*')
|
14
|
+
end
|
data/lib/echelon_chef.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'echelon_chef/echelon_chef'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
%w(config log rest node).each do |lib|
|
2
|
+
require "chef/#{lib}"
|
3
|
+
end
|
4
|
+
|
5
|
+
class EchelonChef
|
6
|
+
|
7
|
+
attr_reader :config
|
8
|
+
|
9
|
+
def initialize(config=nil)
|
10
|
+
@config = config || {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def enabled?
|
14
|
+
config['enabled']
|
15
|
+
end
|
16
|
+
|
17
|
+
def correct_environment?(environment=nil)
|
18
|
+
if(enabled?)
|
19
|
+
env = Array(environment || config['environment'])
|
20
|
+
if(env.empty?)
|
21
|
+
true
|
22
|
+
else
|
23
|
+
rest = Chef::REST.new(
|
24
|
+
config['server_url'],
|
25
|
+
config['node_name'],
|
26
|
+
config['signing_key_filename']
|
27
|
+
)
|
28
|
+
node_env = rest.get_rest("/nodes/" + @event['client']['name']).chef_environment
|
29
|
+
env.include?(node_env)
|
30
|
+
end
|
31
|
+
else
|
32
|
+
true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def client_exists?(client)
|
37
|
+
raise "Valid client name must be provided (got: #{client})" if client.to_s.empty?
|
38
|
+
if(enabled?)
|
39
|
+
Chef::REST.new(
|
40
|
+
config['server_url'],
|
41
|
+
config['node_name'],
|
42
|
+
config['signing_key_filename']
|
43
|
+
).get_rest("/clients").keys.include?(client)
|
44
|
+
else
|
45
|
+
true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: echelon_chef
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Heavy Water
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Chef interaction helper
|
15
|
+
email: chris@hw-ops.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- CHANGELOG.md
|
21
|
+
- echelon_chef.gemspec
|
22
|
+
- README.md
|
23
|
+
- lib/echelon_chef.rb
|
24
|
+
- lib/echelon_chef/version.rb
|
25
|
+
- lib/echelon_chef/echelon_chef.rb
|
26
|
+
homepage: http://github.com/heavywater/echelon_chef
|
27
|
+
licenses: []
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 1.8.17
|
47
|
+
signing_key:
|
48
|
+
specification_version: 3
|
49
|
+
summary: Chef interaction helper
|
50
|
+
test_files: []
|
51
|
+
has_rdoc:
|