puppetdb_rundeck 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 2014-07-01 Release 0.3.0
2
+ - improved performance for large instances of puppetdb
3
+ - added 30 min cache with api for clearing cache
4
+ - added json output
5
+
1
6
  2014-04-29 Release 0.2.3
2
7
  - adding sinartra binding
3
8
 
@@ -11,4 +16,4 @@
11
16
  - replaced json dependency with json_pure
12
17
 
13
18
  2014-04-25 Release 0.1.0
14
- - initial version
19
+ - initial version
data/lib/app.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'yaml'
3
+ require 'json'
3
4
  require 'sinatra'
4
5
  require 'haml'
5
6
 
@@ -7,10 +8,14 @@ require File.expand_path('../helpers/puppetdb', __FILE__)
7
8
  require File.expand_path('../helpers/process', __FILE__)
8
9
 
9
10
  require File.expand_path('../model/endpoint', __FILE__)
10
- require File.expand_path('../model/xml', __FILE__)
11
- require File.expand_path('../model/yaml', __FILE__)
12
11
 
13
12
  class PuppetDBRunDeck < Sinatra::Base
13
+ def initialize(app = nil, params = {})
14
+ super(app)
15
+ puppetdb_helper = Helpers::PuppetDB.new(settings.puppetdb_host, settings.puppetdb_port)
16
+ @endpoint = EndPoint.new(puppetdb_helper)
17
+ end
18
+
14
19
  get '/' do
15
20
  redirect to('/api')
16
21
  end
@@ -21,16 +26,25 @@ class PuppetDBRunDeck < Sinatra::Base
21
26
 
22
27
  get '/api/yaml' do
23
28
  content_type 'text/yaml'
24
- puppetdb_helper = Helpers::PuppetDB.new(settings.puppetdb_host, settings.puppetdb_port)
25
- output = YAMLOutput.new(puppetdb_helper)
26
- Helpers::Process.new().endpoint_processor(output)
29
+ content = @endpoint.to_yaml()
27
30
  end
28
31
 
29
32
  get '/api/xml' do
30
33
  content_type 'application/xml'
31
- puppetdb_helper = Helpers::PuppetDB.new(settings.puppetdb_host, settings.puppetdb_port)
32
- output = XMLOutput.new(puppetdb_helper)
33
- Helpers::Process.new().endpoint_processor(output)
34
+ content = @endpoint.to_xml()
35
+ end
36
+
37
+ get '/api/json' do
38
+ content_type 'application/json'
39
+ content = @endpoint.to_json()
40
+ end
41
+
42
+ get '/cache' do
43
+ haml :cache
44
+ end
45
+
46
+ get '/cache/clear' do
47
+ @endpoint.clear_cache
34
48
  end
35
49
  end
36
50
 
@@ -38,4 +52,4 @@ end
38
52
  if (!defined? settings.puppetdb_host) and (!defined? settings.puppetdb_port)
39
53
  PuppetDBRunDeck.set :puppetdb_host, 'localhost'
40
54
  PuppetDBRunDeck.set :puppetdb_port, '8080'
41
- end
55
+ end
@@ -16,7 +16,12 @@ class Helpers::Process
16
16
  end
17
17
 
18
18
  if collection.instance_of?(Hash)
19
+ if collection[host].nil?
20
+ collection[host] = {}
21
+ end
22
+
19
23
  collection[host][fact_name] = fact_value
24
+
20
25
  elsif collection.instance_of?(Array)
21
26
  collection << "#{fact_name}=\"#{fact_value}\" "
22
27
  else
@@ -26,29 +31,6 @@ class Helpers::Process
26
31
  return collection
27
32
  end
28
33
 
29
- def endpoint_processor(output)
30
- file_name = output.tmp_file
31
- content = ''
32
- if File.exist?(file_name)
33
- file = File.new(file_name)
34
- t_now = Time.at(Time.now.to_i)
35
- t_file = Time.at(file.mtime.to_i)
36
-
37
- if t_now < (t_file + 300)
38
- content = File.new(file_name, 'r').read
39
- else
40
- p "#{t_now} #{t_file}"
41
- endpoint = EndPoint.new()
42
- content = endpoint.parse(output)
43
- end
44
- else
45
- endpoint = EndPoint.new()
46
- content = endpoint.parse(output)
47
- end
48
-
49
- return content
50
- end
51
-
52
34
  private
