chef-rundeck 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acd9c147df627c29f79ec208b7ad4796a1933c81
4
- data.tar.gz: 312f65e10a495d38b4e752fefef49099073b872a
3
+ metadata.gz: 0a2d92734fe5fb40c98da75959323085c520e7ed
4
+ data.tar.gz: d68f81f5b3ca5692f331e2fcc850da4d1556b4cc
5
5
  SHA512:
6
- metadata.gz: 6427c173c17c256172eb7b81c67047aa724d91e34004c2ddb3873aade19844977dbeebe38952964ac36cd14047b77cbfc2b4a863bc2aeeb9ebf9f704ba8faeb9
7
- data.tar.gz: 207ed6aaaf9fad065ec4c06a44e7b9791d766569fcf59c8a8991d4dce4ffd8a3019f6fce8d1021d61ac780d571005ffc4ee9ac63429c39348fa8b5c26a96b654
6
+ metadata.gz: 7fe3bdfcaf2611f1a4b40411dc5102d8115582a954919b7dacf3a0a5e7b5412d1233e4673035aa62579fa6cec1da6b736a228639446ba7ecc6dd705add5406cb
7
+ data.tar.gz: 0daa97c60b39c83a55f2237181a9da35ab0fff702573e88f27473ff06aeaeabf0adfebdcd17f3baa42b0a8ecb635c1dfb180f220c79e4b96f430291ec97fb1a0
data/README.md CHANGED
@@ -8,11 +8,24 @@ A simple Sinatra app that presents matching node results of a Chef search format
8
8
 
9
9
  ## Usage
10
10
 
11
- Install the gem and fire up chef-rundeck. Point it at a Chef client config file (a knife config would be ideal) and provide the URI for your Chef server's web UI.
11
+ Install the gem and fire up chef-rundeck. Point it at a Chef client config file (a knife config would be ideal) using
12
+ the `-c` flag and provide the URI for your Chef server's web UI.
12
13
 
13
14
  ## Configuration Notes
14
15
 
15
- More to come.
16
+ chef-rundeck binds to "localhost," which may result in it binding to an IPv6-only address in certain configurations.
17
+ If this isn't what you want, try starting chef-rundeck with the `-o` switch, e.g. `-o 0.0.0.0`.
18
+
19
+ You can use the `-u` switch to override the username that is inserted into a project as the remote user that Rundeck should use for execution.
20
+ The default is the system user that executes chef-rundeck, which may not be what you expect.
21
+
22
+ chef-rundeck now supports partial search against Enterprise Chef and OSS Chef servers running version 11 or greater!
23
+ If your organization has many nodes and you notice slow performance from chef-rundeck, try turning it on with `--partial-search true`.
24
+
25
+ chef-rundeck caches the generated resource XML for a project by default for 30 seconds. If this behavior ruins your day, change the number
26
+ of seconds a document is cached by using the `-t` switch.
27
+
28
+ Further configuration details can be found on the [wiki] (https://github.com/oswaldlabs/chef-rundeck/wiki/).
16
29
 
17
30
  ## Notes on Patches/Pull Requests
18
31
 
@@ -28,4 +41,4 @@ We want your cool additional feature. Here's how to give it to us:
28
41
 
29
42
  # Copyright
30
43
 
31
- Original code © 2010 Adam Jacob. Released to the open source community under the Apache license in 2013. See the LICENSE file for details.
44
+ Original code © 2010 Adam Jacob. Released to the open source community under the Apache license in 2013. See the LICENSE file for details.
@@ -68,7 +68,8 @@ class ChefRundeck < Sinatra::Base
68
68
  get "/#{project}" do
69
69
  content_type 'text/xml'
70
70
  Chef::Log.info("Loading nodes for /#{project}")
71
- send_file build_project project, projects[project]['pattern'], projects[project]['username'], (projects[project]['hostname'].nil? ? "fqdn" : projects[project]['hostname']), projects[project]['attributes']
71
+ # TODO: Validate project data before rendering the document?
72
+ send_file build_project project, projects[project]['pattern'], (projects[project]['username'].nil? ? ChefRundeck.username : projects[project]['username']), (projects[project]['hostname'].nil? ? "fqdn" : projects[project]['hostname']), projects[project]['attributes']
72
73
  end
73
74
  cache_file = "#{Dir.tmpdir}/chef-rundeck-#{project}.xml"
74
75
  at_exit { File.delete(cache_file) if File.exist?(cache_file) }
@@ -107,6 +108,7 @@ class ChefRundeck < Sinatra::Base
107
108
  'chef_environment' => [ 'chef_environment' ],
108
109
  'platform' => [ 'platform'],
109
110
  'platform_version' => [ 'platform_version' ],
111
+ 'tags' => [ 'tags' ],
110
112
  'hostname' => [hostname]
111
113
  }
