puppet-rundeck-2013 0.0.11 → 0.0.12
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/README.rdoc +15 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/puppet-rundeck.rb +26 -4
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
{<img src="https://badge.fury.io/rb/puppet-rundeck-2013.png" alt="Gem Version" />}[http://badge.fury.io/rb/puppet-rundeck-2013]
|
2
|
+
|
3
|
+
|
1
4
|
= puppet-rundeck-2013
|
2
5
|
|
3
6
|
Integrates Puppet with RunDeck.
|
@@ -17,9 +20,11 @@ Requires:
|
|
17
20
|
|
18
21
|
== Installation
|
19
22
|
|
23
|
+
|
20
24
|
Install the gem:
|
21
25
|
|
22
|
-
$ sudo gem install puppet-rundeck
|
26
|
+
$ sudo gem install puppet-rundeck-2013
|
27
|
+
|
23
28
|
|
24
29
|
== Usage
|
25
30
|
|
@@ -59,10 +64,15 @@ on the same puppet server and puppet-rundeck instance:
|
|
59
64
|
|
60
65
|
project.resources.url = http://localhost:8144/tag/production
|
61
66
|
|
67
|
+
You can also specify a required facts to filter the node list, to provide different project URLs based
|
68
|
+
on the same puppet server and puppet-rundeck instance:
|
69
|
+
|
70
|
+
project.resources.url = http://localhost:8144/facts/timezone=UTC&uptime_days=0
|
71
|
+
|
62
72
|
In the version puppet-rundeck-2013 you can also pass configuration flags for puppet-rundeck.
|
63
73
|
|
64
74
|
- user=rundeck_ssh_username - to override SSH user for Rundeck
|
65
|
-
- use_tags=0 - to avoid adding default tags puppet from puppetmaster
|
75
|
+
- use_tags=0 - to avoid adding default tags puppet from puppetmaster. Disabling tags drastically speeds up result generation.
|
66
76
|
- add_facts=fact1,fact2,fact3 - list of facter facts that will be added as tags for rundeck
|
67
77
|
|
68
78
|
Examples:
|
@@ -70,6 +80,9 @@ Examples:
|
|
70
80
|
Add facts *fqdn* and *ipaddress* to list of tags, set SSH user to *root* and disable puppet-generated tags:
|
71
81
|
curl http://127.0.0.1:8144/?add_facts=fqdn,ipaddress&user=root&use_tags=0
|
72
82
|
|
83
|
+
Add facts *fqdn* and *ipaddress* to list of tags, set SSH user to *root* and disable puppet-generated tags only for nodes with timezone = UTC and having days uptime=0:
|
84
|
+
curl http://127.0.0.1:8144/facts/timezone=UTC&uptime_days=0?add_facts=fqdn,ipaddress&user=root&use_tags=0
|
85
|
+
|
73
86
|
|
74
87
|
You can specify some configuration options:
|
75
88
|
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
gem.description = %Q{Provides a resource endpoint for RunDeck from a Puppet Server}
|
10
10
|
gem.files = Dir["{lib,test}/**/*"] + Dir["[A-Z]*"]
|
11
11
|
gem.require_path = "lib"
|
12
|
-
gem.email = "
|
12
|
+
gem.email = "LazyDelphiBuilder@gmail.com"
|
13
13
|
gem.homepage = "http://github.com/tdelphi/puppet-rundeck"
|
14
14
|
gem.authors = ["James Turnbull","Aleksey Timohin"]
|
15
15
|
gem.add_dependency "sinatra", "<= 1.3.6"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
data/lib/puppet-rundeck.rb
CHANGED
@@ -42,7 +42,7 @@ class PuppetRundeck < Sinatra::Base
|
|
42
42
|
return input.to_s.to_xs
|
43
43
|
end
|
44
44
|
|
45
|
-
def respond(required_tag=nil,uname=nil,use_tags=nil,add_facts=nil)
|
45
|
+
def respond(required_tag=nil,required_facts=nil,uname=nil,use_tags=nil,add_facts=nil)
|
46
46
|
response['Content-Type'] = 'text/xml'
|
47
47
|
response_xml = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE project PUBLIC "-//DTO Labs Inc.//DTD Resources Document 1.0//EN" "project.dtd">\n<project>\n)
|
48
48
|
|
@@ -61,6 +61,13 @@ class PuppetRundeck < Sinatra::Base
|
|
61
61
|
nodes = Puppet::Node.indirection.search("*")
|
62
62
|
end
|
63
63
|
|
64
|
+
if ! required_facts.nil?
|
65
|
+
# this should convert string 'fact1=fact1_value&fact2=fact2_value' to array [fact1, fact1_value, fact2, fact2_value]
|
66
|
+
local_required_facts = Hash[*required_facts.split(/[=&]/)].to_a
|
67
|
+
else
|
68
|
+
local_required_facts = nil
|
69
|
+
end
|
70
|
+
|
64
71
|
nodes.each do |n|
|
65
72
|
if should_use_tags
|
66
73
|
if Puppet::Node::Facts.respond_to? :find
|
@@ -77,6 +84,11 @@ class PuppetRundeck < Sinatra::Base
|
|
77
84
|
end
|
78
85
|
|
79
86
|
facts = n.parameters
|
87
|
+
|
88
|
+
if ! local_required_facts.nil?
|
89
|
+
next if ! (local_required_facts-facts.to_a).empty?
|
90
|
+
end
|
91
|
+
|
80
92
|
os_family = facts["kernel"] =~ /windows/i ? 'windows' : 'unix'
|
81
93
|
|
82
94
|
facts_string = nil
|
@@ -110,6 +122,12 @@ class PuppetRundeck < Sinatra::Base
|
|
110
122
|
tags_string = [tags_string,facts_string].join(',')
|
111
123
|
end
|
112
124
|
|
125
|
+
if PuppetRundeck.ssh_port.to_s == '22' then
|
126
|
+
hostname_port = ''
|
127
|
+
else
|
128
|
+
hostname_port = "\:#{PuppetRundeck.ssh_port.to_s}"
|
129
|
+
end
|
130
|
+
|
113
131
|
response_xml << <<-EOH
|
114
132
|
<node name="#{xml_escape(n.name)}"
|
115
133
|
type="Node"
|
@@ -120,7 +138,7 @@ class PuppetRundeck < Sinatra::Base
|
|
120
138
|
osVersion="#{xml_escape(facts["operatingsystemrelease"])}"
|
121
139
|
tags="#{xml_escape(tags_string)}"
|
122
140
|
username="#{xml_escape(targetusername)}"
|
123
|
-
hostname="#{xml_escape(facts["ipaddress"] +
|
141
|
+
hostname="#{xml_escape(facts["ipaddress"] + hostname_port)}"/>
|
124
142
|
EOH
|
125
143
|
end
|
126
144
|
response_xml << "</project>"
|
@@ -130,11 +148,15 @@ EOH
|
|
130
148
|
require 'pp'
|
131
149
|
|
132
150
|
get '/tag/:tag' do
|
133
|
-
respond(params[:tag], params["user"], params["use_tags"], params["add_facts"])
|
151
|
+
respond(params[:tag], nil, params["user"], params["use_tags"], params["add_facts"])
|
152
|
+
end
|
153
|
+
|
154
|
+
get '/facts/:fact' do
|
155
|
+
respond(nil, params[:fact], params["user"], params["use_tags"], params["add_facts"])
|
134
156
|
end
|
135
157
|
|
136
158
|
get '/' do
|
137
|
-
respond(nil, params["user"], params["use_tags"], params["add_facts"])
|
159
|
+
respond(nil, nil, params["user"], params["use_tags"], params["add_facts"])
|
138
160
|
end
|
139
161
|
|
140
162
|
end
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-rundeck-2013
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 12
|
10
|
+
version: 0.0.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
- James Turnbull,
|
13
|
+
- James Turnbull, Aleksey Timohin
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-10-
|
18
|
+
date: 2013-10-31 00:00:00 +00:00
|
19
19
|
default_executable: puppet-rundeck
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|