53
35
  def number_to_name(name)
54
36
  lookup = {
@@ -66,4 +48,4 @@ class Helpers::Process
66
48
  return name
67
49
  end
68
50
 
69
- end
51
+ end
@@ -12,10 +12,10 @@ module Helpers
12
12
 
13
13
  def get_nodes
14
14
  uri = URI.parse( "http://#{@puppetdb_host}:#{@puppetdb_port}/v3/nodes" )
15
- http = Net::HTTP.new(uri.host, uri.port)
16
15
  request = Net::HTTP::Get.new(uri.path)
17
16
  request.add_field('Accept', 'application/json')
18
- response = http.request(request)
17
+ http_client = Net::HTTP.new(uri.host, uri.port)
18
+ response = http_client.request(request)
19
19
  response['Content-Type'] = 'application/yaml'
20
20
  if response.code == '200'
21
21
  nodes = JSON.parse(response.body)
@@ -26,20 +26,32 @@ module Helpers
26
26
  return nodes
27
27
  end
28
28
 
29
- def get_facts
30
- uri = URI.parse( "http://#{@puppetdb_host}:#{@puppetdb_port}/v3/facts" )
31
- http = Net::HTTP.new(uri.host, uri.port)
32
- request = Net::HTTP::Get.new(uri.path)
33
- request.add_field('Accept', 'application/json')
34
- response = http.request(request)
35
- response['Content-Type'] = 'application/yaml'
36
- if response.code == '200'
37
- facts = JSON.parse(response.body)
29
+ def get_facts(node=nil)
30
+ if node
31
+ fact_endpoint = "http://#{@puppetdb_host}:#{@puppetdb_port}/v3/nodes/#{node}/facts"
38
32
  else
39
- facts = []
33
+ fact_endpoint = "http://#{@puppetdb_host}:#{@puppetdb_port}/v3/facts"
40
34
  end
41
35
 
42
- return facts
36
+ #p "requesting facts by: #{fact_endpoint}"
37
+
38
+ uri = URI.parse(fact_endpoint)
39
+ request = Net::HTTP::Get.new(uri.path)
40
+ request.add_field('Accept', 'application/json')
41
+ http_client = Net::HTTP.new(uri.host, uri.port)
42
+ begin
43
+ response = http_client.request(request)
44
+ response['Content-Type'] = 'application/json'
45
+ if response.code == '200'
46
+ facts = JSON.parse(response.body)
47
+ else
48
+ facts = []
49
+ end
50
+
51
+ return facts
52
+ rescue Timeout::Error
53
+
54
+ end
43
55
  end
44
56
 
45
57
  end
@@ -1,5 +1,122 @@
1
+ require File.expand_path('../../helpers/process', __FILE__)
2
+
1
3
  class EndPoint
2
- def parse(parser)
3
- parser.parse
4
+
5
+ attr_accessor :cache_timeout
6
+ THREAD_COUNT = 40
7
+
8
+ def initialize(puppetdb_helper)
9
+ @db_helper = puppetdb_helper
10
+ @cache_timeout = 1800
4
11
  end
5
- end
12
+
13
+ def reload(type)
14
+ nodes = @db_helper.get_nodes
15
+
16
+ @rundeck_data = Hash.new
17
+
18
+ helper = Helpers::Process.new
19
+
20
+ mutex = Mutex.new
21
+
22
+ per_type_cache = "/tmp/puppetdb-resource.#{type}"
23
+
24
+ THREAD_COUNT.times.map {
25
+ Thread.new(nodes, @rundeck_data) do |nodes|
26
+ while node = mutex.synchronize { nodes.pop }
27
+ host = node['name']
28
+ facts = @db_helper.get_facts(host)
29
+ if !facts.nil?
30
+ mutex.synchronize { helper.add_facts(facts, host, @rundeck_data) }
31
+ end
32
+ end
33
+ end
34
+ }.each(&:join)
35
+
36
+ data = case type
37
+ when 'json' then to_json(false)
38
+ when 'yaml' then to_yaml(false)
39
+ when 'xml' then to_xml(false)
40
+ else "unknown"
41
+ end
42
+
43
+ File.open(per_type_cache, 'w') { |file| file.write(data) }
44
+
45
+ return data
46
+ end
47
+
48
+ def to_json(parse_data=true)
49
+ parse('json') if parse_data == true
50
+ if @rundeck_data.is_a?(String)
51
+ @rundeck_data
52
+ else
53
+ @rundeck_data.to_json
54
+ end
55
+ end
56
+
57
+ def to_yaml(parse_data=true)
58
+ parse('yaml') if parse_data == true
59
+ if @rundeck_data.is_a?(String)
60
+ @rundeck_data
61
+ else
62
+ @rundeck_data.to_yaml
63
+ end
64
+ end
65
+
66
+ def to_xml(parse_data=true)
67
+ helper = Helpers::Process.new
68
+
69
+ parse('xml') if parse_data == true
70
+ if @rundeck_data.is_a?(String)
71
+ @rundeck_data
72
+ else
73
+ data = Array.new
74
+ data << "<project>\n"
75
+ @rundeck_data.keys.each {|n|
76
+ data << "<node name=\"#{n}\""
77
+ @rundeck_data[n].each {|k,v|
78
+ data << "#{k}=\"#{v}\""
79
+ }
80
+ data << "/>\n"
81
+ }
82
+ data << "</project>"
83
+ xml = data.join(" ")
84
+
85
+ @rundeck_data = xml
86
+ end
87
+ end
88
+
89
+
90
+ def parse(type)
91
+ per_type_cache = "/tmp/puppetdb-resource.#{type}"
92
+
93
+ if File.exist?(per_type_cache)
94
+ file = File.new(per_type_cache)
95
+ t_now = Time.at(Time.now.to_i)
96
+ t_file = Time.at(file.mtime.to_i)
97
+
98
+ if t_now < (t_file + @cache_timeout)
99
+ p "reading from cache for #{type}"
100
+ @rundeck_data = File.new(per_type_cache, 'r').read
101
+ else
102
+ p "not reading from cache for: #{type}"
103
+ reload(type)
104
+ end
105
+ else
106
+ p "not reading from cache for: #{type}"
107
+ reload(type)
108
+ end
109
+ end
110
+
111
+ def clear_cache
112
+ cache_files = ['/tmp/puppetdb-resource.xml','/tmp/puppetdb-resource.json','/tmp/puppetdb-resource.yaml']
113
+
114
+ cache_files.each do |file|
115
+ if File.exist?(file)
116
+ FileUtils.rm file
117
+ end
118
+ end
119
+ "Cached cleared"
120
+ end
121
+
122
+ end
data/lib/views/api.haml CHANGED
@@ -7,9 +7,15 @@
7
7
  %p
8
8
  The puppetdb-rundeck application allows Rundeck to make use of the node and fact information stored in PuppetDB.
9
9
  %p
10
- Two API endpoints are provided which you can point Rundeck to:
10
+ Three API endpoints are provided which you can point Rundeck to:
11
11
  %ul
12
12
  %li
13
13
  %a(href="/api/xml") XML
14
14
  %li
15
- %a(href="/api/yaml") YAML
15
+ %a(href="/api/yaml") YAML
16
+ %li
17
+ %a(href="/api/json") JSON
18
+ %p
19
+ %p
20
+ To set the cache settings for this API, see
21
+ %a(href="/cache") here
@@ -0,0 +1,12 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title PuppetDB-Rundeck
5
+ %body
6
+ %h1 PuppetDB-Rundeck
7
+ %h2 Cache settings
8
+ %p
9
+ The puppetdb-rundeck resource api caches data for a default time of 30 mins.
10
+ %p
11
+ To clear the cache click
12
+ %a(href="/cache/clear") here
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'puppetdb_rundeck'
6
- spec.version = '0.2.3'
6
+ spec.version = '0.3.0'
7
7
  spec.authors = ['liamjbennett']
8
8
  spec.email = ['lbennett@opentable.com']
9
9
  spec.summary = %q{A sinatra based application to provide integration between PuppetDB and Rundeck}
@@ -18,15 +18,17 @@ with rundeck}
18
18
  spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1.5'
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
22
  spec.add_development_dependency 'rake', '~> 10.2'
