puppet 0.16.0 → 0.18.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +98 -0
- data/Rakefile +5 -1
- data/bin/puppet +1 -1
- data/bin/puppetca +25 -11
- data/bin/puppetd +189 -66
- data/bin/puppetdoc +79 -62
- data/bin/puppetmasterd +93 -49
- data/bin/puppetrun +385 -0
- data/conf/redhat/client.init +5 -2
- data/conf/redhat/fileserver.conf +1 -1
- data/conf/redhat/lsb-config.patch +51 -0
- data/conf/redhat/puppet.spec +45 -18
- data/conf/redhat/puppetd.conf +32 -4
- data/conf/redhat/server.init +5 -2
- data/conf/solaris/pkginfo +7 -0
- data/conf/solaris/smf/puppetd.xml +77 -0
- data/conf/solaris/smf/puppetmasterd.xml +77 -0
- data/conf/solaris/smf/svc-puppetd +66 -0
- data/conf/solaris/smf/svc-puppetmasterd +62 -0
- data/examples/code/failers/noobjectrvalue +1 -0
- data/examples/code/snippets/deepclassheirarchy.pp +23 -0
- data/examples/code/snippets/defineoverrides.pp +17 -0
- data/examples/code/snippets/emptyexec.pp +3 -0
- data/examples/code/snippets/selectorvalues.pp +6 -1
- data/examples/code/snippets/tagged.pp +35 -0
- data/ext/ldap/puppet.schema +2 -2
- data/install.rb +4 -2
- data/lib/puppet.rb +206 -15
- data/lib/puppet/client.rb +30 -20
- data/lib/puppet/client/ca.rb +2 -2
- data/lib/puppet/client/dipper.rb +5 -9
- data/lib/puppet/client/master.rb +224 -44
- data/lib/puppet/client/pelement.rb +54 -9
- data/lib/puppet/client/proxy.rb +3 -2
- data/lib/puppet/client/reporter.rb +34 -0
- data/lib/puppet/client/runner.rb +17 -0
- data/lib/puppet/config.rb +136 -55
- data/lib/puppet/daemon.rb +59 -37
- data/lib/puppet/element.rb +2 -1
- data/lib/puppet/event.rb +14 -3
- data/lib/puppet/filetype.rb +28 -19
- data/lib/puppet/log.rb +297 -132
- data/lib/puppet/metric.rb +31 -131
- data/lib/puppet/networkclient.rb +73 -46
- data/lib/puppet/parameter.rb +49 -1
- data/lib/puppet/parsedfile.rb +32 -12
- data/lib/puppet/parser/ast.rb +6 -1
- data/lib/puppet/parser/ast/astarray.rb +32 -6
- data/lib/puppet/parser/ast/collection.rb +91 -0
- data/lib/puppet/parser/ast/compdef.rb +2 -2
- data/lib/puppet/parser/ast/component.rb +24 -11
- data/lib/puppet/parser/ast/function.rb +50 -0
- data/lib/puppet/parser/ast/hostclass.rb +70 -22
- data/lib/puppet/parser/ast/node.rb +17 -8
- data/lib/puppet/parser/ast/nodedef.rb +1 -1
- data/lib/puppet/parser/ast/objectdef.rb +28 -10
- data/lib/puppet/parser/ast/selector.rb +4 -1
- data/lib/puppet/parser/functions.rb +145 -0
- data/lib/puppet/parser/interpreter.rb +243 -86
- data/lib/puppet/parser/lexer.rb +5 -4
- data/lib/puppet/parser/parser.rb +586 -505
- data/lib/puppet/parser/scope.rb +337 -187
- data/lib/puppet/rails.rb +115 -0
- data/lib/puppet/rails/database.rb +40 -0
- data/lib/puppet/rails/host.rb +83 -0
- data/lib/puppet/rails/rails_object.rb +42 -0
- data/lib/puppet/rails/rails_parameter.rb +5 -0
- data/lib/puppet/reports/rrdgraph.rb +20 -0
- data/lib/puppet/reports/tagmail.rb +94 -0
- data/lib/puppet/server.rb +20 -4
- data/lib/puppet/server/authconfig.rb +14 -3
- data/lib/puppet/server/authstore.rb +2 -2
- data/lib/puppet/server/ca.rb +23 -11
- data/lib/puppet/server/filebucket.rb +10 -10
- data/lib/puppet/server/fileserver.rb +4 -8
- data/lib/puppet/server/master.rb +19 -22
- data/lib/puppet/server/pelement.rb +28 -16
- data/lib/puppet/server/report.rb +184 -0
- data/lib/puppet/server/runner.rb +62 -0
- data/lib/puppet/server/servlet.rb +23 -9
- data/lib/puppet/sslcertificates/ca.rb +25 -1
- data/lib/puppet/statechange.rb +34 -53
- data/lib/puppet/storage.rb +1 -2
- data/lib/puppet/transaction.rb +305 -133
- data/lib/puppet/transaction/report.rb +42 -0
- data/lib/puppet/transportable.rb +57 -33
- data/lib/puppet/type.rb +260 -127
- data/lib/puppet/type/component.rb +9 -21
- data/lib/puppet/type/cron.rb +367 -116
- data/lib/puppet/type/exec.rb +15 -16
- data/lib/puppet/type/group.rb +9 -1
- data/lib/puppet/type/nameservice.rb +2 -5
- data/lib/puppet/type/nameservice/netinfo.rb +3 -0
- data/lib/puppet/type/nameservice/objectadd.rb +23 -10
- data/lib/puppet/type/nameservice/pw.rb +16 -3
- data/lib/puppet/type/package.rb +25 -75
- data/lib/puppet/type/package/apple.rb +15 -1
- data/lib/puppet/type/package/apt.rb +37 -2
- data/lib/puppet/type/package/blastwave.rb +136 -0
- data/lib/puppet/type/package/dpkg.rb +4 -4
- data/lib/puppet/type/package/gem.rb +119 -0
- data/lib/puppet/type/package/openbsd.rb +7 -6
- data/lib/puppet/type/package/ports.rb +7 -2
- data/lib/puppet/type/package/rpm.rb +1 -1
- data/lib/puppet/type/package/sun.rb +23 -9
- data/lib/puppet/type/package/sunfreeware.rb +7 -0
- data/lib/puppet/type/package/yum.rb +16 -9
- data/lib/puppet/type/parsedtype.rb +7 -5
- data/lib/puppet/type/parsedtype/mount.rb +55 -34
- data/lib/puppet/type/parsedtype/port.rb +7 -1
- data/lib/puppet/type/parsedtype/sshkey.rb +6 -16
- data/lib/puppet/type/pfile.rb +115 -23
- data/lib/puppet/type/pfile/checksum.rb +18 -5
- data/lib/puppet/type/pfile/content.rb +2 -2
- data/lib/puppet/type/pfile/ensure.rb +3 -3
- data/lib/puppet/type/pfile/group.rb +2 -2
- data/lib/puppet/type/pfile/source.rb +28 -17
- data/lib/puppet/type/pfile/target.rb +25 -17
- data/lib/puppet/type/pfilebucket.rb +25 -6
- data/lib/puppet/type/schedule.rb +6 -6
- data/lib/puppet/type/service.rb +24 -14
- data/lib/puppet/type/service/debian.rb +1 -1
- data/lib/puppet/type/service/redhat.rb +13 -10
- data/lib/puppet/type/service/smf.rb +3 -3
- data/lib/puppet/type/state.rb +1 -2
- data/lib/puppet/type/symlink.rb +3 -4
- data/lib/puppet/type/user.rb +22 -10
- data/lib/puppet/type/yumrepo.rb +6 -1
- data/lib/puppet/type/zone.rb +595 -0
- data/lib/puppet/util.rb +58 -12
- data/test/client/client.rb +2 -2
- data/test/client/master.rb +92 -3
- data/test/client/pelement.rb +99 -0
- data/test/executables/puppetbin.rb +3 -4
- data/test/executables/puppetca.rb +3 -3
- data/test/executables/puppetd.rb +3 -3
- data/test/executables/puppetmasterd.rb +1 -5
- data/test/executables/puppetmodule.rb +2 -2
- data/test/language/ast.rb +200 -11
- data/test/language/functions.rb +245 -0
- data/test/language/interpreter.rb +155 -6
- data/test/language/lexer.rb +35 -2
- data/test/language/node.rb +48 -1
- data/test/language/parser.rb +250 -1
- data/test/language/rails.rb +105 -0
- data/test/language/scope.rb +304 -10
- data/test/language/snippets.rb +54 -5
- data/test/language/transportable.rb +60 -28
- data/test/other/config.rb +214 -1
- data/test/other/events.rb +67 -9
- data/test/other/log.rb +31 -5
- data/test/other/metrics.rb +23 -21
- data/test/other/parsedfile.rb +29 -2
- data/test/other/puppet.rb +79 -0
- data/test/other/report.rb +106 -0
- data/test/other/storage.rb +2 -2
- data/test/other/transactions.rb +128 -2
- data/test/puppet/utiltest.rb +10 -5
- data/test/puppettest.rb +193 -21
- data/test/server/authstore.rb +13 -4
- data/test/server/bucket.rb +33 -8
- data/test/server/ca.rb +44 -6
- data/test/server/master.rb +6 -7
- data/test/server/pelement.rb +15 -5
- data/test/server/report.rb +93 -0
- data/test/server/runner.rb +107 -0
- data/test/server/server.rb +28 -1
- data/test/types/cron.rb +339 -31
- data/test/types/file.rb +256 -24
- data/test/types/filebucket.rb +6 -2
- data/test/types/filesources.rb +41 -92
- data/test/types/group.rb +31 -1
- data/test/types/host.rb +2 -1
- data/test/types/mount.rb +18 -1
- data/test/types/package.rb +200 -18
- data/test/types/service.rb +5 -1
- data/test/types/sshkey.rb +2 -1
- data/test/types/symlink.rb +3 -2
- data/test/types/type.rb +180 -1
- data/test/types/user.rb +65 -27
- data/test/types/yumrepo.rb +15 -0
- data/test/types/zone.rb +437 -0
- metadata +43 -4
- data/bin/cf2puppet +0 -186
- data/conf/redhat/puppetmasterd.conf +0 -5
data/lib/puppet/rails.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
# Load the appropriate libraries, or set a class indicating they aren't available
|
2
|
+
|
3
|
+
require 'facter'
|
4
|
+
require 'puppet'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'active_record'
|
8
|
+
rescue LoadError => detail
|
9
|
+
if Facter["operatingsystem"].value == "Debian" and
|
10
|
+
FileTest.exists?("/usr/share/rails")
|
11
|
+
count = 0
|
12
|
+
Dir.entries("/usr/share/rails").each do |dir|
|
13
|
+
libdir = File.join("/usr/share/rails", dir, "lib")
|
14
|
+
if FileTest.exists?(libdir) and ! $:.include?(libdir)
|
15
|
+
count += 1
|
16
|
+
$: << libdir
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
if count > 0
|
21
|
+
retry
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# If we couldn't find it the normal way, try using a Gem.
|
27
|
+
unless defined? ActiveRecord
|
28
|
+
begin
|
29
|
+
require 'rubygems'
|
30
|
+
require_gem 'rails'
|
31
|
+
rescue LoadError
|
32
|
+
# Nothing
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module Puppet::Rails
|
37
|
+
Puppet.config.setdefaults(:puppetmaster,
|
38
|
+
:dblocation => { :default => "$statedir/clientconfigs.sqlite3",
|
39
|
+
:mode => 0600,
|
40
|
+
:owner => "$user",
|
41
|
+
:group => "$group",
|
42
|
+
:desc => "The database cache for client configurations. Used for
|
43
|
+
querying within the language."
|
44
|
+
},
|
45
|
+
:dbadapter => [ "sqlite3", "The type of database to use." ],
|
46
|
+
:dbname => [ "puppet", "The name of the database to use." ],
|
47
|
+
:dbserver => [ "puppet", "The database server for Client caching. Only
|
48
|
+
used when networked databases are used."],
|
49
|
+
:dbuser => [ "puppet", "The database user for Client caching. Only
|
50
|
+
used when networked databases are used."],
|
51
|
+
:dbpassword => [ "puppet", "The database password for Client caching. Only
|
52
|
+
used when networked databases are used."],
|
53
|
+
:railslog => {:default => "$logdir/puppetrails.log",
|
54
|
+
:mode => 0600,
|
55
|
+
:owner => "$user",
|
56
|
+
:group => "$group",
|
57
|
+
:desc => "Where Rails-specific logs are sent"
|
58
|
+
}
|
59
|
+
)
|
60
|
+
|
61
|
+
def self.clear
|
62
|
+
@inited = false
|
63
|
+
end
|
64
|
+
|
65
|
+
# Set up our database connection. It'd be nice to have a "use" system
|
66
|
+
# that could make callbacks.
|
67
|
+
def self.init
|
68
|
+
unless defined? ActiveRecord::Base
|
69
|
+
raise Puppet::DevError, "No activerecord, cannot init Puppet::Rails"
|
70
|
+
end
|
71
|
+
|
72
|
+
# This global init does not work for testing, because we remove
|
73
|
+
# the state dir on every test.
|
74
|
+
#unless (defined? @inited and @inited) or defined? Test::Unit::TestCase
|
75
|
+
unless (defined? @inited and @inited)
|
76
|
+
Puppet.config.use(:puppet)
|
77
|
+
|
78
|
+
ActiveRecord::Base.logger = Logger.new(Puppet[:railslog])
|
79
|
+
args = {:adapter => Puppet[:dbadapter]}
|
80
|
+
|
81
|
+
case Puppet[:dbadapter]
|
82
|
+
when "sqlite3":
|
83
|
+
args[:database] = Puppet[:dblocation]
|
84
|
+
when "mysql":
|
85
|
+
args[:host] = Puppet[:dbserver]
|
86
|
+
args[:username] = Puppet[:dbuser]
|
87
|
+
args[:password] = Puppet[:dbpassword]
|
88
|
+
args[:database] = Puppet[:dbname]
|
89
|
+
end
|
90
|
+
|
91
|
+
ActiveRecord::Base.establish_connection(args)
|
92
|
+
|
93
|
+
@inited = true
|
94
|
+
end
|
95
|
+
|
96
|
+
if Puppet[:dbadapter] == "sqlite3" and ! FileTest.exists?(Puppet[:dblocation])
|
97
|
+
require 'puppet/rails/database'
|
98
|
+
begin
|
99
|
+
Puppet::Rails::Database.up
|
100
|
+
rescue => detail
|
101
|
+
if Puppet[:debug]
|
102
|
+
puts detail.backtrace
|
103
|
+
end
|
104
|
+
raise Puppet::Error, "Could not initialize database: %s" % detail
|
105
|
+
end
|
106
|
+
end
|
107
|
+
Puppet.config.use(:puppetmaster)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
if defined? ActiveRecord::Base
|
112
|
+
require 'puppet/rails/host'
|
113
|
+
end
|
114
|
+
|
115
|
+
# $Id: rails.rb 1205 2006-05-17 23:42:22Z luke $
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Puppet::Rails::Database < ActiveRecord::Migration
|
2
|
+
require 'sqlite3'
|
3
|
+
|
4
|
+
def self.up
|
5
|
+
if ActiveRecord::Migration.respond_to?(:verbose)
|
6
|
+
ActiveRecord::Migration.verbose = false
|
7
|
+
end
|
8
|
+
|
9
|
+
create_table :rails_objects do |table|
|
10
|
+
table.column :name, :string, :null => false
|
11
|
+
table.column :ptype, :string, :null => false
|
12
|
+
table.column :tags, :string
|
13
|
+
table.column :file, :string
|
14
|
+
table.column :line, :integer
|
15
|
+
table.column :host_id, :integer
|
16
|
+
table.column :collectable, :boolean
|
17
|
+
end
|
18
|
+
|
19
|
+
create_table :rails_parameters do |table|
|
20
|
+
table.column :name, :string, :null => false
|
21
|
+
table.column :value, :string, :null => false
|
22
|
+
table.column :rails_object_id, :integer
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table :hosts do |table|
|
26
|
+
table.column :name, :string, :null => false
|
27
|
+
table.column :ip, :string
|
28
|
+
table.column :facts, :string
|
29
|
+
table.column :connect, :date
|
30
|
+
table.column :success, :date
|
31
|
+
table.column :classes, :string
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.down
|
36
|
+
drop_table :rails_objects
|
37
|
+
drop_table :rails_parameters
|
38
|
+
drop_table :hosts
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'puppet/rails/rails_object'
|
2
|
+
|
3
|
+
#RailsObject = Puppet::Rails::RailsObject
|
4
|
+
class Puppet::Rails::Host < ActiveRecord::Base
|
5
|
+
serialize :facts, Hash
|
6
|
+
serialize :classes, Array
|
7
|
+
|
8
|
+
has_many :rails_objects, :dependent => :delete_all
|
9
|
+
|
10
|
+
# If the host already exists, get rid of its objects
|
11
|
+
def self.clean(host)
|
12
|
+
if obj = self.find_by_name(host)
|
13
|
+
obj.rails_objects.clear
|
14
|
+
return obj
|
15
|
+
else
|
16
|
+
return nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Store our host in the database.
|
21
|
+
def self.store(hash)
|
22
|
+
name = hash[:host] || "localhost"
|
23
|
+
ip = hash[:ip] || "127.0.0.1"
|
24
|
+
facts = hash[:facts] || {}
|
25
|
+
objects = hash[:objects]
|
26
|
+
|
27
|
+
unless objects
|
28
|
+
raise ArgumentError, "You must pass objects"
|
29
|
+
end
|
30
|
+
|
31
|
+
hostargs = {
|
32
|
+
:name => name,
|
33
|
+
:ip => ip,
|
34
|
+
:facts => facts,
|
35
|
+
:classes => objects.classes
|
36
|
+
}
|
37
|
+
|
38
|
+
objects = objects.flatten
|
39
|
+
|
40
|
+
host = nil
|
41
|
+
if host = clean(name)
|
42
|
+
[:name, :facts, :classes].each do |param|
|
43
|
+
unless host[param] == hostargs[param]
|
44
|
+
host[param] = hostargs[param]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
host.addobjects(objects)
|
48
|
+
else
|
49
|
+
host = self.new(hostargs) do |hostobj|
|
50
|
+
hostobj.addobjects(objects)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
host.save
|
56
|
+
|
57
|
+
return host
|
58
|
+
end
|
59
|
+
|
60
|
+
# Add all of our RailsObjects
|
61
|
+
def addobjects(objects)
|
62
|
+
objects.each do |tobj|
|
63
|
+
params = {}
|
64
|
+
tobj.each do |p,v| params[p] = v end
|
65
|
+
|
66
|
+
args = {:ptype => tobj.type, :name => tobj.name}
|
67
|
+
[:tags, :file, :line].each do |param|
|
68
|
+
if val = tobj.send(param)
|
69
|
+
args[param] = val
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
robj = rails_objects.build(args)
|
74
|
+
|
75
|
+
robj.addparams(params)
|
76
|
+
if tobj.collectable
|
77
|
+
robj.toggle(:collectable)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# $Id: host.rb 1198 2006-05-15 20:19:03Z luke $
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'puppet'
|
2
|
+
require 'puppet/rails/rails_parameter'
|
3
|
+
|
4
|
+
#RailsParameter = Puppet::Rails::RailsParameter
|
5
|
+
class Puppet::Rails::RailsObject < ActiveRecord::Base
|
6
|
+
has_many :rails_parameters, :dependent => :delete_all
|
7
|
+
serialize :tags, Array
|
8
|
+
|
9
|
+
belongs_to :host
|
10
|
+
|
11
|
+
# Add a set of parameters.
|
12
|
+
def addparams(params)
|
13
|
+
params.each do |pname, pvalue|
|
14
|
+
rails_parameters.build(
|
15
|
+
:name => pname,
|
16
|
+
:value => pvalue
|
17
|
+
)
|
18
|
+
|
19
|
+
#self.rails_parameters << pobj
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Convert our object to a trans_object. Do not retain whether the object
|
24
|
+
# is collectable, though, since that would cause it to get stripped
|
25
|
+
# from the configuration.
|
26
|
+
def to_trans
|
27
|
+
obj = Puppet::TransObject.new(name(), ptype())
|
28
|
+
|
29
|
+
[:file, :line, :tags].each do |method|
|
30
|
+
if val = send(method)
|
31
|
+
obj.send(method.to_s + "=", val)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
rails_parameters.each do |param|
|
35
|
+
obj[param.name] = param.value
|
36
|
+
end
|
37
|
+
|
38
|
+
return obj
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# $Id: rails_object.rb 1192 2006-05-14 02:42:21Z luke $
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'puppet'
|
2
|
+
|
3
|
+
Puppet::Server::Report.newreport(:rrdgraph) do |report|
|
4
|
+
time = Time.now.to_i
|
5
|
+
|
6
|
+
File.open(File.join(Puppet[:rrddir],"index.html"),"w") { |of|
|
7
|
+
of.puts "<html><body>"
|
8
|
+
report.metrics.each do |name, metric|
|
9
|
+
metric.store(time)
|
10
|
+
|
11
|
+
metric.graph
|
12
|
+
|
13
|
+
of.puts "<img src=%s.png><br>" % name
|
14
|
+
end
|
15
|
+
|
16
|
+
of.puts "</body></html>"
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
# $Id: rrdgraph.rb 1350 2006-06-30 22:30:27Z luke $
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'puppet'
|
2
|
+
|
3
|
+
Puppet.config.setdefaults(:reporting,
|
4
|
+
:tagmap => ["$confdir/tagmail.conf",
|
5
|
+
"The mapping between reporting tags and email addresses."],
|
6
|
+
:sendmail => [%x{which sendmail 2>/dev/null}.chomp,
|
7
|
+
"Where to find the sendmail binary with which to send email."],
|
8
|
+
:reportfrom => ["report@" + [Facter["hostname"].value, Facter["domain"].value].join("."),
|
9
|
+
"The 'from' email address for the reports."],
|
10
|
+
:smtpserver => ["none",
|
11
|
+
"The server through which to send email reports."]
|
12
|
+
)
|
13
|
+
|
14
|
+
require 'net/smtp'
|
15
|
+
|
16
|
+
Puppet::Server::Report.newreport(:tagmail) do |report|
|
17
|
+
unless FileTest.exists?(Puppet[:tagmap])
|
18
|
+
Puppet.notice "Cannot send tagmail report; no tagmap file %s" %
|
19
|
+
Puppet[:tagmap]
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
# Load the config file
|
24
|
+
tags = {}
|
25
|
+
File.readlines(Puppet[:tagmap]).each do |line|
|
26
|
+
taglist, emails = line.chomp.split(/\s*:\s*/)
|
27
|
+
|
28
|
+
emails = emails.split(/\s*,\s*/)
|
29
|
+
taglist.split(/\s*,\s*/).each do |tag|
|
30
|
+
tags[tag] = emails
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Now find any appropriately tagged messages.
|
35
|
+
reports = {}
|
36
|
+
tags.each do |tag, emails|
|
37
|
+
messages = nil
|
38
|
+
if tag == "all"
|
39
|
+
messages = report.logs
|
40
|
+
else
|
41
|
+
messages = report.logs.find_all do |log|
|
42
|
+
log.tagged?(tag)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if messages and ! messages.empty?
|
47
|
+
reports[emails] = messages.collect { |m| m.to_report }.join("\n")
|
48
|
+
else
|
49
|
+
Puppet.info "No messages to report"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Let's fork for the sending of the email, since you never know what might
|
54
|
+
# happen.
|
55
|
+
fork do
|
56
|
+
if Puppet[:smtpserver] != "none"
|
57
|
+
begin
|
58
|
+
Net::SMTP.start(Puppet[:smtpserver]) do |smtp|
|
59
|
+
reports.each do |emails, messages|
|
60
|
+
Puppet.info "Sending report to %s" % emails.join(", ")
|
61
|
+
smtp.send_message(messages, Puppet[:reportfrom], *emails)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
rescue => detail
|
65
|
+
if Puppet[:debug]
|
66
|
+
puts detail.backtrace
|
67
|
+
end
|
68
|
+
raise Puppet::Error,
|
69
|
+
"Could not send report emails through smtp: %s" % detail
|
70
|
+
end
|
71
|
+
elsif Puppet[:sendmail] != ""
|
72
|
+
begin
|
73
|
+
reports.each do |emails, messages|
|
74
|
+
Puppet.info "Sending report to %s" % emails.join(", ")
|
75
|
+
# We need to open a separate process for every set of email addresses
|
76
|
+
IO.popen(Puppet[:sendmail] + " " + emails.join(" "), "w") do |p|
|
77
|
+
p.puts "From: #{Puppet[:reportfrom]}"
|
78
|
+
p.puts "Subject: Puppet Report for %s" % report.host
|
79
|
+
|
80
|
+
p.puts messages
|
81
|
+
end
|
82
|
+
end
|
83
|
+
rescue => detail
|
84
|
+
if Puppet[:debug]
|
85
|
+
puts detail.backtrace
|
86
|
+
end
|
87
|
+
raise Puppet::Error,
|
88
|
+
"Could not send report emails via sendmail: %s" % detail
|
89
|
+
end
|
90
|
+
else
|
91
|
+
raise Puppet::Error, "SMTP server is unset and could not find sendmail"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/puppet/server.rb
CHANGED
@@ -27,6 +27,14 @@ module Puppet
|
|
27
27
|
class Server < WEBrick::HTTPServer
|
28
28
|
include Puppet::Daemon
|
29
29
|
|
30
|
+
Puppet.config.setdefaults(:puppetd,
|
31
|
+
:listen => [false, "Whether puppetd should listen for
|
32
|
+
connections. If this is true, then by default only the
|
33
|
+
``runner`` server is started, which allows remote authorized
|
34
|
+
and authenticated nodes to connect and trigger ``puppetd``
|
35
|
+
runs."]
|
36
|
+
)
|
37
|
+
|
30
38
|
# Create our config object if necessary. This works even if
|
31
39
|
# there's no configuration file.
|
32
40
|
def authconfig
|
@@ -75,6 +83,12 @@ module Puppet
|
|
75
83
|
@driver = ca
|
76
84
|
@secureinit = true
|
77
85
|
self.fqdn
|
86
|
+
else
|
87
|
+
if hash.include?(:NoSecureInit)
|
88
|
+
@secureinit = false
|
89
|
+
else
|
90
|
+
@secureinit = true
|
91
|
+
end
|
78
92
|
end
|
79
93
|
|
80
94
|
unless self.readcert
|
@@ -104,9 +118,7 @@ module Puppet
|
|
104
118
|
# mount has to be called after the server is initialized
|
105
119
|
self.mount("/RPC2", Puppet::Server::Servlet, @handlers)
|
106
120
|
end
|
107
|
-
end
|
108
121
|
|
109
|
-
class Server
|
110
122
|
# the base class for the different handlers
|
111
123
|
class Handler
|
112
124
|
attr_accessor :server
|
@@ -117,8 +129,9 @@ module Puppet
|
|
117
129
|
end
|
118
130
|
|
119
131
|
def self.handler(name)
|
132
|
+
name = name.to_s.downcase
|
120
133
|
@subclasses.find { |h|
|
121
|
-
h.name == name
|
134
|
+
h.name.to_s.downcase == name
|
122
135
|
}
|
123
136
|
end
|
124
137
|
|
@@ -174,7 +187,10 @@ require 'puppet/server/master'
|
|
174
187
|
require 'puppet/server/ca'
|
175
188
|
require 'puppet/server/fileserver'
|
176
189
|
require 'puppet/server/filebucket'
|
190
|
+
require 'puppet/server/pelement'
|
191
|
+
require 'puppet/server/runner'
|
177
192
|
require 'puppet/server/logger'
|
193
|
+
require 'puppet/server/report'
|
178
194
|
require 'puppet/client'
|
179
195
|
|
180
|
-
# $Id: server.rb
|
196
|
+
# $Id: server.rb 1339 2006-06-29 20:32:17Z luke $
|