puppet 0.24.5 → 0.24.6
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 +206 -0
- data/Rakefile +53 -0
- data/bin/filebucket +0 -0
- data/bin/puppet +32 -11
- data/bin/puppetca +1 -0
- data/bin/puppetd +0 -0
- data/bin/puppetdoc +0 -0
- data/bin/puppetmasterd +0 -0
- data/bin/puppetrun +16 -8
- data/bin/ralsh +0 -0
- data/conf/debian/rules +0 -0
- data/conf/gentoo/init.d/puppetmaster +0 -0
- data/conf/osx/PackageInfo.plist +36 -0
- data/conf/osx/createpackage.sh +167 -0
- data/conf/osx/preflight +12 -0
- data/conf/redhat/client.init +1 -1
- data/conf/redhat/puppet.spec +34 -6
- data/conf/redhat/server.init +42 -7
- data/conf/redhat/server.sysconfig +22 -0
- data/conf/solaris/smf/svc-puppetd +0 -0
- data/conf/solaris/smf/svc-puppetmasterd +0 -0
- data/examples/etc/init.d/sleeper +0 -0
- data/examples/mac_dscl.pp +0 -0
- data/examples/mac_dscl_revert.pp +0 -0
- data/examples/mac_netinfo.pp +0 -0
- data/examples/mac_pkgdmg.pp +0 -0
- data/ext/bin/sleeper +0 -0
- data/ext/module_puppet +0 -0
- data/ext/nagios/check_puppet.rb +0 -0
- data/ext/passenger/README +63 -0
- data/ext/passenger/apache2.conf +29 -0
- data/ext/passenger/config.ru +40 -0
- data/ext/puppet-test +0 -0
- data/ext/puppetlast +6 -31
- data/ext/puppetstoredconfigclean.rb +87 -0
- data/install.rb +75 -20
- data/lib/puppet.rb +1 -1
- data/lib/puppet/daemon.rb +0 -0
- data/lib/puppet/defaults.rb +3 -7
- data/lib/puppet/external/base64.rb +0 -0
- data/lib/puppet/external/nagios.rb +0 -0
- data/lib/puppet/external/nagios/base.rb +0 -0
- data/lib/puppet/file_serving/fileset.rb +2 -2
- data/lib/puppet/file_serving/metadata.rb +3 -3
- data/lib/puppet/indirector/facts/facter.rb +3 -2
- data/lib/puppet/indirector/yaml.rb +10 -1
- data/lib/puppet/module.rb +36 -12
- data/lib/puppet/network/authstore.rb +0 -0
- data/lib/puppet/network/client/master.rb +12 -11
- data/lib/puppet/network/handler/filebucket.rb +0 -0
- data/lib/puppet/network/handler/fileserver.rb +38 -46
- data/lib/puppet/network/handler/master.rb +1 -1
- data/lib/puppet/network/handler/report.rb +0 -0
- data/lib/puppet/network/handler/resource.rb +0 -0
- data/lib/puppet/network/handler/runner.rb +0 -0
- data/lib/puppet/network/http_server/rack.rb +148 -0
- data/lib/puppet/network/rights.rb +0 -0
- data/lib/puppet/network/xmlrpc/client.rb +5 -5
- data/lib/puppet/node.rb +5 -9
- data/lib/puppet/node/environment.rb +1 -17
- data/lib/puppet/node/facts.rb +0 -0
- data/lib/puppet/parameter.rb +1 -28
- data/lib/puppet/parser/ast.rb +6 -0
- data/lib/puppet/parser/ast/arithmetic_operator.rb +41 -0
- data/lib/puppet/parser/ast/boolean_operator.rb +48 -0
- data/lib/puppet/parser/ast/collexpr.rb +6 -1
- data/lib/puppet/parser/ast/comparison_operator.rb +37 -0
- data/lib/puppet/parser/ast/minus.rb +23 -0
- data/lib/puppet/parser/ast/nop.rb +11 -0
- data/lib/puppet/parser/ast/not.rb +19 -0
- data/lib/puppet/parser/ast/resource_override.rb +23 -16
- data/lib/puppet/parser/ast/resource_reference.rb +10 -6
- data/lib/puppet/parser/ast/vardef.rb +2 -2
- data/lib/puppet/parser/collector.rb +2 -1
- data/lib/puppet/parser/functions.rb +7 -217
- data/lib/puppet/parser/functions/defined.rb +27 -0
- data/lib/puppet/parser/functions/fail.rb +4 -0
- data/lib/puppet/parser/functions/file.rb +21 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +15 -0
- data/lib/puppet/parser/functions/generate.rb +35 -0
- data/lib/puppet/parser/functions/include.rb +26 -0
- data/lib/puppet/parser/functions/realize.rb +14 -0
- data/lib/puppet/parser/functions/search.rb +7 -0
- data/lib/puppet/parser/functions/sha1.rb +6 -0
- data/lib/puppet/parser/functions/tag.rb +6 -0
- data/lib/puppet/parser/functions/tagged.rb +18 -0
- data/lib/puppet/parser/functions/template.rb +22 -0
- data/lib/puppet/parser/lexer.rb +15 -5
- data/lib/puppet/parser/parser.rb +1073 -715
- data/lib/puppet/parser/parser_support.rb +18 -13
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/parser/resource/param.rb +10 -2
- data/lib/puppet/parser/scope.rb +63 -5
- data/lib/puppet/parser/templatewrapper.rb +61 -15
- data/lib/puppet/property.rb +7 -1
- data/lib/puppet/property/keyvalue.rb +96 -0
- data/lib/puppet/property/list.rb +78 -0
- data/lib/puppet/provider/confine.rb +1 -1
- data/lib/puppet/provider/confine/variable.rb +10 -1
- data/lib/puppet/provider/cron/crontab.rb +0 -0
- data/lib/puppet/provider/mailalias/aliases.rb +0 -0
- data/lib/puppet/provider/maillist/mailman.rb +0 -0
- data/lib/puppet/provider/mount/parsed.rb +0 -0
- data/lib/puppet/provider/nameservice.rb +24 -39
- data/lib/puppet/provider/nameservice/directoryservice.rb +12 -3
- data/lib/puppet/provider/nameservice/netinfo.rb +12 -2
- data/lib/puppet/provider/nameservice/objectadd.rb +1 -10
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/apple.rb +0 -0
- data/lib/puppet/provider/package/apt.rb +14 -21
- data/lib/puppet/provider/package/aptitude.rb +0 -0
- data/lib/puppet/provider/package/blastwave.rb +2 -0
- data/lib/puppet/provider/package/darwinport.rb +0 -0
- data/lib/puppet/provider/package/dpkg.rb +33 -51
- data/lib/puppet/provider/package/fink.rb +1 -1
- data/lib/puppet/provider/package/freebsd.rb +0 -0
- data/lib/puppet/provider/package/gem.rb +0 -0
- data/lib/puppet/provider/package/hpux.rb +46 -0
- data/lib/puppet/provider/package/openbsd.rb +0 -0
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +3 -1
- data/lib/puppet/provider/package/ports.rb +3 -3
- data/lib/puppet/provider/package/rpm.rb +8 -1
- data/lib/puppet/provider/package/rug.rb +2 -2
- data/lib/puppet/provider/package/sun.rb +2 -0
- data/lib/puppet/provider/package/sunfreeware.rb +3 -0
- data/lib/puppet/provider/package/yum.rb +24 -17
- data/lib/puppet/provider/package/yumhelper.py +92 -11
- data/lib/puppet/provider/parsedfile.rb +0 -0
- data/lib/puppet/provider/port/parsed.rb +0 -0
- data/lib/puppet/provider/selboolean/getsetsebool.rb +47 -0
- data/lib/puppet/provider/selmodule/semodule.rb +143 -0
- data/lib/puppet/provider/service/base.rb +0 -0
- data/lib/puppet/provider/service/daemontools.rb +154 -0
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/freebsd.rb +2 -0
- data/lib/puppet/provider/service/gentoo.rb +2 -0
- data/lib/puppet/provider/service/init.rb +0 -0
- data/lib/puppet/provider/service/redhat.rb +1 -1
- data/lib/puppet/provider/service/runit.rb +93 -0
- data/lib/puppet/provider/service/smf.rb +2 -0
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -1
- data/lib/puppet/provider/sshkey/parsed.rb +0 -0
- data/lib/puppet/provider/user/hpux.rb +30 -0
- data/lib/puppet/provider/user/user_role_add.rb +156 -0
- data/lib/puppet/provider/user/useradd.rb +23 -14
- data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +17 -0
- data/lib/puppet/rails/database/schema.rb +0 -8
- data/lib/puppet/rails/resource.rb +6 -6
- data/lib/puppet/reference/configuration.rb +0 -7
- data/lib/puppet/reports.rb +0 -0
- data/lib/puppet/reports/rrdgraph.rb +3 -2
- data/lib/puppet/sslcertificates.rb +0 -0
- data/lib/puppet/sslcertificates/inventory.rb +3 -2
- data/lib/puppet/sslcertificates/support.rb +3 -0
- data/lib/puppet/transaction/report.rb +1 -7
- data/lib/puppet/transportable.rb +10 -7
- data/lib/puppet/type.rb +2110 -14
- data/lib/puppet/type/cron.rb +0 -0
- data/lib/puppet/type/exec.rb +0 -0
- data/lib/puppet/type/file.rb +12 -2
- data/lib/puppet/type/file/checksum.rb +4 -0
- data/lib/puppet/type/file/content.rb +0 -0
- data/lib/puppet/type/file/ensure.rb +0 -0
- data/lib/puppet/type/file/group.rb +30 -43
- data/lib/puppet/type/file/mode.rb +0 -0
- data/lib/puppet/type/file/owner.rb +0 -0
- data/lib/puppet/type/file/selcontext.rb +104 -0
- data/lib/puppet/type/file/source.rb +0 -0
- data/lib/puppet/type/file/type.rb +0 -0
- data/lib/puppet/type/filebucket.rb +0 -0
- data/lib/puppet/type/group.rb +0 -8
- data/lib/puppet/type/host.rb +0 -0
- data/lib/puppet/type/mailalias.rb +0 -0
- data/lib/puppet/type/maillist.rb +0 -0
- data/lib/puppet/type/mount.rb +0 -0
- data/lib/puppet/type/package.rb +2 -2
- data/lib/puppet/type/port.rb +0 -0
- data/lib/puppet/type/schedule.rb +0 -0
- data/lib/puppet/type/selboolean.rb +31 -0
- data/lib/puppet/type/selmodule.rb +54 -0
- data/lib/puppet/type/ssh_authorized_key.rb +3 -3
- data/lib/puppet/type/sshkey.rb +0 -0
- data/lib/puppet/type/tidy.rb +0 -0
- data/lib/puppet/type/user.rb +153 -137
- data/lib/puppet/type/yumrepo.rb +18 -2
- data/lib/puppet/type/zone.rb +5 -1
- data/lib/puppet/util.rb +7 -7
- data/lib/puppet/util/filetype.rb +7 -0
- data/lib/puppet/util/instance_loader.rb +0 -0
- data/lib/puppet/util/ldap/connection.rb +11 -1
- data/lib/puppet/util/ldap/manager.rb +1 -1
- data/lib/puppet/util/loadedfile.rb +0 -0
- data/lib/puppet/util/log.rb +42 -43
- data/lib/puppet/util/metric.rb +23 -9
- data/lib/puppet/util/posix.rb +69 -18
- data/lib/puppet/util/selinux.rb +139 -0
- data/lib/puppet/util/settings.rb +5 -7
- data/lib/puppet/util/user_attr.rb +21 -0
- data/test/certmgr/ca.rb +0 -0
- data/test/certmgr/certmgr.rb +0 -0
- data/test/certmgr/inventory.rb +0 -0
- data/test/certmgr/support.rb +0 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys1 +3 -0
- data/test/data/snippets/append.pp +11 -0
- data/test/data/snippets/arithmetic_expression.pp +8 -0
- data/test/data/snippets/arraytrailingcomma.pp +3 -0
- data/test/data/snippets/emptyifelse.pp +9 -0
- data/test/data/snippets/funccomma.pp +5 -0
- data/test/data/snippets/ifexpression.rb +6 -0
- data/test/data/snippets/subclass_name_duplication.pp +0 -0
- data/test/executables/filebucket.rb +0 -0
- data/test/executables/puppetbin.rb +0 -0
- data/test/executables/puppetca.rb +0 -0
- data/test/executables/puppetd.rb +0 -0
- data/test/executables/puppetmasterd.rb +0 -0
- data/test/executables/puppetmodule.rb +0 -0
- data/test/language/ast.rb +0 -0
- data/test/language/ast/casestatement.rb +0 -0
- data/test/language/ast/resource.rb +0 -0
- data/test/language/ast/resource_reference.rb +0 -28
- data/test/language/ast/selector.rb +0 -0
- data/test/language/ast/variable.rb +0 -0
- data/test/language/functions.rb +91 -12
- data/test/language/parser.rb +21 -0
- data/test/language/resource.rb +0 -0
- data/test/language/scope.rb +28 -0
- data/test/language/snippets.rb +14 -0
- data/test/language/transportable.rb +0 -0
- data/test/lib/puppettest.rb +0 -0
- data/test/lib/puppettest/reporttesting.rb +0 -2
- data/test/lib/puppettest/runnable_test.rb +2 -0
- data/test/lib/puppettest/support/resources.rb +0 -0
- data/test/network/authconfig.rb +0 -0
- data/test/network/authorization.rb +0 -0
- data/test/network/authstore.rb +0 -0
- data/test/network/client/ca.rb +0 -0
- data/test/network/client/client.rb +0 -0
- data/test/network/client/dipper.rb +0 -0
- data/test/network/client/master.rb +2 -6
- data/test/network/client/resource.rb +0 -0
- data/test/network/client_request.rb +0 -0
- data/test/network/daemon.rb +0 -0
- data/test/network/handler/bucket.rb +0 -0
- data/test/network/handler/ca.rb +0 -0
- data/test/network/handler/fileserver.rb +8 -0
- data/test/network/handler/handler.rb +0 -0
- data/test/network/handler/master.rb +3 -1
- data/test/network/handler/report.rb +0 -0
- data/test/network/handler/resource.rb +0 -0
- data/test/network/handler/runner.rb +0 -0
- data/test/network/rights.rb +0 -0
- data/test/network/server/mongrel_test.rb +0 -0
- data/test/network/server/webrick.rb +0 -0
- data/test/network/xmlrpc/client.rb +0 -0
- data/test/network/xmlrpc/processor.rb +0 -0
- data/test/network/xmlrpc/server.rb +0 -0
- data/test/network/xmlrpc/webrick_servlet.rb +0 -0
- data/test/other/dsl.rb +0 -0
- data/test/other/events.rb +0 -0
- data/test/other/overrides.rb +0 -0
- data/test/other/provider.rb +0 -0
- data/test/other/puppet.rb +0 -0
- data/test/other/relationships.rb +0 -0
- data/test/other/report.rb +2 -4
- data/test/other/transactions.rb +1 -1
- data/test/puppet/conffiles.rb +0 -0
- data/test/puppet/defaults.rb +0 -0
- data/test/puppet/errortest.rb +0 -0
- data/test/puppet/tc_suidmanager.rb +0 -0
- data/test/rails/ast.rb +0 -0
- data/test/rails/configuration.rb +0 -0
- data/test/rails/host.rb +0 -0
- data/test/rails/rails.rb +0 -0
- data/test/rails/railsparameter.rb +0 -0
- data/test/rails/railsresource.rb +0 -0
- data/test/ral/manager/attributes.rb +0 -0
- data/test/ral/manager/instances.rb +0 -0
- data/test/ral/manager/manager.rb +0 -0
- data/test/ral/manager/provider.rb +0 -0
- data/test/ral/manager/type.rb +0 -0
- data/test/ral/providers/cron/crontab.rb +0 -0
- data/test/ral/providers/group.rb +14 -13
- data/test/ral/providers/host/netinfo.rb +0 -0
- data/test/ral/providers/host/parsed.rb +0 -0
- data/test/ral/providers/mailalias/aliases.rb +0 -0
- data/test/ral/providers/mount/netinfo.rb +0 -0
- data/test/ral/providers/nameservice.rb +0 -0
- data/test/ral/providers/package.rb +0 -31
- data/test/ral/providers/package/aptitude.rb +1 -2
- data/test/ral/providers/package/aptrpm.rb +2 -2
- data/test/ral/providers/parsedfile.rb +0 -0
- data/test/ral/providers/port/parsed.rb +0 -0
- data/test/ral/providers/provider.rb +0 -0
- data/test/ral/providers/service/base.rb +0 -0
- data/test/ral/providers/service/debian.rb +0 -0
- data/test/ral/providers/sshkey/parsed.rb +0 -0
- data/test/ral/providers/user.rb +8 -8
- data/test/ral/providers/user/useradd.rb +0 -0
- data/test/ral/type/basic.rb +0 -0
- data/test/ral/type/cron.rb +0 -0
- data/test/ral/type/exec.rb +0 -0
- data/test/ral/type/file.rb +0 -0
- data/test/ral/type/file/target.rb +0 -0
- data/test/ral/type/filebucket.rb +0 -0
- data/test/ral/type/fileignoresource.rb +0 -0
- data/test/ral/type/filesources.rb +1 -3
- data/test/ral/type/group.rb +0 -0
- data/test/ral/type/host.rb +0 -0
- data/test/ral/type/mailalias.rb +1 -2
- data/test/ral/type/parameter.rb +0 -0
- data/test/ral/type/port.rb +0 -0
- data/test/ral/type/property.rb +0 -0
- data/test/ral/type/resources.rb +0 -0
- data/test/ral/type/service.rb +0 -0
- data/test/ral/type/sshkey.rb +0 -0
- data/test/ral/type/tidy.rb +0 -0
- data/test/ral/type/user.rb +0 -50
- data/test/ral/type/yumrepo.rb +7 -1
- data/test/ral/type/zone.rb +0 -0
- data/test/test +0 -0
- data/test/util/autoload.rb +0 -0
- data/test/util/classgen.rb +0 -0
- data/test/util/execution.rb +0 -0
- data/test/util/features.rb +0 -0
- data/test/util/fileparsing.rb +0 -0
- data/test/util/filetype.rb +0 -0
- data/test/util/inifile.rb +0 -0
- data/test/util/instance_loader.rb +0 -0
- data/test/util/log.rb +0 -59
- data/test/util/metrics.rb +0 -0
- data/test/util/package.rb +0 -0
- data/test/util/pidlock.rb +0 -0
- data/test/util/settings.rb +0 -0
- data/test/util/storage.rb +0 -0
- data/test/util/subclass_loader.rb +0 -0
- data/test/util/utiltest.rb +0 -0
- metadata +54 -19
- data/lib/puppet/metatype/attributes.rb +0 -685
- data/lib/puppet/metatype/closure.rb +0 -49
- data/lib/puppet/metatype/container.rb +0 -50
- data/lib/puppet/metatype/evaluation.rb +0 -163
- data/lib/puppet/metatype/instances.rb +0 -305
- data/lib/puppet/metatype/metaparams.rb +0 -423
- data/lib/puppet/metatype/providers.rb +0 -247
- data/lib/puppet/metatype/relationships.rb +0 -115
- data/lib/puppet/metatype/schedules.rb +0 -33
- data/lib/puppet/metatype/tags.rb +0 -38
- data/lib/puppet/util/plist.rb +0 -23
- data/lib/puppet/util/plist/generator.rb +0 -225
- data/lib/puppet/util/plist/parser.rb +0 -226
- data/test/ral/providers/package/apt.rb +0 -169
- data/test/ral/providers/package/dpkg.rb +0 -64
- data/test/util/posixtest.rb +0 -169
@@ -95,11 +95,10 @@ class Puppet::Parser::Parser
|
|
95
95
|
raise Puppet::Error, "Could not find file %s" % file
|
96
96
|
end
|
97
97
|
end
|
98
|
-
if
|
99
|
-
raise Puppet::AlreadyImportedError.new("Import loop detected")
|
100
|
-
else
|
101
|
-
@files << Puppet::Util::LoadedFile.new(file)
|
98
|
+
if check_and_add_to_watched_files(file)
|
102
99
|
@lexer.file = file
|
100
|
+
else
|
101
|
+
raise Puppet::AlreadyImportedError.new("Import loop detected")
|
103
102
|
end
|
104
103
|
end
|
105
104
|
|
@@ -216,7 +215,7 @@ class Puppet::Parser::Parser
|
|
216
215
|
# Initialize or reset all of our variables.
|
217
216
|
def initvars
|
218
217
|
@lexer = Puppet::Parser::Lexer.new()
|
219
|
-
@files =
|
218
|
+
@files = {}
|
220
219
|
@loaded = []
|
221
220
|
end
|
222
221
|
|
@@ -435,8 +434,8 @@ class Puppet::Parser::Parser
|
|
435
434
|
|
436
435
|
# See if any of the files have changed.
|
437
436
|
def reparse?
|
438
|
-
if file = @files.detect { |file| file.changed? }
|
439
|
-
return file.stamp
|
437
|
+
if file = @files.detect { |name, file| file.changed? }
|
438
|
+
return file[1].stamp
|
440
439
|
else
|
441
440
|
return false
|
442
441
|
end
|
@@ -449,12 +448,18 @@ class Puppet::Parser::Parser
|
|
449
448
|
# Add a new file to be checked when we're checking to see if we should be
|
450
449
|
# reparsed. This is basically only used by the TemplateWrapper to let the
|
451
450
|
# parser know about templates that should be parsed.
|
452
|
-
def watch_file(
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
451
|
+
def watch_file(filename)
|
452
|
+
check_and_add_to_watched_files(filename)
|
453
|
+
end
|
454
|
+
|
455
|
+
private
|
456
|
+
|
457
|
+
def check_and_add_to_watched_files(filename)
|
458
|
+
unless @files.include?(filename)
|
459
|
+
@files[filename] = Puppet::Util::LoadedFile.new(filename)
|
460
|
+
return true
|
461
|
+
else
|
462
|
+
return false
|
458
463
|
end
|
459
464
|
end
|
460
465
|
end
|
@@ -369,7 +369,7 @@ class Puppet::Parser::Resource
|
|
369
369
|
next unless val = scope.lookupvar(name.to_s, false) and val != :undefined
|
370
370
|
|
371
371
|
# The default case: just set the value
|
372
|
-
|
372
|
+
set_parameter(name, val) and next unless @params[name]
|
373
373
|
|
374
374
|
# For relationship params, though, join the values (a la #446).
|
375
375
|
@params[name].value = [@params[name].value, val].flatten
|
@@ -66,6 +66,14 @@ class Puppet::Parser::Resource::Param
|
|
66
66
|
def to_s
|
67
67
|
"%s => %s" % [self.name, self.value]
|
68
68
|
end
|
69
|
+
|
70
|
+
def compare(v,db_value)
|
71
|
+
if (v.is_a?(Puppet::Parser::Resource::Reference))
|
72
|
+
return v.to_s == db_value.to_s
|
73
|
+
else
|
74
|
+
return v == db_value
|
75
|
+
end
|
76
|
+
end
|
69
77
|
|
70
78
|
def values_to_remove(db_values)
|
71
79
|
values = munge_for_rails(value)
|
@@ -73,7 +81,7 @@ class Puppet::Parser::Resource::Param
|
|
73
81
|
db_values.collect do |db|
|
74
82
|
db unless (db.line == line_number &&
|
75
83
|
values.find { |v|
|
76
|
-
v
|
84
|
+
compare(v,db.value)
|
77
85
|
} )
|
78
86
|
end.compact
|
79
87
|
end
|
@@ -82,7 +90,7 @@ class Puppet::Parser::Resource::Param
|
|
82
90
|
values = munge_for_rails(value)
|
83
91
|
line_number = line_to_i()
|
84
92
|
values.collect do |v|
|
85
|
-
v unless db_values.find { |db| (v
|
93
|
+
v unless db_values.find { |db| (compare(v,db.value) &&
|
86
94
|
line_number == db.line) }
|
87
95
|
end.compact
|
88
96
|
end
|
data/lib/puppet/parser/scope.rb
CHANGED
@@ -43,6 +43,29 @@ class Puppet::Parser::Scope
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
# Is the value a number?, return the correct object or nil if not a number
|
47
|
+
def self.number?(value)
|
48
|
+
unless value.is_a?(Fixnum) or value.is_a?(Bignum) or value.is_a?(Float) or value.is_a?(String)
|
49
|
+
return nil
|
50
|
+
end
|
51
|
+
|
52
|
+
if value.is_a?(String)
|
53
|
+
if value =~ /^-?\d+(:?\.\d+|(:?\.\d+)?e\d+)$/
|
54
|
+
return value.to_f
|
55
|
+
elsif value =~ /^0x\d+/i
|
56
|
+
return value.to_i(16)
|
57
|
+
elsif value =~ /^0\d+/i
|
58
|
+
return value.to_i(8)
|
59
|
+
elsif value =~ /^-?\d+/
|
60
|
+
return value.to_i
|
61
|
+
else
|
62
|
+
return nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
# it is one of Fixnum,Bignum or Float
|
66
|
+
return value
|
67
|
+
end
|
68
|
+
|
46
69
|
# Add to our list of namespaces.
|
47
70
|
def add_namespace(ns)
|
48
71
|
return false if @namespaces.include?(ns)
|
@@ -183,6 +206,25 @@ class Puppet::Parser::Scope
|
|
183
206
|
end
|
184
207
|
end
|
185
208
|
|
209
|
+
# Return a hash containing our variables and their values, optionally (and
|
210
|
+
# by default) including the values defined in our parent. Local values
|
211
|
+
# shadow parent values.
|
212
|
+
def to_hash(recursive = true)
|
213
|
+
if recursive and parent then
|
214
|
+
target = parent.to_hash(recursive)
|
215
|
+
end
|
216
|
+
target ||= Hash.new
|
217
|
+
@symtable.keys.each { |name|
|
218
|
+
value = @symtable[name]
|
219
|
+
if value == :undef then
|
220
|
+
target.delete(name)
|
221
|
+
else
|
222
|
+
target[name] = value
|
223
|
+
end
|
224
|
+
}
|
225
|
+
return target
|
226
|
+
end
|
227
|
+
|
186
228
|
def namespaces
|
187
229
|
@namespaces.dup
|
188
230
|
end
|
@@ -241,11 +283,15 @@ class Puppet::Parser::Scope
|
|
241
283
|
# Set a variable in the current scope. This will override settings
|
242
284
|
# in scopes above, but will not allow variables in the current scope
|
243
285
|
# to be reassigned.
|
244
|
-
def setvar(name,value, file = nil, line = nil)
|
245
|
-
#Puppet.debug "Setting %s to '%s' at level %s" %
|
246
|
-
# [name.inspect,value,self.level]
|
286
|
+
def setvar(name,value, file = nil, line = nil, append = false)
|
287
|
+
#Puppet.debug "Setting %s to '%s' at level %s mode append %s" %
|
288
|
+
# [name.inspect,value,self.level, append]
|
247
289
|
if @symtable.include?(name)
|
248
|
-
|
290
|
+
unless append
|
291
|
+
error = Puppet::ParseError.new("Cannot reassign variable %s" % name)
|
292
|
+
else
|
293
|
+
error = Puppet::ParseError.new("Cannot append, variable %s is defined in this scope" % name)
|
294
|
+
end
|
249
295
|
if file
|
250
296
|
error.file = file
|
251
297
|
end
|
@@ -254,7 +300,19 @@ class Puppet::Parser::Scope
|
|
254
300
|
end
|
255
301
|
raise error
|
256
302
|
end
|
257
|
-
|
303
|
+
|
304
|
+
unless append
|
305
|
+
@symtable[name] = value
|
306
|
+
else # append case
|
307
|
+
# lookup the value in the scope if it exists and insert the var
|
308
|
+
@symtable[name] = lookupvar(name)
|
309
|
+
# concatenate if string, append if array, nothing for other types
|
310
|
+
if value.is_a?(Array)
|
311
|
+
@symtable[name] += value
|
312
|
+
else
|
313
|
+
@symtable[name] << value
|
314
|
+
end
|
315
|
+
end
|
258
316
|
end
|
259
317
|
|
260
318
|
# Return an interpolated string.
|
@@ -5,50 +5,96 @@ class Puppet::Parser::TemplateWrapper
|
|
5
5
|
include Puppet::Util
|
6
6
|
Puppet::Util.logmethods(self)
|
7
7
|
|
8
|
-
def initialize(scope,
|
9
|
-
@
|
10
|
-
@
|
8
|
+
def initialize(scope, filename)
|
9
|
+
@__scope__ = scope
|
10
|
+
@__file__ = Puppet::Module::find_template(filename, scope.compiler.environment)
|
11
11
|
|
12
|
-
unless FileTest.exists?(
|
12
|
+
unless FileTest.exists?(file)
|
13
13
|
raise Puppet::ParseError,
|
14
14
|
"Could not find template %s" % file
|
15
15
|
end
|
16
16
|
|
17
17
|
# We'll only ever not have a parser in testing, but, eh.
|
18
|
-
if
|
19
|
-
|
18
|
+
if scope.parser
|
19
|
+
scope.parser.watch_file(file)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def scope
|
24
|
+
@__scope__
|
25
|
+
end
|
26
|
+
|
27
|
+
def file
|
28
|
+
@__file__
|
29
|
+
end
|
30
|
+
|
23
31
|
# Should return true if a variable is defined, false if it is not
|
24
32
|
def has_variable?(name)
|
25
|
-
if
|
33
|
+
if scope.lookupvar(name.to_s, false) != :undefined
|
26
34
|
true
|
27
35
|
else
|
28
36
|
false
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
32
|
-
#
|
33
|
-
|
40
|
+
# Allow templates to access the defined classes
|
41
|
+
def classes
|
42
|
+
return scope.catalog.classes
|
43
|
+
end
|
44
|
+
|
45
|
+
# Allow templates to access the tags defined in the current scope
|
46
|
+
def tags
|
47
|
+
return scope.tags
|
48
|
+
end
|
49
|
+
|
50
|
+
# Allow templates to access the all the defined tags
|
51
|
+
def all_tags
|
52
|
+
return scope.catalog.tags
|
53
|
+
end
|
54
|
+
|
55
|
+
# Ruby treats variables like methods, so we used to expose variables
|
56
|
+
# within scope to the ERB code via method_missing. As per RedMine #1427,
|
57
|
+
# though, this means that conflicts between methods in our inheritance
|
58
|
+
# tree (Kernel#fork) and variable names (fork => "yes/no") could arise.
|
59
|
+
#
|
60
|
+
# Worse, /new/ conflicts could pop up when a new kernel or object method
|
61
|
+
# was added to Ruby, causing templates to suddenly fail mysteriously when
|
62
|
+
# Ruby was upgraded.
|
63
|
+
#
|
64
|
+
# To ensure that legacy templates using unqualified names work we retain
|
65
|
+
# the missing_method definition here until we declare the syntax finally
|
66
|
+
# dead.
|
34
67
|
def method_missing(name, *args)
|
35
68
|
# We have to tell lookupvar to return :undefined to us when
|
36
69
|
# appropriate; otherwise it converts to "".
|
37
|
-
value =
|
70
|
+
value = scope.lookupvar(name.to_s, false)
|
38
71
|
if value != :undefined
|
39
72
|
return value
|
40
73
|
else
|
41
74
|
# Just throw an error immediately, instead of searching for
|
42
75
|
# other missingmethod things or whatever.
|
43
|
-
raise Puppet::ParseError,
|
44
|
-
"Could not find value for '%s'" % name
|
76
|
+
raise Puppet::ParseError, "Could not find value for '%s'" % name
|
45
77
|
end
|
46
78
|
end
|
47
79
|
|
48
80
|
def result
|
81
|
+
# Expose all the variables in our scope as instance variables of the
|
82
|
+
# current object, making it possible to access them without conflict
|
83
|
+
# to the regular methods.
|
84
|
+
benchmark(:debug, "Bound template variables for #{file}") do
|
85
|
+
scope.to_hash.each { |name, value|
|
86
|
+
if name.kind_of?(String)
|
87
|
+
realname = name.gsub(/[^\w]/, "_")
|
88
|
+
else
|
89
|
+
realname = name
|
90
|
+
end
|
91
|
+
instance_variable_set("@#{realname}", value)
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
49
95
|
result = nil
|
50
|
-
benchmark(:debug, "Interpolated template #{
|
51
|
-
template = ERB.new(File.read(
|
96
|
+
benchmark(:debug, "Interpolated template #{file}") do
|
97
|
+
template = ERB.new(File.read(file), 0, "-")
|
52
98
|
result = template.result(binding)
|
53
99
|
end
|
54
100
|
|
@@ -56,7 +102,7 @@ class Puppet::Parser::TemplateWrapper
|
|
56
102
|
end
|
57
103
|
|
58
104
|
def to_s
|
59
|
-
"template[%s]" %
|
105
|
+
"template[%s]" % file
|
60
106
|
end
|
61
107
|
end
|
62
108
|
|
data/lib/puppet/property.rb
CHANGED
@@ -441,7 +441,13 @@ class Property < Puppet::Parameter
|
|
441
441
|
return "%s(%s)" % [@resource.name,self.name]
|
442
442
|
end
|
443
443
|
|
444
|
-
#
|
444
|
+
# Just return any should value we might have.
|
445
|
+
def value
|
446
|
+
self.should
|
447
|
+
end
|
448
|
+
|
449
|
+
# Match the Parameter interface, but we really just use 'should' internally.
|
450
|
+
# Note that the should= method does all of the validation and such.
|
445
451
|
def value=(value)
|
446
452
|
self.should = value
|
447
453
|
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#This subclass of property manages string key value pairs.
|
2
|
+
|
3
|
+
#In order to use this property:
|
4
|
+
# - the @should value must be an array of keyvalue pairs separated by the 'separator'
|
5
|
+
# - the retrieve method should return a hash with the keys as symbols
|
6
|
+
# IMPORTANT NOTE: In order for this property to work there must also be a 'membership' parameter
|
7
|
+
# The class that inherits from property should override that method with the symbol for the membership
|
8
|
+
|
9
|
+
require 'puppet/property'
|
10
|
+
|
11
|
+
module Puppet
|
12
|
+
class Property
|
13
|
+
class KeyValue < Property
|
14
|
+
|
15
|
+
def hash_to_key_value_s(hash)
|
16
|
+
hash.select { |k,v| true }.map { |pair| pair.join(separator) }.join(delimiter)
|
17
|
+
end
|
18
|
+
|
19
|
+
def should_to_s(should_value)
|
20
|
+
hash_to_key_value_s(should_value)
|
21
|
+
end
|
22
|
+
|
23
|
+
def is_to_s(current_value)
|
24
|
+
hash_to_key_value_s(current_value)
|
25
|
+
end
|
26
|
+
|
27
|
+
def membership
|
28
|
+
:key_value_membership
|
29
|
+
end
|
30
|
+
|
31
|
+
def inclusive?
|
32
|
+
@resource[membership] == :inclusive
|
33
|
+
end
|
34
|
+
|
35
|
+
def hashify(key_value_array)
|
36
|
+
#turns string array into a hash
|
37
|
+
key_value_array.inject({}) do |hash, key_value|
|
38
|
+
tmp = key_value.split(separator)
|
39
|
+
hash[tmp[0].intern] = tmp[1]
|
40
|
+
hash
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def process_current_hash(current)
|
45
|
+
return {} if current == :absent
|
46
|
+
|
47
|
+
#inclusive means we are managing everything so if it isn't in should, its gone
|
48
|
+
if inclusive?
|
49
|
+
current.each_key { |key| current[key] = nil }
|
50
|
+
end
|
51
|
+
current
|
52
|
+
end
|
53
|
+
|
54
|
+
def should
|
55
|
+
unless defined? @should and @should
|
56
|
+
return nil
|
57
|
+
end
|
58
|
+
|
59
|
+
members = hashify(@should)
|
60
|
+
current = process_current_hash(retrieve)
|
61
|
+
|
62
|
+
#shared keys will get overwritten by members
|
63
|
+
current.merge(members)
|
64
|
+
end
|
65
|
+
|
66
|
+
def separator
|
67
|
+
"="
|
68
|
+
end
|
69
|
+
|
70
|
+
def delimiter
|
71
|
+
";"
|
72
|
+
end
|
73
|
+
|
74
|
+
def retrieve
|
75
|
+
#ok, some 'convention' if the keyvalue property is named properties, provider should implement a properties method
|
76
|
+
if key_hash = provider.send(name) and key_hash != :absent
|
77
|
+
return key_hash
|
78
|
+
else
|
79
|
+
return :absent
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def insync?(is)
|
84
|
+
unless defined? @should and @should
|
85
|
+
return true
|
86
|
+
end
|
87
|
+
|
88
|
+
unless is
|
89
|
+
return true
|
90
|
+
end
|
91
|
+
|
92
|
+
return (is == self.should)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'puppet/property'
|
2
|
+
|
3
|
+
module Puppet
|
4
|
+
class Property
|
5
|
+
class List < Property
|
6
|
+
|
7
|
+
def should_to_s(should_value)
|
8
|
+
#just return the should value
|
9
|
+
should_value
|
10
|
+
end
|
11
|
+
|
12
|
+
def is_to_s(currentvalue)
|
13
|
+
currentvalue.join(delimiter)
|
14
|
+
end
|
15
|
+
|
16
|
+
def membership
|
17
|
+
:membership
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_should_with_current(should, current)
|
21
|
+
if current.is_a?(Array)
|
22
|
+
should += current
|
23
|
+
end
|
24
|
+
should.uniq
|
25
|
+
end
|
26
|
+
|
27
|
+
def inclusive?
|
28
|
+
@resource[membership] == :inclusive
|
29
|
+
end
|
30
|
+
|
31
|
+
def should
|
32
|
+
unless defined? @should and @should
|
33
|
+
return nil
|
34
|
+
end
|
35
|
+
|
36
|
+
members = @should
|
37
|
+
#inclusive means we are managing everything so if it isn't in should, its gone
|
38
|
+
if ! inclusive?
|
39
|
+
members = add_should_with_current(members, retrieve)
|
40
|
+
end
|
41
|
+
|
42
|
+
members.sort.join(delimiter)
|
43
|
+
end
|
44
|
+
|
45
|
+
def delimiter
|
46
|
+
","
|
47
|
+
end
|
48
|
+
|
49
|
+
def retrieve
|
50
|
+
#ok, some 'convention' if the list property is named groups, provider should implement a groups method
|
51
|
+
if tmp = provider.send(name) and tmp != :absent
|
52
|
+
return tmp.split(delimiter)
|
53
|
+
else
|
54
|
+
return :absent
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def prepare_is_for_comparison(is)
|
59
|
+
if is.is_a? Array
|
60
|
+
is = is.sort.join(delimiter)
|
61
|
+
end
|
62
|
+
is
|
63
|
+
end
|
64
|
+
|
65
|
+
def insync?(is)
|
66
|
+
unless defined? @should and @should
|
67
|
+
return true
|
68
|
+
end
|
69
|
+
|
70
|
+
unless is
|
71
|
+
return true
|
72
|
+
end
|
73
|
+
|
74
|
+
return (prepare_is_for_comparison(is) == self.should)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|