23
23
  spec.add_development_dependency 'rspec'
24
24
  spec.add_development_dependency 'rack-test'
25
25
  spec.add_development_dependency 'webmock'
26
26
  spec.add_development_dependency 'rspec-mocks'
27
+ spec.add_development_dependency 'builder'
27
28
 
28
29
  spec.add_runtime_dependency 'json_pure', '~> 1.8'
29
30
  spec.add_runtime_dependency 'tilt', '~> 1.3'
30
31
  spec.add_runtime_dependency 'sinatra', '~> 1.4'
31
32
  spec.add_runtime_dependency 'haml', '~> 4.0'
33
+ spec.add_runtime_dependency 'thread', '~> 0.1'
32
34
  end
data/spec/app_spec.rb CHANGED
@@ -12,7 +12,7 @@ describe 'puppetdb_rundeck Application' do
12
12
  it 'should allow access to the main api page' do
13
13
  get '/api'
14
14
  last_response.should be_ok
15
- last_response.body.should include('Two API endpoints are provided')
15
+ last_response.body.should include('Three API endpoints are provided')
16
16
  end
17
17
 
18
18
  it 'should allow access to the xml endpoint' do
@@ -26,4 +26,4 @@ describe 'puppetdb_rundeck Application' do
26
26
  get '/api/yaml'