112
114
  if !custom_attributes.nil? then
@@ -142,7 +144,7 @@ class ChefRundeck < Sinatra::Base
142
144
  node_is_valid? node
143
145
  rescue ArgumentError => ae
144
146
  Chef::Log.warn("invalid node element: #{ae}")
145
- failed = failed +1
147
+ failed = failed + 1
146
148
  next
147
149
  end
148
150
 
@@ -181,7 +183,7 @@ def build_node (node, username, hostname, custom_attributes)
181
183
  osVersion="#{xml_escape(node['platform_version'])}"
182
184
  roles="#{xml_escape(node['roles'].join(','))}"
183
185
  recipes="#{xml_escape(node['recipes'].join(','))}"
184
- tags="#{xml_escape(node['roles'].concat(node['recipes']).join(',') + ',' + node['chef_environment'])}"
186
+ tags="#{xml_escape([ node['roles'], node['recipes'], node['chef_environment'], node['tags']].flatten.join(","))}"
185
187
  environment="#{xml_escape(node['chef_environment'])}"
186
188
  username="#{xml_escape(username)}"
187
189
  hostname="#{xml_escape(node['hostname'])}"
@@ -229,6 +231,7 @@ def convert_results(results, hostname, custom_attributes)
229
231
  n['kernel_os'] = !node['kernel'].nil? ? node['kernel']['os'] : nil
230
232
  n['platform'] = node['platform']
231
233
  n['platform_version'] = node['platform_version']
234
+ n['tags'] = node['tags']
232
235
 
233
236
  if !custom_attributes.nil? then
234
237
  custom_attributes.each do |attr|
@@ -14,57 +14,97 @@ describe 'ChefRundeck' do
14
14
  end
15
15
  it 'fetch to root should return 200' do
16
16
  get '/'
17
- last_response.should be_ok
17
+ expect(last_response).to be_ok
18
18
  end
19
- it 'fetched document should be Nokogiri-parseable XML document' do
19
+ it 'fetched document should be parseable by Nokogiri without errors' do
20
20
  get '/'
21
- Nokogiri::XML(last_response.body).document.should be_true
21
+ expect(Nokogiri::XML(last_response.body).document.errors).to be_empty
22
22
  end
23
- it 'fetched document should be node1 only' do
23
+ it 'data for node1 should contain tag attribute with Chef node object\'s tag, role, recipes in run list and environment' do
24
+ get '/'
25
+ expect(last_response).to be_ok
26
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@tags").text()).to include("role1")
27
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@tags").text()).to include("cookbook::default")
28
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@tags").text()).to include("tag1")
29
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@tags").text()).to include("development")
30
+ end
31
+ it 'data for node1 should contain custom role attribute with Chef node object\'s role' do
32
+ get '/'
33
+ expect(last_response).to be_ok
34
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@roles").text()).to include("role1")
35
+ end
36
+ it 'data for node1 should contain custom recipes attribute with Chef node object\'s run list' do
37
+ get '/'
38
+ expect(last_response).to be_ok
39
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@recipes").text()).to include("cookbook::default")
40
+ end
41
+ it 'data for node1 should contain custom environment attribute with Chef node object\'s environment' do
42
+ get '/'
43
+ expect(last_response).to be_ok
44
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@environment").text()).to eq("development")
45
+ end
46
+ it 'data for node1 should contain default ChefRundeck username' do
47
+ get '/'
48
+ expect(last_response).to be_ok
49
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@username").text()).to eq(ChefRundeck.username)
50
+ end
51
+ it 'fetched document for first test project should be node1 only' do
24
52
  get '/node1_systems'
