puppet 0.9.2 → 0.13.0
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 +58 -0
- data/README +21 -18
- data/Rakefile +176 -36
- data/bin/puppet +34 -48
- data/bin/puppetca +41 -28
- data/bin/puppetd +87 -65
- data/bin/puppetdoc +99 -23
- data/bin/puppetmasterd +72 -91
- data/conf/redhat/client.init +80 -0
- data/conf/redhat/client.sysconfig +11 -0
- data/conf/redhat/fileserver.conf +12 -0
- data/conf/redhat/puppet.spec +130 -0
- data/conf/redhat/server.init +89 -0
- data/conf/redhat/server.sysconfig +9 -0
- data/examples/code/allatonce +2 -2
- data/examples/code/assignments +1 -1
- data/examples/code/classing +2 -2
- data/examples/code/components +2 -2
- data/examples/code/file.bl +5 -5
- data/examples/code/filedefaults +2 -2
- data/examples/code/fileparsing +1 -1
- data/examples/code/filerecursion +1 -1
- data/examples/code/functions +1 -1
- data/examples/code/groups +1 -1
- data/examples/code/importing +1 -1
- data/examples/code/nodes +1 -1
- data/examples/code/one +1 -1
- data/examples/code/relationships +2 -2
- data/examples/code/simpletests +5 -5
- data/examples/code/snippets/argumentdefaults +2 -2
- data/examples/code/snippets/casestatement +16 -8
- data/examples/code/snippets/classheirarchy.pp +4 -4
- data/examples/code/snippets/classincludes.pp +4 -4
- data/examples/code/snippets/classpathtest +2 -2
- data/examples/code/snippets/componentmetaparams.pp +11 -0
- data/examples/code/snippets/dirchmod +5 -5
- data/examples/code/snippets/emptyclass.pp +9 -0
- data/examples/code/snippets/failmissingexecpath.pp +1 -1
- data/examples/code/snippets/falsevalues.pp +1 -1
- data/examples/code/snippets/filecreate +5 -5
- data/examples/code/snippets/implicititeration +5 -5
- data/examples/code/snippets/multipleinstances +4 -4
- data/examples/code/snippets/namevartest +3 -3
- data/examples/code/snippets/scopetest +1 -1
- data/examples/code/snippets/selectorvalues.pp +3 -3
- data/examples/code/snippets/simpledefaults +2 -2
- data/examples/code/snippets/simpleselector +5 -5
- data/examples/code/snippets/singleary.pp +19 -0
- data/examples/root/etc/init.d/sleeper +3 -2
- data/ext/emacs/puppet-mode-init.el +6 -0
- data/ext/emacs/puppet-mode.el +189 -0
- data/ext/ldap/puppet.schema +17 -0
- data/ext/{module:puppet → module_puppet} +30 -31
- data/ext/vim/filetype.vim +9 -0
- data/ext/vim/puppet.vim +87 -0
- data/install.rb +63 -30
- data/lib/puppet.rb +216 -122
- data/lib/puppet/client.rb +51 -416
- data/lib/puppet/client/ca.rb +17 -0
- data/lib/puppet/client/dipper.rb +78 -0
- data/lib/puppet/client/file.rb +20 -0
- data/lib/puppet/client/log.rb +17 -0
- data/lib/puppet/client/master.rb +246 -0
- data/lib/puppet/client/proxy.rb +27 -0
- data/lib/puppet/client/status.rb +7 -0
- data/lib/puppet/config.rb +563 -13
- data/lib/puppet/daemon.rb +50 -22
- data/lib/puppet/element.rb +4 -4
- data/lib/puppet/event-loop.rb +1 -0
- data/lib/puppet/event-loop/better-definers.rb +367 -0
- data/lib/puppet/event-loop/event-loop.rb +355 -0
- data/lib/puppet/event-loop/signal-system.rb +220 -0
- data/lib/puppet/event.rb +9 -11
- data/lib/puppet/filetype.rb +195 -0
- data/lib/puppet/log.rb +35 -12
- data/lib/puppet/metric.rb +2 -2
- data/lib/puppet/networkclient.rb +145 -0
- data/lib/puppet/parameter.rb +335 -0
- data/lib/puppet/parser/ast.rb +42 -1453
- data/lib/puppet/parser/ast/astarray.rb +88 -0
- data/lib/puppet/parser/ast/branch.rb +47 -0
- data/lib/puppet/parser/ast/caseopt.rb +66 -0
- data/lib/puppet/parser/ast/casestatement.rb +78 -0
- data/lib/puppet/parser/ast/classdef.rb +78 -0
- data/lib/puppet/parser/ast/compdef.rb +111 -0
- data/lib/puppet/parser/ast/component.rb +105 -0
- data/lib/puppet/parser/ast/hostclass.rb +82 -0
- data/lib/puppet/parser/ast/leaf.rb +86 -0
- data/lib/puppet/parser/ast/node.rb +103 -0
- data/lib/puppet/parser/ast/nodedef.rb +68 -0
- data/lib/puppet/parser/ast/objectdef.rb +336 -0
- data/lib/puppet/parser/ast/objectparam.rb +30 -0
- data/lib/puppet/parser/ast/objectref.rb +76 -0
- data/lib/puppet/parser/ast/selector.rb +60 -0
- data/lib/puppet/parser/ast/typedefaults.rb +45 -0
- data/lib/puppet/parser/ast/vardef.rb +44 -0
- data/lib/puppet/parser/interpreter.rb +31 -14
- data/lib/puppet/parser/lexer.rb +2 -4
- data/lib/puppet/parser/parser.rb +332 -242
- data/lib/puppet/parser/scope.rb +55 -38
- data/lib/puppet/server.rb +43 -44
- data/lib/puppet/server/authstore.rb +3 -6
- data/lib/puppet/server/ca.rb +5 -2
- data/lib/puppet/server/filebucket.rb +2 -4
- data/lib/puppet/server/fileserver.rb +28 -12
- data/lib/puppet/server/logger.rb +15 -4
- data/lib/puppet/server/master.rb +62 -7
- data/lib/puppet/sslcertificates.rb +41 -607
- data/lib/puppet/sslcertificates/ca.rb +291 -0
- data/lib/puppet/sslcertificates/certificate.rb +283 -0
- data/lib/puppet/statechange.rb +6 -1
- data/lib/puppet/storage.rb +67 -56
- data/lib/puppet/transaction.rb +25 -9
- data/lib/puppet/transportable.rb +102 -22
- data/lib/puppet/type.rb +1096 -315
- data/lib/puppet/type/component.rb +30 -21
- data/lib/puppet/type/cron.rb +409 -448
- data/lib/puppet/type/exec.rb +234 -174
- data/lib/puppet/type/group.rb +65 -82
- data/lib/puppet/type/nameservice.rb +247 -3
- data/lib/puppet/type/nameservice/netinfo.rb +29 -40
- data/lib/puppet/type/nameservice/objectadd.rb +52 -66
- data/lib/puppet/type/nameservice/posix.rb +6 -194
- data/lib/puppet/type/package.rb +447 -295
- data/lib/puppet/type/package/apt.rb +51 -50
- data/lib/puppet/type/package/bsd.rb +82 -0
- data/lib/puppet/type/package/dpkg.rb +85 -88
- data/lib/puppet/type/package/rpm.rb +67 -63
- data/lib/puppet/type/package/sun.rb +119 -98
- data/lib/puppet/type/package/yum.rb +41 -37
- data/lib/puppet/type/parsedtype.rb +295 -0
- data/lib/puppet/type/parsedtype/host.rb +143 -0
- data/lib/puppet/type/parsedtype/port.rb +232 -0
- data/lib/puppet/type/parsedtype/sshkey.rb +129 -0
- data/lib/puppet/type/pfile.rb +484 -460
- data/lib/puppet/type/pfile/checksum.rb +237 -181
- data/lib/puppet/type/pfile/content.rb +67 -0
- data/lib/puppet/type/pfile/ensure.rb +212 -0
- data/lib/puppet/type/pfile/group.rb +106 -105
- data/lib/puppet/type/pfile/mode.rb +98 -101
- data/lib/puppet/type/pfile/source.rb +228 -209
- data/lib/puppet/type/pfile/type.rb +18 -21
- data/lib/puppet/type/pfile/uid.rb +127 -130
- data/lib/puppet/type/pfilebucket.rb +68 -63
- data/lib/puppet/type/schedule.rb +341 -0
- data/lib/puppet/type/service.rb +351 -255
- data/lib/puppet/type/service/base.rb +9 -14
- data/lib/puppet/type/service/debian.rb +32 -38
- data/lib/puppet/type/service/init.rb +130 -130
- data/lib/puppet/type/service/smf.rb +48 -20
- data/lib/puppet/type/state.rb +229 -16
- data/lib/puppet/type/symlink.rb +51 -63
- data/lib/puppet/type/tidy.rb +105 -102
- data/lib/puppet/type/user.rb +118 -180
- data/lib/puppet/util.rb +100 -6
- data/test/certmgr/certmgr.rb +0 -1
- data/test/client/client.rb +4 -4
- data/test/executables/puppetbin.rb +7 -14
- data/test/executables/puppetca.rb +18 -24
- data/test/executables/puppetd.rb +7 -16
- data/test/executables/puppetmasterd.rb +7 -9
- data/test/executables/puppetmodule.rb +11 -16
- data/test/language/ast.rb +11 -7
- data/test/language/interpreter.rb +1 -1
- data/test/language/scope.rb +2 -0
- data/test/language/snippets.rb +30 -5
- data/test/language/transportable.rb +77 -0
- data/test/other/config.rb +316 -0
- data/test/other/events.rb +22 -21
- data/test/other/log.rb +14 -14
- data/test/other/metrics.rb +4 -8
- data/test/other/overrides.rb +5 -5
- data/test/other/relationships.rb +4 -2
- data/test/other/storage.rb +64 -3
- data/test/other/transactions.rb +20 -20
- data/test/parser/parser.rb +7 -4
- data/test/puppet/conffiles.rb +12 -12
- data/test/puppet/defaults.rb +13 -11
- data/test/puppet/utiltest.rb +14 -11
- data/test/puppettest.rb +156 -48
- data/test/server/bucket.rb +2 -2
- data/test/server/fileserver.rb +6 -6
- data/test/server/logger.rb +19 -11
- data/test/server/master.rb +33 -4
- data/test/server/server.rb +2 -7
- data/test/types/basic.rb +5 -7
- data/test/types/component.rb +22 -18
- data/test/types/cron.rb +111 -44
- data/test/types/exec.rb +116 -59
- data/test/types/file.rb +262 -137
- data/test/types/filebucket.rb +13 -15
- data/test/types/fileignoresource.rb +12 -16
- data/test/types/filesources.rb +73 -48
- data/test/types/filetype.rb +13 -15
- data/test/types/group.rb +15 -13
- data/test/types/host.rb +146 -0
- data/test/types/package.rb +74 -63
- data/test/types/port.rb +139 -0
- data/test/types/query.rb +8 -8
- data/test/types/schedule.rb +335 -0
- data/test/types/service.rb +137 -21
- data/test/types/sshkey.rb +140 -0
- data/test/types/symlink.rb +3 -5
- data/test/types/tidy.rb +5 -14
- data/test/types/type.rb +67 -11
- data/test/types/user.rb +25 -23
- metadata +186 -122
- data/lib/puppet/type/pfile/create.rb +0 -108
- data/lib/puppet/type/pprocess.rb +0 -97
- data/lib/puppet/type/typegen.rb +0 -149
- data/lib/puppet/type/typegen/filerecord.rb +0 -243
- data/lib/puppet/type/typegen/filetype.rb +0 -316
- data/test/other/state.rb +0 -106
data/ext/vim/puppet.vim
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
" puppet syntax file
|
2
|
+
" Filename: puppet.vim
|
3
|
+
" Language: puppet configuration file
|
4
|
+
" Maintainer: Luke Kanies <luke@madstop.com>
|
5
|
+
" URL: http://reductivelabs.com/svn/puppet/trunk/ext/vim/puppet.vim
|
6
|
+
" Last Change:
|
7
|
+
" Version:
|
8
|
+
"
|
9
|
+
" $Id: puppet.vim 875 2006-02-07 23:56:16Z luke $
|
10
|
+
|
11
|
+
" Copied from the cfengine, ruby, and perl syntax files
|
12
|
+
" For version 5.x: Clear all syntax items
|
13
|
+
" For version 6.x: Quit when a syntax file was already loaded
|
14
|
+
if version < 600
|
15
|
+
syntax clear
|
16
|
+
elseif exists("b:current_syntax")
|
17
|
+
finish
|
18
|
+
endif
|
19
|
+
|
20
|
+
syn region puppetDefine start="^\s*\(class\|define\|site\|node\)" end="{" contains=puppetDefType,puppetDefName,puppetDefArguments
|
21
|
+
syn keyword puppetDefType class define site node inherits contained
|
22
|
+
syn keyword puppetInherits inherits contained
|
23
|
+
syn region puppetDefArguments start="(" end=")" contains=puppetArgument
|
24
|
+
syn match puppetArgument "\w\+" contained
|
25
|
+
syn match puppetDefName "\w\+" contained
|
26
|
+
|
27
|
+
syn match puppetInstance "\w\+\s*{" contains=puppetTypeBrace,puppetTypeName,puppetTypeDefault
|
28
|
+
syn match puppetTypeBrace "{" contained
|
29
|
+
syn match puppetTypeName "[a-z]\w*" contained
|
30
|
+
syn match puppetTypeDefault "[A-Z]\w*" contained
|
31
|
+
|
32
|
+
syn match puppetParam "\w\+\s*=>" contains=puppetTypeRArrow,puppetParamName
|
33
|
+
syn match puppetParamRArrow "=>" contained
|
34
|
+
syn match puppetParamName "\w\+" contained
|
35
|
+
syn match puppetVariable "$\w\+"
|
36
|
+
syn match puppetVariable "${\w\+}"
|
37
|
+
syn match puppetParen "("
|
38
|
+
syn match puppetParen ")"
|
39
|
+
syn match puppetBrace "{"
|
40
|
+
syn match puppetBrace "}"
|
41
|
+
|
42
|
+
syn region puppetString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=puppetVariable
|
43
|
+
|
44
|
+
syn keyword puppetBoolean true false
|
45
|
+
syn keyword puppetKeyword import inherits include
|
46
|
+
syn keyword puppetControl case default
|
47
|
+
|
48
|
+
" comments last overriding everything else
|
49
|
+
syn match puppetComment "\s*#.*$" contains=puppetTodo
|
50
|
+
syn keyword puppetTodo TODO NOTE FIXME XXX contained
|
51
|
+
|
52
|
+
" Define the default highlighting.
|
53
|
+
" For version 5.7 and earlier: only when not done already
|
54
|
+
" For version 5.8 and later: only when an item doesn't have highlighting yet
|
55
|
+
if version >= 508 || !exists("did_puppet_syn_inits")
|
56
|
+
if version < 508
|
57
|
+
let did_puppet_syn_inits = 1
|
58
|
+
command -nargs=+ HiLink hi link <args>
|
59
|
+
else
|
60
|
+
command -nargs=+ HiLink hi def link <args>
|
61
|
+
endif
|
62
|
+
|
63
|
+
HiLink puppetVariable Identifier
|
64
|
+
HiLink puppetBoolean Boolean
|
65
|
+
HiLink puppetType Identifier
|
66
|
+
HiLink puppetDefault Identifier
|
67
|
+
HiLink puppetKeyword Define
|
68
|
+
HiLink puppetTypeDefs Define
|
69
|
+
HiLink puppetComment Comment
|
70
|
+
HiLink puppetString String
|
71
|
+
HiLink puppetTodo Todo
|
72
|
+
" HiLink puppetBrace Delimiter
|
73
|
+
" HiLink puppetTypeBrace Delimiter
|
74
|
+
" HiLink puppetParen Delimiter
|
75
|
+
HiLink puppetDelimiter Delimiter
|
76
|
+
HiLink puppetControl Statement
|
77
|
+
HiLink puppetDefType Define
|
78
|
+
HiLink puppetDefName Type
|
79
|
+
HiLink puppetTypeName Statement
|
80
|
+
HiLink puppetTypeDefault Type
|
81
|
+
HiLink puppetParamName Identifier
|
82
|
+
HiLink puppetArgument Identifier
|
83
|
+
|
84
|
+
delcommand HiLink
|
85
|
+
endif
|
86
|
+
|
87
|
+
let b:current_syntax = "puppet"
|
data/install.rb
CHANGED
@@ -30,27 +30,37 @@
|
|
30
30
|
# 5) Install all library files ending in .rb from lib/ into Ruby's
|
31
31
|
# site_lib/version directory.
|
32
32
|
#
|
33
|
-
# $Id: install.rb
|
33
|
+
# $Id: install.rb 779 2006-01-05 20:36:01Z luke $
|
34
34
|
#++
|
35
35
|
|
36
36
|
require 'rbconfig'
|
37
37
|
require 'find'
|
38
38
|
require 'fileutils'
|
39
|
-
require '
|
39
|
+
require 'ftools' # apparently on some system ftools doesn't get loaded
|
40
40
|
require 'optparse'
|
41
41
|
require 'ostruct'
|
42
42
|
|
43
|
+
begin
|
44
|
+
require 'rdoc/rdoc'
|
45
|
+
$haverdoc = true
|
46
|
+
rescue LoadError
|
47
|
+
puts "Missing rdoc; skipping documentation"
|
48
|
+
$haverdoc = false
|
49
|
+
end
|
50
|
+
|
51
|
+
PREREQS = %w{openssl facter xmlrpc/client xmlrpc/server cgi}
|
52
|
+
|
43
53
|
InstallOptions = OpenStruct.new
|
44
54
|
|
45
55
|
def glob(list)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
56
|
+
g = list.map { |i| Dir.glob(i) }
|
57
|
+
g.flatten!
|
58
|
+
g.compact!
|
59
|
+
g.reject! { |e| e =~ /\.svn/ }
|
60
|
+
g
|
51
61
|
end
|
52
62
|
|
53
|
-
|
63
|
+
# Set these values to what you want installed.
|
54
64
|
bins = glob(%w{bin/**/*})
|
55
65
|
rdoc = glob(%w{bin/**/* lib/**/*.rb README README-library CHANGELOG TODO Install}).reject { |e| e=~ /\.(bat|cmd)$/ }
|
56
66
|
ri = glob(%w(bin/**/*.rb lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ }
|
@@ -74,15 +84,32 @@ def do_libs(libs, strip = 'lib/')
|
|
74
84
|
end
|
75
85
|
end
|
76
86
|
|
87
|
+
# Verify that all of the prereqs are installed
|
88
|
+
def check_prereqs
|
89
|
+
PREREQS.each { |pre|
|
90
|
+
begin
|
91
|
+
require pre
|
92
|
+
rescue LoadError
|
93
|
+
puts "Could not load %s; cannot install" % pre
|
94
|
+
end
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
77
98
|
##
|
78
99
|
# Prepare the file installation.
|
79
100
|
#
|
80
101
|
def prepare_installation
|
81
|
-
|
82
|
-
if
|
83
|
-
|
102
|
+
# Only try to do docs if we're sure they have rdoc
|
103
|
+
if $haverdoc
|
104
|
+
InstallOptions.rdoc = true
|
105
|
+
if RUBY_PLATFORM == "i386-mswin32"
|
106
|
+
InstallOptions.ri = false
|
107
|
+
else
|
108
|
+
InstallOptions.ri = true
|
109
|
+
end
|
84
110
|
else
|
85
|
-
|
111
|
+
InstallOptions.rdoc = false
|
112
|
+
InstallOptions.ri = false
|
86
113
|
end
|
87
114
|
InstallOptions.tests = true
|
88
115
|
|
@@ -153,25 +180,30 @@ end
|
|
153
180
|
# Build the rdoc documentation. Also, try to build the RI documentation.
|
154
181
|
#
|
155
182
|
def build_rdoc(files)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
183
|
+
return unless $haverdoc
|
184
|
+
begin
|
185
|
+
r = RDoc::RDoc.new
|
186
|
+
r.document(["--main", "README", "--title",
|
187
|
+
"Puppet -- Site Configuration Management", "--line-numbers"] + files)
|
188
|
+
rescue RDoc::RDocError => e
|
189
|
+
$stderr.puts e.message
|
190
|
+
rescue Exception => e
|
191
|
+
$stderr.puts "Couldn't build RDoc documentation\n#{e.message}"
|
192
|
+
end
|
164
193
|
end
|
165
194
|
|
166
195
|
def build_ri(files)
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
rescue
|
173
|
-
|
174
|
-
|
196
|
+
return unless $haverdoc
|
197
|
+
begin
|
198
|
+
ri = RDoc::RDoc.new
|
199
|
+
#ri.document(["--ri-site", "--merge"] + files)
|
200
|
+
ri.document(["--ri-site"] + files)
|
201
|
+
rescue RDoc::RDocError => e
|
202
|
+
$stderr.puts e.message
|
203
|
+
rescue Exception => e
|
204
|
+
$stderr.puts "Couldn't build Ri documentation\n#{e.message}"
|
205
|
+
$stderr.puts "Continuing with install..."
|
206
|
+
end
|
175
207
|
end
|
176
208
|
|
177
209
|
def run_tests(test_list)
|
@@ -261,10 +293,11 @@ goto done
|
|
261
293
|
:done
|
262
294
|
EOS
|
263
295
|
|
296
|
+
check_prereqs
|
264
297
|
prepare_installation
|
265
298
|
|
266
299
|
run_tests(tests) if InstallOptions.tests
|
267
|
-
build_rdoc(rdoc) if InstallOptions.rdoc
|
268
|
-
build_ri(ri) if InstallOptions.ri
|
300
|
+
#build_rdoc(rdoc) if InstallOptions.rdoc
|
301
|
+
#build_ri(ri) if InstallOptions.ri
|
269
302
|
do_bins(bins, Config::CONFIG['bindir'])
|
270
303
|
do_libs(libs)
|
data/lib/puppet.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'singleton'
|
2
|
+
require 'puppet/event-loop'
|
2
3
|
require 'puppet/log'
|
4
|
+
require 'puppet/config'
|
5
|
+
require 'puppet/util'
|
3
6
|
|
4
7
|
# see the bottom of the file for further inclusions
|
5
8
|
|
@@ -11,7 +14,7 @@ require 'puppet/log'
|
|
11
14
|
#
|
12
15
|
# it's also a place to find top-level commands like 'debug'
|
13
16
|
module Puppet
|
14
|
-
PUPPETVERSION=
|
17
|
+
PUPPETVERSION = '0.13.0'
|
15
18
|
|
16
19
|
def Puppet.version
|
17
20
|
return PUPPETVERSION
|
@@ -19,10 +22,18 @@ module Puppet
|
|
19
22
|
|
20
23
|
class Error < RuntimeError
|
21
24
|
attr_accessor :stack, :line, :file
|
25
|
+
attr_writer :backtrace
|
26
|
+
|
27
|
+
def backtrace
|
28
|
+
if defined? @backtrace
|
29
|
+
return @backtrace
|
30
|
+
else
|
31
|
+
return super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
22
35
|
def initialize(message)
|
23
36
|
@message = message
|
24
|
-
|
25
|
-
@stack = caller
|
26
37
|
end
|
27
38
|
|
28
39
|
def to_s
|
@@ -47,8 +58,12 @@ module Puppet
|
|
47
58
|
|
48
59
|
class DevError < Error; end
|
49
60
|
|
61
|
+
def self.name
|
62
|
+
$0.gsub(/.+#{File::SEPARATOR}/,'')
|
63
|
+
end
|
64
|
+
|
50
65
|
# the hash that determines how our system behaves
|
51
|
-
@@config =
|
66
|
+
@@config = Puppet::Config.new
|
52
67
|
|
53
68
|
# define helper messages for each of the message levels
|
54
69
|
Puppet::Log.eachlevel { |level|
|
@@ -68,50 +83,103 @@ module Puppet
|
|
68
83
|
# XXX this isn't actually working right now
|
69
84
|
alias :error :err
|
70
85
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
:statedir => [:puppetvar, "state"],
|
76
|
-
|
77
|
-
# then the files},
|
78
|
-
:manifestdir => [:puppetconf, "manifests"],
|
79
|
-
:manifest => [:manifestdir, "site.pp"],
|
80
|
-
:localconfig => [:puppetconf, "localconfig.ma"],
|
81
|
-
:logfile => [:logdir, "puppet.log"],
|
82
|
-
:httplogfile => [:logdir, "http.log"],
|
83
|
-
:masterlog => [:logdir, "puppetmaster.log"],
|
84
|
-
:masterhttplog => [:logdir, "masterhttp.log"],
|
85
|
-
:checksumfile => [:statedir, "checksums"],
|
86
|
-
:ssldir => [:puppetconf, "ssl"],
|
87
|
-
|
88
|
-
# and finally the simple answers,
|
89
|
-
:server => "puppet",
|
90
|
-
:rrdgraph => false,
|
91
|
-
:noop => false,
|
92
|
-
:parseonly => false,
|
93
|
-
:puppetport => 8139,
|
94
|
-
:masterport => 8140,
|
95
|
-
}
|
96
|
-
if Process.uid == 0
|
97
|
-
@defaults[:puppetconf] = "/etc/puppet"
|
98
|
-
@defaults[:puppetvar] = "/var/puppet"
|
99
|
-
else
|
100
|
-
@defaults[:puppetconf] = File.expand_path("~/.puppet")
|
101
|
-
@defaults[:puppetvar] = File.expand_path("~/.puppet/var")
|
86
|
+
# Store a new default value.
|
87
|
+
def self.setdefaults(section, *arrays)
|
88
|
+
start = Time.now
|
89
|
+
@@config.setdefaults(section, *arrays)
|
102
90
|
end
|
103
91
|
|
104
|
-
|
105
|
-
|
92
|
+
# If we're running the standalone puppet process as a non-root user,
|
93
|
+
# use basedirs that are in the user's home directory.
|
94
|
+
conf = nil
|
95
|
+
var = nil
|
96
|
+
if self.name == "puppet" and Process.uid != 0
|
97
|
+
conf = File.expand_path("~/.puppet")
|
98
|
+
var = File.expand_path("~/.puppet/var")
|
99
|
+
else
|
100
|
+
# Else, use system-wide directories.
|
101
|
+
conf = "/etc/puppet"
|
102
|
+
var = "/var/puppet"
|
106
103
|
end
|
104
|
+
self.setdefaults("puppet",
|
105
|
+
[:confdir, conf, "The main Puppet configuration directory."],
|
106
|
+
[:vardir, var, "Where Puppet stores dynamic and growing data."]
|
107
|
+
)
|
108
|
+
|
109
|
+
# Define the config default.
|
110
|
+
self.setdefaults(self.name,
|
111
|
+
[:config, "$confdir/#{self.name}.conf",
|
112
|
+
"The configuration file for #{self.name}."]
|
113
|
+
)
|
114
|
+
|
115
|
+
self.setdefaults("puppet",
|
116
|
+
[:logdir, "$vardir/log",
|
117
|
+
"The Puppet log directory."],
|
118
|
+
[:bucketdir, "$vardir/bucket",
|
119
|
+
"Where FileBucket files are stored."],
|
120
|
+
[:statedir, "$vardir/state",
|
121
|
+
"The directory where Puppet state is stored. Generally, this
|
122
|
+
directory can be removed without causing harm (although it might
|
123
|
+
result in spurious service restarts)."],
|
124
|
+
[:rundir, "$vardir/run", "Where Puppet PID files are kept."],
|
125
|
+
[:statefile, "$statedir/state.yaml",
|
126
|
+
"Where puppetd and puppetmasterd store state associated with the running
|
127
|
+
configuration. In the case of puppetmasterd, this file reflects the
|
128
|
+
state discovered through interacting with clients."],
|
129
|
+
[:ssldir, "$confdir/ssl", "Where SSL certificates are kept."],
|
130
|
+
[:genconfig, false,
|
131
|
+
"Whether to just print a configuration to stdout and exit. Only makes
|
132
|
+
sense when used interactively. Takes into account arguments specified
|
133
|
+
on the CLI."],
|
134
|
+
[:genmanifest, false,
|
135
|
+
"Whether to just print a manifest to stdout and exit. Only makes
|
136
|
+
sense when used interactively. Takes into account arguments specified
|
137
|
+
on the CLI."]
|
138
|
+
)
|
139
|
+
self.setdefaults("puppetmasterd",
|
140
|
+
[:manifestdir, "$confdir/manifests",
|
141
|
+
"Where puppetmasterd looks for its manifests."],
|
142
|
+
[:manifest, "$manifestdir/site.pp",
|
143
|
+
"The entry-point manifest for puppetmasterd."],
|
144
|
+
[:masterlog, "$logdir/puppetmaster.log",
|
145
|
+
"Where puppetmasterd logs. This is generally not used, since syslog
|
146
|
+
is the default log destination."],
|
147
|
+
[:masterhttplog, "$logdir/masterhttp.log",
|
148
|
+
"Where the puppetmasterd web server logs."],
|
149
|
+
[:masterport, 8140, "Which port puppetmasterd listens on."],
|
150
|
+
[:parseonly, false, "Just check the syntax of the manifests."]
|
151
|
+
)
|
152
|
+
|
153
|
+
self.setdefaults("puppetd",
|
154
|
+
[:localconfig, "$confdir/localconfig",
|
155
|
+
"Where puppetd caches the local configuration. An extension reflecting
|
156
|
+
the cache format is added automatically."],
|
157
|
+
[:classfile, "$confdir/classes.txt",
|
158
|
+
"The file in which puppetd stores a list of the classes associated
|
159
|
+
with the retrieved configuratiion."],
|
160
|
+
[:puppetdlog, "$logdir/puppetd.log",
|
161
|
+
"The log file for puppetd. This is generally not used."],
|
162
|
+
[:httplog, "$logdir/http.log", "Where the puppetd web server logs."],
|
163
|
+
[:server, "puppet",
|
164
|
+
"The server to which server puppetd should connect"],
|
165
|
+
[:user, "puppet", "The user puppetmasterd should run as."],
|
166
|
+
[:group, "puppet", "The group puppetmasterd should run as."],
|
167
|
+
[:ignoreschedules, false,
|
168
|
+
"Boolean; whether puppetd should ignore schedules. This is useful
|
169
|
+
for initial puppetd runs."],
|
170
|
+
[:puppetport, 8139, "Which port puppetd listens on."],
|
171
|
+
[:noop, false, "Whether puppetd should be run in noop mode."],
|
172
|
+
[:runinterval, 1800, # 30 minutes
|
173
|
+
"How often puppetd applies the client configuration; in seconds"]
|
174
|
+
)
|
175
|
+
self.setdefaults("metrics",
|
176
|
+
[:rrddir, "$vardir/rrd",
|
177
|
+
"The directory where RRD database files are stored."],
|
178
|
+
[:rrdgraph, false, "Whether RRD information should be graphed."]
|
179
|
+
)
|
107
180
|
|
108
181
|
# configuration parameter access and stuff
|
109
182
|
def self.[](param)
|
110
|
-
if param.is_a?(String)
|
111
|
-
param = param.intern
|
112
|
-
elsif ! param.is_a?(Symbol)
|
113
|
-
raise ArgumentError, "Invalid parameter type %s" % param.class
|
114
|
-
end
|
115
183
|
case param
|
116
184
|
when :debug:
|
117
185
|
if Puppet::Log.level == :debug
|
@@ -119,104 +187,113 @@ module Puppet
|
|
119
187
|
else
|
120
188
|
return false
|
121
189
|
end
|
122
|
-
when :loglevel:
|
123
|
-
return Puppet::Log.level
|
124
190
|
else
|
125
|
-
|
126
|
-
if @@config.include?(param)
|
127
|
-
return @@config[param]
|
128
|
-
else
|
129
|
-
if @defaults.include?(param)
|
130
|
-
default = @defaults[param]
|
131
|
-
if default.is_a?(Proc)
|
132
|
-
return default.call()
|
133
|
-
elsif default.is_a?(Array)
|
134
|
-
return File.join(self[default[0]], default[1])
|
135
|
-
else
|
136
|
-
return default
|
137
|
-
end
|
138
|
-
else
|
139
|
-
raise ArgumentError, "Invalid parameter %s" % param
|
140
|
-
end
|
141
|
-
end
|
191
|
+
return @@config[param]
|
142
192
|
end
|
143
193
|
end
|
144
194
|
|
145
195
|
# configuration parameter access and stuff
|
146
196
|
def self.[]=(param,value)
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
197
|
+
@@config[param] = value
|
198
|
+
# case param
|
199
|
+
# when :debug:
|
200
|
+
# if value
|
201
|
+
# Puppet::Log.level=(:debug)
|
202
|
+
# else
|
203
|
+
# Puppet::Log.level=(:notice)
|
204
|
+
# end
|
205
|
+
# when :loglevel:
|
206
|
+
# Puppet::Log.level=(value)
|
207
|
+
# when :logdest:
|
208
|
+
# Puppet::Log.newdestination(value)
|
209
|
+
# else
|
210
|
+
# @@config[param] = value
|
211
|
+
# end
|
161
212
|
end
|
162
213
|
|
163
|
-
def self.
|
164
|
-
|
165
|
-
|
166
|
-
require 'etc'
|
214
|
+
def self.clear
|
215
|
+
@@config.clear
|
216
|
+
end
|
167
217
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
218
|
+
def self.debug=(value)
|
219
|
+
if value
|
220
|
+
Puppet::Log.level=(:debug)
|
221
|
+
else
|
222
|
+
Puppet::Log.level=(:notice)
|
172
223
|
end
|
224
|
+
end
|
173
225
|
|
174
|
-
|
226
|
+
def self.config
|
227
|
+
@@config
|
228
|
+
end
|
175
229
|
|
176
|
-
|
177
|
-
if
|
178
|
-
|
179
|
-
|
230
|
+
def self.genconfig
|
231
|
+
if Puppet[:genconfig]
|
232
|
+
puts Puppet.config.to_config
|
233
|
+
exit(0)
|
180
234
|
end
|
235
|
+
end
|
181
236
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
Process.euid = olduid
|
237
|
+
def self.genmanifest
|
238
|
+
if Puppet[:genmanifest]
|
239
|
+
puts Puppet.config.to_manifest
|
240
|
+
exit(0)
|
187
241
|
end
|
188
|
-
|
189
|
-
return retval
|
190
242
|
end
|
191
243
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
end
|
199
|
-
else
|
200
|
-
raise ArgumentError, "Invalid default %s for param %s" %
|
201
|
-
[value.inspect, param]
|
202
|
-
end
|
203
|
-
|
204
|
-
unless value[1].is_a?(String)
|
205
|
-
raise ArgumentError, "Invalid default %s for param %s" %
|
206
|
-
[value.inspect, param]
|
207
|
-
end
|
208
|
-
|
209
|
-
unless value.length == 2
|
210
|
-
raise ArgumentError, "Invalid default %s for param %s" %
|
211
|
-
[value.inspect, param]
|
212
|
-
end
|
244
|
+
# Start our event loop. This blocks, waiting for someone, somewhere,
|
245
|
+
# to generate events of some kind.
|
246
|
+
def self.start
|
247
|
+
#Puppet.info "Starting loop"
|
248
|
+
EventLoop.current.run
|
249
|
+
end
|
213
250
|
|
214
|
-
|
215
|
-
|
216
|
-
|
251
|
+
# Create the timer that our different objects (uh, mostly the client)
|
252
|
+
# check.
|
253
|
+
def self.timer
|
254
|
+
unless defined? @timer
|
255
|
+
#Puppet.info "Interval is %s" % Puppet[:runinterval]
|
256
|
+
#@timer = EventLoop::Timer.new(:interval => Puppet[:runinterval])
|
257
|
+
@timer = EventLoop::Timer.new(
|
258
|
+
:interval => Puppet[:runinterval],
|
259
|
+
:tolerance => 1,
|
260
|
+
:start? => true
|
261
|
+
)
|
262
|
+
EventLoop.current.monitor_timer @timer
|
217
263
|
end
|
264
|
+
@timer
|
218
265
|
end
|
219
266
|
|
267
|
+
# Store a new default value.
|
268
|
+
# def self.setdefaults(section, hash)
|
269
|
+
# @@config.setdefaults(section, hash)
|
270
|
+
# if value.is_a?(Array)
|
271
|
+
# if value[0].is_a?(Symbol)
|
272
|
+
# unless @defaults.include?(value[0])
|
273
|
+
# raise ArgumentError, "Unknown basedir %s for param %s" %
|
274
|
+
# [value[0], param]
|
275
|
+
# end
|
276
|
+
# else
|
277
|
+
# raise ArgumentError, "Invalid default %s for param %s" %
|
278
|
+
# [value.inspect, param]
|
279
|
+
# end
|
280
|
+
#
|
281
|
+
# unless value[1].is_a?(String)
|
282
|
+
# raise ArgumentError, "Invalid default %s for param %s" %
|
283
|
+
# [value.inspect, param]
|
284
|
+
# end
|
285
|
+
#
|
286
|
+
# unless value.length == 2
|
287
|
+
# raise ArgumentError, "Invalid default %s for param %s" %
|
288
|
+
# [value.inspect, param]
|
289
|
+
# end
|
290
|
+
#
|
291
|
+
# @defaults[param] = value
|
292
|
+
# else
|
293
|
+
# @defaults[param] = value
|
294
|
+
# end
|
295
|
+
# end
|
296
|
+
|
220
297
|
# XXX this should all be done using puppet objects, not using
|
221
298
|
# normal mkdir
|
222
299
|
def self.recmkdir(dir,mode = 0755)
|
@@ -228,20 +305,37 @@ module Puppet
|
|
228
305
|
tmp.split(File::SEPARATOR).each { |dir|
|
229
306
|
path.push dir
|
230
307
|
if ! FileTest.exist?(File.join(path))
|
231
|
-
|
308
|
+
begin
|
309
|
+
Dir.mkdir(File.join(path), mode)
|
310
|
+
rescue Errno::EACCES => detail
|
311
|
+
Puppet.err detail.to_s
|
312
|
+
return false
|
313
|
+
rescue => detail
|
314
|
+
Puppet.err "Could not create %s: %s" % [path, detail.to_s]
|
315
|
+
return false
|
316
|
+
end
|
232
317
|
elsif FileTest.directory?(File.join(path))
|
233
318
|
next
|
234
319
|
else FileTest.exist?(File.join(path))
|
235
|
-
raise "Cannot create %s: basedir %s is a file" %
|
320
|
+
raise Puppet::Error, "Cannot create %s: basedir %s is a file" %
|
236
321
|
[dir, File.join(path)]
|
237
322
|
end
|
238
323
|
}
|
239
324
|
return true
|
240
325
|
end
|
241
326
|
end
|
327
|
+
|
328
|
+
# Create a new type. Just proxy to the Type class.
|
329
|
+
def self.newtype(name, parent = nil, &block)
|
330
|
+
Puppet::Type.newtype(name, parent, &block)
|
331
|
+
end
|
332
|
+
|
333
|
+
# Retrieve a type by name. Just proxy to the Type class.
|
334
|
+
def self.type(name)
|
335
|
+
Puppet::Type.type(name)
|
336
|
+
end
|
242
337
|
end
|
243
338
|
|
244
|
-
require 'puppet/util'
|
245
339
|
require 'puppet/server'
|
246
340
|
require 'puppet/type'
|
247
341
|
require 'puppet/storage'
|