27
27
  last_response.should be_ok
28
28
  end
29
- end
29
+ end
@@ -1,18 +1,21 @@
1
1
  require File.expand_path '../../spec_helper.rb', __FILE__
2
2
  require File.expand_path '../../../lib/helpers/puppetdb', __FILE__
3
- require File.expand_path '../../../lib/model/xml', __FILE__
4
3
 
5
- describe XMLOutput, '#parse' do
4
+ describe EndPoint, '#to_xml' do
6
5
 
7
6
  it 'should return valid xml containing the node name' do
8
7
  helper = Helpers::PuppetDB.new('fubar', '80')
9
8
  allow(helper).to receive(:get_nodes).and_return([{'name' => 'test.internal'}])
10
9
  allow(helper).to receive(:get_facts).and_return([{'certname' => 'test.internal', 'name' => 'osfamily', 'value' => 'Debian'}])
11
10
 
12
- xml_output = XMLOutput.new(helper)
11
+ if File.exist?('/tmp/puppetdb-resource.xml')
12
+ FileUtils.rm '/tmp/puppetdb-resource.xml'
13
+ end
13
14
 
14
- expectation = "<project>\n <node name=\"test.internal\" osfamily=\"Debian\" />\n </project>"
15
+ endpoint = EndPoint.new(helper)
15
16
 
16
- xml_output.parse.should == expectation
17
+ expectation = "<project>\n <node name=\"test.internal\" osfamily=\"Debian\" />\n </project>"
18
+
19
+ endpoint.to_xml().should == expectation
17
20
  end
18
- end
21
+ end
@@ -1,18 +1,21 @@
1
1
  require File.expand_path '../../spec_helper.rb', __FILE__
2
2
  require File.expand_path '../../../lib/helpers/puppetdb', __FILE__
3
- require File.expand_path '../../../lib/model/yaml', __FILE__
4
3
 
5
- describe YAMLOutput, '#parse' do
4
+ describe EndPoint, '#to_yaml' do
6
5
 
7
6
  it 'should return valid yaml containing the node name' do
8
7
  helper = Helpers::PuppetDB.new('fubar', '80')
9
8
  allow(helper).to receive(:get_nodes).and_return([{'name' => 'test.internal'}])
10
9
  allow(helper).to receive(:get_facts).and_return([{'certname' => 'test.internal', 'name' => 'osfamily', 'value' => 'Debian'}])
11
10
 
12
- yaml_output = YAMLOutput.new(helper)
11
+ if File.exist?('/tmp/puppetdb-resource.yaml')
12
+ FileUtils.rm '/tmp/puppetdb-resource.yaml'
13
+ end
14
+
15
+ endpoint = EndPoint.new(helper)
13
16
 
14
17
  expectation = "---\ntest.internal:\n osfamily: Debian\n"