25
- last_response.should be_ok
26
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']").length().should == 1
27
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']").length().should == 0
53
+ expect(last_response).to be_ok
54
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']").length()).to eq(1)
55
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']").length()).to eq(0)
28
56
  end
29
57
  it 'fetched document should be node1 only verify hostname override' do
30
58
  get '/node1_systems'
31
- last_response.should be_ok
32
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@hostname").text().should == "10.0.0.1"
59
+ expect(last_response).to be_ok
60
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@hostname").text()).to eq("10.0.0.1")
61
+ end
62
+ it 'fetched document node data should contain custom username' do
63
+ get '/node1_systems'
64
+ expect(last_response).to be_ok
65
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@username").text()).to eq("rundeck")
33
66
  end
34
67
  it 'fetched document should be node2 only verify hostname' do
35
68
  get '/node2_systems'
36
- last_response.should be_ok
37
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/@hostname").text().should == "node2.chefrundeck.local"
69
+ expect(last_response).to be_ok
70
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/@hostname").text()).to eq("node2.chefrundeck.local")
38
71
  end
39
72
  it 'fetched document should be node2 only' do
40
73
  get '/node2_systems'
41
- last_response.should be_ok
42
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']").length().should == 0
43
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']").length().should == 1
74
+ expect(last_response).to be_ok
75
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']").length()).to eq(0)
76
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']").length()).to eq(1)
44
77
  end
45
78
  it 'check custom attributes on node2 only' do
46
79
  get '/node2_systems'
47
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute").length().should == 2
48
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute")[0].text.should == "linux"
49
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute")[1].text.should == "centos"
80
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute").length()).to eq(2)
81
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute")[0].text).to eq("linux")
82
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute")[1].text).to eq("centos")
50
83
  end
51
- it 'check partial search' do
52
- ChefRundeck.partial_search = true
84
+ it 'fetched document node data should use application default' do
53
85
  get '/node2_systems'
54
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute").length().should == 2
55
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute")[0].text.should == "linux"
56
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute")[1].text.should == "centos"
86
+ expect(last_response).to be_ok
87
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/@username").text()).to eq(ChefRundeck.username)
57
88
  end
58
- it 'partial search: fetched document should be node1 only verify hostname override' do
59
- ChefRundeck.partial_search = true
60
- get '/node1_systems'
61
- last_response.should be_ok
62
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@hostname").text().should == "10.0.0.1"
63
- end
64
- it 'partial search: fetched document should be node2 only verify hostname' do
65
- ChefRundeck.partial_search = true
66
- get '/node2_systems'
67
- last_response.should be_ok
68
- Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/@hostname").text().should == "node2.chefrundeck.local"
89
+ context 'when partial search is enabled' do
90
+ before do
91
+ ChefRundeck.partial_search = true
92
+ end
93
+ it 'check partial search' do
94
+ get '/node2_systems'
95
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute").length()).to eq(2)
96
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute")[0].text).to eq("linux")
97
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/attribute")[1].text).to eq("centos")
98
+ end
99
+ it 'fetched document should be node1 only verify hostname override' do
100
+ get '/node1_systems'
101
+ expect(last_response).to be_ok
102
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node1.chefrundeck.local']/@hostname").text).to eq("10.0.0.1")
103
+ end
104
+ it 'fetched document should be node2 only verify hostname' do
105
+ get '/node2_systems'
106
+ expect(last_response).to be_ok
107
+ expect(Nokogiri::XML(last_response.body).xpath("//project/node[@name='node2.chefrundeck.local']/@hostname").text).to eq("node2.chefrundeck.local")
108
+ end
69
109
  end
70
110
  end
@@ -3,7 +3,6 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'chef-rundeck'
4
4
  require 'sinatra'
5
5
  require 'rspec'
6
- require 'rspec/autorun'
7
6
  require 'rack/test'
8
7
 
9
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-rundeck
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.2.2
154
+ rubygems_version: 2.3.0
155
155
  signing_key:
156
156
  specification_version: 3
157
157
  summary: Integrates Chef with RunDeck