15
18
 
16
- yaml_output.parse.should == expectation
19
+ endpoint.to_yaml().should == expectation
17
20
  end
18
- end
21
+ end
metadata CHANGED
@@ -1,32 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppetdb_rundeck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - liamjbennett
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-04-29 00:00:00.000000000 Z
12
+ date: 2014-07-01 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
19
- version: '1.5'
21
+ version: '1.6'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
26
- version: '1.5'
29
+ version: '1.6'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -41,62 +46,87 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rspec
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rack-test
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: webmock
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - '>='
83
+ - - ! '>='
74
84
  - !ruby/object:Gem::Version
75
85
  version: '0'
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - '>='
91
+ - - ! '>='
81
92
  - !ruby/object:Gem::Version
82
93
  version: '0'
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: rspec-mocks
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - '>='
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - '>='
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: builder
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
95
124
  - !ruby/object:Gem::Version
96
125
  version: '0'
97
126
  - !ruby/object:Gem::Dependency
98
127
  name: json_pure
99
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
100
130
  requirements:
101
131
  - - ~>
102
132
  - !ruby/object:Gem::Version
@@ -104,6 +134,7 @@ dependencies:
104
134
  type: :runtime
105
135
  prerelease: false
106
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
107
138
  requirements:
108
139
  - - ~>
109
140
  - !ruby/object:Gem::Version
@@ -111,6 +142,7 @@ dependencies:
111
142
  - !ruby/object:Gem::Dependency
112
143
  name: tilt
113
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
114
146
  requirements:
115
147
  - - ~>
116
148
  - !ruby/object:Gem::Version
@@ -118,6 +150,7 @@ dependencies:
118
150
  type: :runtime
119
151
  prerelease: false
120
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
121
154
  requirements:
122
155
  - - ~>
123
156
  - !ruby/object:Gem::Version
@@ -125,6 +158,7 @@ dependencies:
125
158
  - !ruby/object:Gem::Dependency
126
159
  name: sinatra
127
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
128
162
  requirements:
129
163
  - - ~>
130
164
  - !ruby/object:Gem::Version
@@ -132,6 +166,7 @@ dependencies:
132
166
  type: :runtime
133
167
  prerelease: false
134
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
135
170
  requirements:
136
171
  - - ~>
137
172
  - !ruby/object:Gem::Version
@@ -139,6 +174,7 @@ dependencies:
139
174
  - !ruby/object:Gem::Dependency
140
175
  name: haml
141
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
142
178
  requirements:
143
179
  - - ~>
144
180
  - !ruby/object:Gem::Version
@@ -146,14 +182,34 @@ dependencies:
146
182
  type: :runtime
147
183
  prerelease: false
148
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
149
186
  requirements:
150
187
  - - ~>
151
188
  - !ruby/object:Gem::Version
152
189
  version: '4.0'
153
- description: |-
154
- puppetdb_rundeck is a sinatra based application to provide integration between PuppetDB and Rundeck.
155
- It provides an api in either xml or yaml that allows the node and fact data with puppetdb to use used as a resource
156
- with rundeck
190
+ - !ruby/object:Gem::Dependency
191
+ name: thread
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ~>
196
+ - !ruby/object:Gem::Version
197
+ version: '0.1'
198
+ type: :runtime
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: '0.1'
206
+ description: ! 'puppetdb_rundeck is a sinatra based application to provide integration
207
+ between PuppetDB and Rundeck.
208
+
209
+ It provides an api in either xml or yaml that allows the node and fact data with
210
+ puppetdb to use used as a resource
211
+
212
+ with rundeck'
157
213
  email:
158
214
  - lbennett@opentable.com
159
215
  executables:
@@ -174,9 +230,8 @@ files:
174
230
  - lib/helpers/process.rb
175
231
  - lib/helpers/puppetdb.rb
176
232
  - lib/model/endpoint.rb
177
- - lib/model/xml.rb
178
- - lib/model/yaml.rb
179
233
  - lib/views/api.haml
234
+ - lib/views/cache.haml
180
235
  - puppetdb_rundeck.gemspec
181
236
  - spec/app_spec.rb
182
237
  - spec/helpers/puppetdb_spec.rb
@@ -187,26 +242,27 @@ files:
187
242
  homepage: https://github.com/opentable/puppetdb_rundeck
188
243
  licenses:
189
244
  - MIT
190
- metadata: {}
191
245
  post_install_message:
192
246
  rdoc_options: []
193
247
  require_paths:
194
248
  - lib
195
249
  required_ruby_version: !ruby/object:Gem::Requirement
250
+ none: false
196
251
  requirements:
197
- - - '>='
252
+ - - ! '>='
198
253
  - !ruby/object:Gem::Version
199
254
  version: '0'
200
255
  required_rubygems_version: !ruby/object:Gem::Requirement
256
+ none: false
201
257
  requirements:
202
- - - '>='
258
+ - - ! '>='
203
259
  - !ruby/object:Gem::Version
204
260
  version: '0'
205
261
  requirements: []
206
262
  rubyforge_project:
207
- rubygems_version: 2.2.2
263
+ rubygems_version: 1.8.23.2
208
264
  signing_key:
209
- specification_version: 4
265
+ specification_version: 3
210
266
  summary: A sinatra based application to provide integration between PuppetDB and Rundeck
211
267
  test_files:
212
268
  - spec/app_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: e9655db5de0d26353aea8cb5ca99f2d052b5e2b2
4
- data.tar.gz: 5323191cb82df62b8b05e1158f0a0c742fead502
5
- SHA512:
6
- metadata.gz: 05e07051dc72525ba7d1b6552f87562f58fd4ded6cac8cb279e21b0ecd0597eff4b02eda493a1101b44fd4dd5afc23147da0c11b98512a88a75d7f7390ed0de4
7
- data.tar.gz: aba7c2d4107b2d1277568617f5f02dc2e7a33e04cb5f47433af814fa2f37254ad1086825afc373fcd5b31c3047fa3cdea42a25efcf178eece8fdcbf5cd8907b6
data/lib/model/xml.rb DELETED
@@ -1,37 +0,0 @@
1
- require File.expand_path('../../helpers/process', __FILE__)
2
-
3
- class XMLOutput
4
- attr_accessor :tmp_file
5
- attr_accessor :db_helper
6
-
7
- def initialize(puppetdb_helper)
8
- @tmp_file = '/tmp/puppetdb-resource.xml'
9
- @db_helper = puppetdb_helper
10
- end
11
-
12
- def parse
13
- nodes = @db_helper.get_nodes
14
- facts = @db_helper.get_facts
15
- helper = Helpers::Process.new
16
-
17
- rundeck_data = Array.new
18
- rundeck_data << "<project>\n"
19
-
20
- nodes.each{|n|
21
- host = n['name']
22
-
23
- rundeck_data << "<node name=\"#{host}\""
24
-
25
- rundeck_data = helper.add_facts(facts, host, rundeck_data)
26
-
27
- rundeck_data << "/>\n"
28
- }
29
-
30
- rundeck_data << "</project>"
31
- xml = rundeck_data.join(" ")
32
-
33
- File.open(@tmp_file, 'w') { |file| file.write(xml) }
34
-
35
- return xml
36
- end
37
- end
data/lib/model/yaml.rb DELETED
@@ -1,31 +0,0 @@
1
- require File.expand_path('../../helpers/process', __FILE__)
2
-
3
- class YAMLOutput
4
- attr_accessor :tmp_file
5
-
6
- def initialize(puppetdb_helper)
7
- @tmp_file = '/tmp/puppetdb-resource.yaml'
8
- @db_helper = puppetdb_helper
9
- end
10
-
11
- def parse
12
- nodes = @db_helper.get_nodes
13
- facts = @db_helper.get_facts
14
- helper = Helpers::Process.new
15
-
16
- rundeck_data = Hash.new
17
- nodes.each{|d|
18
- host = d['name']
19
-
20
- rundeck_data[host] = Hash.new if not rundeck_data.key?(host)
21
-
22
- rundeck_data = helper.add_facts(facts, host, rundeck_data)
23
- }
24
-
25
- yaml = rundeck_data.to_yaml
26
-
27
- File.open(@tmp_file, 'w') { |file| file.write(yaml) }
28
-
29
- return yaml
30
- end
31
- end