puppet 2.7.19 → 2.7.20.rc1
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/CONTRIBUTING.md +61 -238
- data/Gemfile +32 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +1 -1
- data/README_DEVELOPER.md +300 -5
- data/Rakefile +41 -37
- data/ext/build_defaults.yaml +20 -0
- data/ext/debian/README.Debian +8 -0
- data/ext/debian/README.source +2 -0
- data/ext/debian/TODO.Debian +1 -0
- data/ext/debian/changelog.erb +1104 -0
- data/ext/debian/compat +1 -0
- data/ext/debian/control +142 -0
- data/ext/debian/copyright +361 -0
- data/ext/debian/docs +1 -0
- data/ext/debian/fileserver.conf +17 -0
- data/ext/debian/puppet-common.dirs +8 -0
- data/ext/debian/puppet-common.install +3 -0
- data/ext/debian/puppet-common.lintian-overrides +7 -0
- data/ext/debian/puppet-common.manpages +2 -0
- data/ext/debian/puppet-common.postinst +35 -0
- data/ext/debian/puppet-common.postrm +32 -0
- data/ext/debian/puppet-el.dirs +1 -0
- data/ext/debian/puppet-el.emacsen-install +25 -0
- data/ext/debian/puppet-el.emacsen-remove +11 -0
- data/ext/debian/puppet-el.emacsen-startup +9 -0
- data/ext/debian/puppet-el.install +1 -0
- data/ext/debian/puppet-testsuite.install +3 -0
- data/ext/debian/puppet-testsuite.lintian-overrides +4 -0
- data/ext/debian/puppet.NEWS +86 -0
- data/ext/debian/puppet.conf +14 -0
- data/ext/debian/puppet.default +7 -0
- data/ext/debian/puppet.dirs +1 -0
- data/ext/debian/puppet.init +118 -0
- data/ext/debian/puppet.install +4 -0
- data/ext/debian/puppet.lintian-overrides +3 -0
- data/ext/debian/puppet.logrotate +11 -0
- data/ext/debian/puppet.manpages +36 -0
- data/ext/debian/puppet.postinst +20 -0
- data/ext/debian/puppet.postrm +20 -0
- data/ext/debian/puppet.preinst +20 -0
- data/ext/debian/puppetmaster-common.install +5 -0
- data/ext/debian/puppetmaster-common.manpages +5 -0
- data/ext/debian/puppetmaster-common.puppetqd.default +27 -0
- data/ext/debian/puppetmaster-common.puppetqd.init +84 -0
- data/ext/debian/puppetmaster-passenger.dirs +4 -0
- data/ext/debian/puppetmaster-passenger.postinst +66 -0
- data/ext/debian/puppetmaster-passenger.postrm +33 -0
- data/ext/debian/puppetmaster.NEWS +13 -0
- data/ext/debian/puppetmaster.README.debian +16 -0
- data/ext/debian/puppetmaster.default +38 -0
- data/ext/debian/puppetmaster.dirs +1 -0
- data/ext/debian/puppetmaster.init +158 -0
- data/ext/debian/puppetmaster.install +1 -0
- data/ext/debian/puppetmaster.lintian-overrides +3 -0
- data/ext/debian/puppetmaster.manpages +1 -0
- data/ext/debian/puppetmaster.postinst +20 -0
- data/ext/debian/puppetmaster.postrm +5 -0
- data/ext/debian/puppetmaster.preinst +22 -0
- data/ext/debian/rules +127 -0
- data/ext/debian/source/format +1 -0
- data/ext/debian/source/options +1 -0
- data/ext/debian/vim-puppet.README.Debian +13 -0
- data/ext/debian/vim-puppet.dirs +3 -0
- data/ext/debian/vim-puppet.yaml +5 -0
- data/ext/debian/watch +2 -0
- data/ext/emacs/puppet-mode.el +1 -0
- data/{conf → ext}/osx/PackageInfo.plist +0 -0
- data/{conf → ext}/osx/createpackage.sh +0 -0
- data/ext/osx/file_mapping.yaml +38 -0
- data/ext/osx/preflight.erb +37 -0
- data/{tasks/rake/templates → ext/osx}/prototype.plist.erb +0 -0
- data/ext/packaging/README-Solaris.md +117 -0
- data/ext/packaging/README.md +255 -0
- data/ext/packaging/spec/spec_helper.rb +12 -0
- data/ext/packaging/spec/tasks/00_utils_spec.rb +66 -0
- data/ext/packaging/tasks/00_utils.rake +382 -0
- data/ext/packaging/tasks/10_setupvars.rake +71 -0
- data/ext/packaging/tasks/20_setupextravars.rake +25 -0
- data/ext/packaging/tasks/apple.rake +201 -0
- data/ext/packaging/tasks/clean.rake +5 -0
- data/ext/packaging/tasks/deb.rake +108 -0
- data/ext/packaging/tasks/doc.rake +20 -0
- data/ext/packaging/tasks/fetch.rake +18 -0
- data/ext/packaging/tasks/gem.rake +68 -0
- data/ext/packaging/tasks/ips.rake +80 -0
- data/ext/packaging/tasks/mock.rake +126 -0
- data/ext/packaging/tasks/pe_deb.rake +9 -0
- data/ext/packaging/tasks/pe_remote.rake +45 -0
- data/ext/packaging/tasks/pe_rpm.rake +21 -0
- data/ext/packaging/tasks/pe_ship.rake +30 -0
- data/ext/packaging/tasks/pe_sign.rake +27 -0
- data/ext/packaging/tasks/pe_sles.rake +96 -0
- data/ext/packaging/tasks/release.rake +73 -0
- data/ext/packaging/tasks/remote_build.rake +78 -0
- data/ext/packaging/tasks/rpm.rake +52 -0
- data/ext/packaging/tasks/ship.rake +78 -0
- data/ext/packaging/tasks/sign.rake +82 -0
- data/ext/packaging/tasks/tag.rake +8 -0
- data/ext/packaging/tasks/tar.rake +68 -0
- data/ext/packaging/tasks/template.rake +13 -0
- data/ext/packaging/tasks/update.rake +16 -0
- data/ext/packaging/tasks/version.rake +21 -0
- data/ext/project_data.yaml +24 -0
- data/{conf/redhat/puppet.spec → ext/redhat/puppet.spec.erb} +18 -10
- data/install.rb +8 -8
- data/lib/puppet.rb +2 -6
- data/lib/puppet/agent/locker.rb +2 -0
- data/lib/puppet/application.rb +1 -1
- data/lib/puppet/application/agent.rb +1 -1
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/application/cert.rb +5 -6
- data/lib/puppet/application/describe.rb +1 -1
- data/lib/puppet/application/device.rb +1 -1
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +1 -1
- data/lib/puppet/application/kick.rb +1 -1
- data/lib/puppet/application/master.rb +1 -1
- data/lib/puppet/application/resource.rb +1 -1
- data/lib/puppet/defaults.rb +21 -3
- data/lib/puppet/external/dot.rb +1 -1
- data/lib/puppet/face/help/global.erb +1 -1
- data/lib/puppet/face/module/install.rb +1 -1
- data/lib/puppet/face/module/list.rb +1 -1
- data/lib/puppet/face/module/uninstall.rb +1 -1
- data/lib/puppet/face/node/clean.rb +23 -18
- data/lib/puppet/face/parser.rb +11 -2
- data/lib/puppet/file_collection.rb +16 -27
- data/lib/puppet/file_collection/lookup.rb +6 -16
- data/lib/puppet/file_serving/base.rb +4 -4
- data/lib/puppet/indirector/catalog/static_compiler.rb +3 -4
- data/lib/puppet/indirector/certificate/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/certificate_request/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/face.rb +2 -2
- data/lib/puppet/indirector/key/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/node/exec.rb +13 -1
- data/lib/puppet/indirector/request.rb +4 -0
- data/lib/puppet/metatype/manager.rb +17 -10
- data/lib/puppet/network/authstore.rb +1 -1
- data/lib/puppet/network/rights.rb +1 -2
- data/lib/puppet/node/environment.rb +1 -0
- data/lib/puppet/parameter/value.rb +9 -3
- data/lib/puppet/parser/ast.rb +1 -4
- data/lib/puppet/parser/files.rb +1 -1
- data/lib/puppet/parser/functions.rb +68 -22
- data/lib/puppet/parser/functions/create_resources.rb +2 -3
- data/lib/puppet/parser/functions/shellquote.rb +21 -25
- data/lib/puppet/parser/lexer.rb +40 -6
- data/lib/puppet/parser/relationship.rb +3 -1
- data/lib/puppet/parser/resource.rb +2 -3
- data/lib/puppet/parser/resource/param.rb +3 -5
- data/lib/puppet/parser/scope.rb +7 -4
- data/lib/puppet/property.rb +5 -3
- data/lib/puppet/provider.rb +5 -5
- data/lib/puppet/provider/aixobject.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +1 -1
- data/lib/puppet/provider/file/windows.rb +10 -29
- data/lib/puppet/provider/group/groupadd.rb +2 -3
- data/lib/puppet/provider/group/ldap.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +1 -1
- data/lib/puppet/provider/ldap.rb +5 -1
- data/lib/puppet/provider/nameservice.rb +3 -3
- data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
- data/lib/puppet/provider/package/gem.rb +6 -2
- data/lib/puppet/provider/package/portage.rb +4 -2
- data/lib/puppet/provider/parsedfile.rb +1 -1
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
- data/lib/puppet/provider/service/base.rb +2 -41
- data/lib/puppet/provider/service/daemontools.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +1 -1
- data/lib/puppet/provider/service/redhat.rb +6 -5
- data/lib/puppet/provider/service/runit.rb +1 -1
- data/lib/puppet/provider/service/service.rb +43 -0
- data/lib/puppet/provider/service/windows.rb +1 -8
- data/lib/puppet/provider/user/user_role_add.rb +2 -1
- data/lib/puppet/provider/user/useradd.rb +8 -3
- data/lib/puppet/provider/user/windows_adsi.rb +12 -1
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/rails/inventory_node.rb +26 -13
- data/lib/puppet/reports.rb +1 -1
- data/lib/puppet/resource.rb +20 -5
- data/lib/puppet/resource/status.rb +1 -1
- data/lib/puppet/ssl/certificate_authority.rb +2 -0
- data/lib/puppet/ssl/host.rb +31 -6
- data/lib/puppet/test/test_helper.rb +3 -1
- data/lib/puppet/transaction/event.rb +1 -1
- data/lib/puppet/transaction/report.rb +2 -2
- data/lib/puppet/type.rb +30 -25
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/cron.rb +2 -2
- data/lib/puppet/type/exec.rb +6 -6
- data/lib/puppet/type/file.rb +5 -15
- data/lib/puppet/type/file/content.rb +1 -1
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/mode.rb +1 -1
- data/lib/puppet/type/file/selcontext.rb +6 -2
- data/lib/puppet/type/file/source.rb +1 -1
- data/lib/puppet/type/mount.rb +1 -1
- data/lib/puppet/type/package.rb +1 -1
- data/lib/puppet/type/schedule.rb +1 -1
- data/lib/puppet/type/scheduled_task.rb +1 -1
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/whit.rb +16 -9
- data/lib/puppet/util.rb +27 -11
- data/lib/puppet/util/adsi.rb +25 -23
- data/lib/puppet/util/autoload.rb +1 -1
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/feature.rb +3 -1
- data/lib/puppet/util/fileparsing.rb +9 -9
- data/lib/puppet/util/filetype.rb +55 -40
- data/lib/puppet/util/instance_loader.rb +5 -5
- data/lib/puppet/util/instrumentation.rb +3 -5
- data/lib/puppet/util/log_paths.rb +1 -3
- data/lib/puppet/util/monkey_patches.rb +34 -8
- data/lib/puppet/util/platform.rb +7 -0
- data/lib/puppet/util/posix.rb +3 -3
- data/lib/puppet/util/provider_features.rb +2 -3
- data/lib/puppet/util/rdoc.rb +4 -3
- data/lib/puppet/util/reference.rb +1 -1
- data/lib/puppet/util/selinux.rb +31 -36
- data/lib/puppet/util/tagging.rb +28 -6
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/error.rb +1 -1
- data/lib/puppet/util/windows/process.rb +3 -3
- data/lib/puppet/util/windows/security.rb +9 -46
- data/lib/puppet/util/windows/sid.rb +96 -0
- data/lib/puppet/util/windows/user.rb +65 -2
- data/lib/puppet/util/zaml.rb +109 -59
- data/lib/puppet/version.rb +18 -0
- data/spec/fixtures/unit/util/filetype/aixtab_output +44 -0
- data/spec/fixtures/unit/util/filetype/suntab_output +9 -0
- data/spec/integration/defaults_spec.rb +26 -7
- data/spec/integration/parser/functions_spec.rb +0 -4
- data/spec/integration/util/file_locking_spec.rb +1 -1
- data/spec/integration/util/windows/security_spec.rb +3 -23
- data/spec/lib/puppet_spec/files.rb +3 -3
- data/spec/shared_contexts/platform.rb +8 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/unit/application/queue_spec.rb +2 -1
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/face/{instrumentation_data.rb → instrumentation_data_spec.rb} +0 -0
- data/spec/unit/face/{instrumentation_listener.rb → instrumentation_listener_spec.rb} +0 -0
- data/spec/unit/face/{instrumentation_probe.rb → instrumentation_probe_spec.rb} +0 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +194 -0
- data/spec/unit/indirector/certificate/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/certificate_request/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/certificate_revocation_list/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/key/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/request_spec.rb +22 -0
- data/spec/unit/network/http/webrick_spec.rb +0 -7
- data/spec/unit/node/environment_spec.rb +8 -8
- data/spec/unit/parser/ast_spec.rb +0 -5
- data/spec/unit/parser/collector_spec.rb +1 -0
- data/spec/unit/parser/files_spec.rb +2 -2
- data/spec/unit/parser/functions/create_resources_spec.rb +3 -4
- data/spec/unit/parser/functions/require_spec.rb +0 -6
- data/spec/unit/parser/functions/shellquote_spec.rb +0 -5
- data/spec/unit/parser/functions/template_spec.rb +6 -1
- data/spec/unit/parser/functions_spec.rb +73 -23
- data/spec/unit/parser/lexer_spec.rb +133 -8
- data/spec/unit/parser/relationship_spec.rb +24 -0
- data/spec/unit/parser/resource_spec.rb +0 -4
- data/spec/unit/parser/scope_spec.rb +2 -2
- data/spec/unit/property_spec.rb +21 -1
- data/spec/unit/provider/exec/posix_spec.rb +7 -6
- data/spec/unit/provider/file/windows_spec.rb +29 -29
- data/spec/unit/provider/group/groupadd_spec.rb +36 -30
- data/spec/unit/provider/group/windows_adsi_spec.rb +2 -2
- data/spec/unit/provider/package/gem_spec.rb +12 -0
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +14 -11
- data/spec/unit/provider/service/redhat_spec.rb +11 -1
- data/spec/unit/provider/service/windows_spec.rb +19 -0
- data/spec/unit/provider/user/ldap_spec.rb +22 -8
- data/spec/unit/provider/user/user_role_add_spec.rb +12 -0
- data/spec/unit/provider/user/useradd_spec.rb +146 -118
- data/spec/unit/provider/user/windows_adsi_spec.rb +24 -2
- data/spec/unit/puppet_spec.rb +10 -0
- data/spec/unit/resource/status_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +73 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +25 -1
- data/spec/unit/ssl/host_spec.rb +73 -27
- data/spec/unit/ssl/key_spec.rb +0 -4
- data/spec/unit/transaction/event_spec.rb +1 -1
- data/spec/unit/type/exec_spec.rb +1 -1
- data/spec/unit/type/file/content_spec.rb +6 -4
- data/spec/unit/type/file/{ctime.rb → ctime_spec.rb} +0 -0
- data/spec/unit/type/file/{mtime.rb → mtime_spec.rb} +0 -0
- data/spec/unit/type/file/{type.rb → type_spec.rb} +0 -0
- data/spec/unit/type/file_spec.rb +2 -12
- data/spec/unit/type/host_spec.rb +14 -5
- data/spec/unit/type/mount_spec.rb +8 -0
- data/spec/unit/type/scheduled_task_spec.rb +2 -2
- data/spec/unit/util/adsi_spec.rb +23 -8
- data/spec/unit/util/command_line_spec.rb +11 -2
- data/spec/unit/util/feature_spec.rb +12 -1
- data/spec/unit/util/filetype_spec.rb +161 -55
- data/spec/unit/util/log_spec.rb +1 -1
- data/spec/unit/util/monkey_patches_spec.rb +7 -0
- data/spec/unit/util/rdoc_spec.rb +8 -2
- data/spec/unit/util/selinux_spec.rb +24 -32
- data/spec/unit/util/windows/sid_spec.rb +100 -0
- data/spec/unit/util/zaml_spec.rb +165 -25
- data/spec/unit/util_spec.rb +3 -9
- data/spec/watchr.rb +2 -6
- data/tasks/rake/gem.rake +4 -2
- data/tasks/rake/sign.rake +1 -1
- data/test/language/parser.rb +1 -0
- data/test/language/scope.rb +0 -5
- data/test/language/snippets.rb +1 -2
- data/test/lib/puppettest.rb +16 -27
- data/test/lib/puppettest/parsertesting.rb +0 -1
- data/test/network/authstore.rb +2 -4
- data/test/puppet/defaults.rb +0 -4
- data/test/util/fileparsing.rb +2 -6
- metadata +1706 -1617
- data/conf/osx/preflight +0 -24
- data/spec/spec.opts +0 -4
- data/spec/unit/file_collection/lookup_spec.rb +0 -45
- data/spec/unit/file_collection_spec.rb +0 -52
- data/tasks/rake/apple.rake +0 -176
- data/test/puppet/errortest.rb +0 -19
data/lib/puppet/parser/files.rb
CHANGED
@@ -82,7 +82,7 @@ module Puppet::Parser::Files
|
|
82
82
|
# nil if the path is empty or absolute (starts with a /).
|
83
83
|
# This method can return nil & anyone calling it needs to handle that.
|
84
84
|
def split_file_path(path)
|
85
|
-
path.split(File::SEPARATOR, 2) unless path == "" or
|
85
|
+
path.split(File::SEPARATOR, 2) unless path == "" or Puppet::Util.absolute_path?(path)
|
86
86
|
end
|
87
87
|
|
88
88
|
end
|
@@ -6,14 +6,25 @@ require 'monitor'
|
|
6
6
|
# is added to a central module that then gets included into the Scope
|
7
7
|
# class.
|
8
8
|
module Puppet::Parser::Functions
|
9
|
-
|
10
|
-
(@functions = Hash.new { |h,k| h[k] = {} }).extend(MonitorMixin)
|
11
|
-
(@modules = {} ).extend(MonitorMixin)
|
9
|
+
Environment = Puppet::Node::Environment
|
12
10
|
|
13
11
|
class << self
|
14
12
|
include Puppet::Util
|
15
13
|
end
|
16
14
|
|
15
|
+
# This is used by tests
|
16
|
+
def self.reset
|
17
|
+
@functions = Hash.new { |h,k| h[k] = {} }.extend(MonitorMixin)
|
18
|
+
@modules = Hash.new.extend(MonitorMixin)
|
19
|
+
|
20
|
+
# Runs a newfunction to create a function for each of the log levels
|
21
|
+
Puppet::Util::Log.levels.each do |level|
|
22
|
+
newfunction(level, :doc => "Log a message on the server at level #{level.to_s}.") do |vals|
|
23
|
+
send(level, vals.join(" "))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
17
28
|
def self.autoloader
|
18
29
|
unless defined?(@autoloader)
|
19
30
|
@autoloader = Puppet::Util::Autoload.new(
|
@@ -26,8 +37,6 @@ module Puppet::Parser::Functions
|
|
26
37
|
@autoloader
|
27
38
|
end
|
28
39
|
|
29
|
-
Environment = Puppet::Node::Environment
|
30
|
-
|
31
40
|
def self.environment_module(env = nil)
|
32
41
|
@modules.synchronize {
|
33
42
|
@modules[ env || Environment.current || Environment.root ] ||= Module.new
|
@@ -36,9 +45,9 @@ module Puppet::Parser::Functions
|
|
36
45
|
|
37
46
|
# Create a new function type.
|
38
47
|
def self.newfunction(name, options = {}, &block)
|
39
|
-
name =
|
48
|
+
name = name.intern
|
40
49
|
|
41
|
-
raise Puppet::DevError, "Function #{name} already defined" if
|
50
|
+
raise Puppet::DevError, "Function #{name} already defined" if get_function(name)
|
42
51
|
|
43
52
|
ftype = options[:type] || :statement
|
44
53
|
|
@@ -51,33 +60,50 @@ module Puppet::Parser::Functions
|
|
51
60
|
|
52
61
|
# Someday we'll support specifying an arity, but for now, nope
|
53
62
|
#functions[name] = {:arity => arity, :type => ftype}
|
54
|
-
|
55
|
-
|
63
|
+
func = {:type => ftype, :name => fname}
|
64
|
+
func[:doc] = options[:doc] if options[:doc]
|
65
|
+
|
66
|
+
add_function(name, func)
|
67
|
+
func
|
56
68
|
end
|
57
69
|
|
58
70
|
# Remove a function added by newfunction
|
59
71
|
def self.rmfunction(name)
|
60
|
-
|
72
|
+
Puppet.deprecation_warning "Puppet::Parser::Functions.rmfunction is deprecated and will be removed in 3.0"
|
73
|
+
name = name.intern
|
61
74
|
|
62
|
-
raise Puppet::DevError, "Function #{name} is not defined" unless
|
75
|
+
raise Puppet::DevError, "Function #{name} is not defined" unless get_function(name)
|
63
76
|
|
64
|
-
functions.
|
77
|
+
@functions.synchronize {
|
78
|
+
@functions[Environment.current].delete(name)
|
79
|
+
# This seems wrong because it won't delete a function defined on root if
|
80
|
+
# the current environment is different
|
81
|
+
#@functions[Environment.root].delete(name)
|
82
|
+
}
|
65
83
|
|
66
84
|
fname = "function_#{name}"
|
85
|
+
# This also only deletes from the module associated with
|
86
|
+
# Environment.current
|
67
87
|
environment_module.send(:remove_method, fname)
|
68
88
|
end
|
69
89
|
|
70
90
|
# Determine if a given name is a function
|
71
91
|
def self.function(name)
|
72
|
-
name =
|
92
|
+
name = name.intern
|
73
93
|
|
94
|
+
func = nil
|
74
95
|
@functions.synchronize do
|
75
|
-
unless
|
76
|
-
autoloader.load(name,Environment.current
|
96
|
+
unless func = get_function(name)
|
97
|
+
autoloader.load(name, Environment.current)
|
98
|
+
func = get_function(name)
|
77
99
|
end
|
78
100
|
end
|
79
101
|
|
80
|
-
|
102
|
+
if func
|
103
|
+
func[:name]
|
104
|
+
else
|
105
|
+
false
|
106
|
+
end
|
81
107
|
end
|
82
108
|
|
83
109
|
def self.functiondocs
|
@@ -85,7 +111,7 @@ module Puppet::Parser::Functions
|
|
85
111
|
|
86
112
|
ret = ""
|
87
113
|
|
88
|
-
|
114
|
+
merged_functions.sort { |a,b| a[0].to_s <=> b[0].to_s }.each do |name, hash|
|
89
115
|
ret += "#{name}\n#{"-" * name.to_s.length}\n"
|
90
116
|
if hash[:doc]
|
91
117
|
ret += Puppet::Util::Docs.scrub(hash[:doc])
|
@@ -100,6 +126,7 @@ module Puppet::Parser::Functions
|
|
100
126
|
end
|
101
127
|
|
102
128
|
def self.functions(env = nil)
|
129
|
+
Puppet.deprecation_warning "Puppet::Parser::Functions.functions is deprecated and will be removed in 3.0"
|
103
130
|
@functions.synchronize {
|
104
131
|
@functions[ env || Environment.current || Environment.root ]
|
105
132
|
}
|
@@ -107,13 +134,32 @@ module Puppet::Parser::Functions
|
|
107
134
|
|
108
135
|
# Determine if a given function returns a value or not.
|
109
136
|
def self.rvalue?(name)
|
110
|
-
(
|
137
|
+
func = get_function(name)
|
138
|
+
func ? func[:type] == :rvalue : false
|
111
139
|
end
|
112
140
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
141
|
+
|
142
|
+
class << self
|
143
|
+
private
|
144
|
+
|
145
|
+
def merged_functions
|
146
|
+
@functions.synchronize {
|
147
|
+
@functions[Environment.root].merge(@functions[Environment.current])
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
def get_function(name)
|
152
|
+
name = name.intern
|
153
|
+
merged_functions[name]
|
154
|
+
end
|
155
|
+
|
156
|
+
def add_function(name, func)
|
157
|
+
name = name.intern
|
158
|
+
@functions.synchronize {
|
159
|
+
@functions[Environment.current][name] = func
|
160
|
+
}
|
117
161
|
end
|
118
162
|
end
|
163
|
+
|
164
|
+
reset # initialize the class instance variables
|
119
165
|
end
|
@@ -18,7 +18,7 @@ Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC
|
|
18
18
|
|
19
19
|
A third, optional parameter may be given, also as a hash:
|
20
20
|
|
21
|
-
$defaults
|
21
|
+
$defaults = {
|
22
22
|
'ensure' => present,
|
23
23
|
'provider' => 'ldap',
|
24
24
|
}
|
@@ -51,8 +51,7 @@ Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC
|
|
51
51
|
# iterate through the resources to create
|
52
52
|
defaults = args[2] || {}
|
53
53
|
args[1].each do |title, params|
|
54
|
-
params = defaults.merge(params)
|
55
|
-
Puppet::Util.symbolizehash!(params)
|
54
|
+
params = Puppet::Util.symbolizehash(defaults.merge(params))
|
56
55
|
raise ArgumentError, 'params should not contain title' if(params[:title])
|
57
56
|
case type_of_resource
|
58
57
|
# JJM The only difference between a type and a define is the call to instantiate_resource
|
@@ -24,12 +24,7 @@
|
|
24
24
|
# other dealings in this Software without prior written authorization
|
25
25
|
# from Thomas Bellman.
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
Safe = 'a-zA-Z0-9@%_+=:,./-' # Safe unquoted
|
30
|
-
Dangerous = '!"`$\\' # Unsafe inside double quotes
|
31
|
-
|
32
|
-
newfunction(:shellquote, :type => :rvalue, :doc => "\
|
27
|
+
Puppet::Parser::Functions.newfunction(:shellquote, :type => :rvalue, :doc => "\
|
33
28
|
Quote and concatenate arguments for use in Bourne shell.
|
34
29
|
|
35
30
|
Each argument is quoted separately, and then all are concatenated
|
@@ -39,27 +34,28 @@ module Puppet::Parser::Functions
|
|
39
34
|
shellquote instead of having to specify each argument
|
40
35
|
individually in the call.
|
41
36
|
") \
|
42
|
-
|
37
|
+
do |args|
|
38
|
+
safe = 'a-zA-Z0-9@%_+=:,./-' # Safe unquoted
|
39
|
+
dangerous = '!"`$\\' # Unsafe inside double quotes
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
r += '"'
|
59
|
-
result << r
|
41
|
+
result = []
|
42
|
+
args.flatten.each do |word|
|
43
|
+
if word.length != 0 and word.count(safe) == word.length
|
44
|
+
result << word
|
45
|
+
elsif word.count(dangerous) == 0
|
46
|
+
result << ('"' + word + '"')
|
47
|
+
elsif word.count("'") == 0
|
48
|
+
result << ("'" + word + "'")
|
49
|
+
else
|
50
|
+
r = '"'
|
51
|
+
word.each_byte do |c|
|
52
|
+
r += "\\" if dangerous.include?(c)
|
53
|
+
r += c.chr
|
60
54
|
end
|
55
|
+
r += '"'
|
56
|
+
result << r
|
61
57
|
end
|
62
|
-
|
63
|
-
return result.join(" ")
|
64
58
|
end
|
59
|
+
|
60
|
+
return result.join(" ")
|
65
61
|
end
|
data/lib/puppet/parser/lexer.rb
CHANGED
@@ -105,6 +105,11 @@ class Puppet::Parser::Lexer
|
|
105
105
|
def sort_tokens
|
106
106
|
@string_tokens.sort! { |a, b| b.string.length <=> a.string.length }
|
107
107
|
end
|
108
|
+
|
109
|
+
# Yield each token name and value in turn.
|
110
|
+
def each
|
111
|
+
@tokens.each {|name, value| yield name, value }
|
112
|
+
end
|
108
113
|
end
|
109
114
|
|
110
115
|
TOKENS = TokenList.new
|
@@ -240,10 +245,30 @@ class Puppet::Parser::Lexer
|
|
240
245
|
end
|
241
246
|
#:startdoc:
|
242
247
|
|
248
|
+
TOKENS.add_token :DOLLAR_VAR_WITH_DASH, %r{\$(?:::)?(?:[-\w]+::)*[-\w]+} do |lexer, value|
|
249
|
+
lexer.warn_if_variable_has_hyphen(value)
|
250
|
+
|
251
|
+
[TOKENS[:VARIABLE], value[1..-1]]
|
252
|
+
end
|
253
|
+
def (TOKENS[:DOLLAR_VAR_WITH_DASH]).acceptable?(context = {})
|
254
|
+
Puppet[:allow_variables_with_dashes]
|
255
|
+
end
|
256
|
+
|
243
257
|
TOKENS.add_token :DOLLAR_VAR, %r{\$(::)?(\w+::)*\w+} do |lexer, value|
|
244
258
|
[TOKENS[:VARIABLE],value[1..-1]]
|
245
259
|
end
|
246
260
|
|
261
|
+
TOKENS.add_token :VARIABLE_WITH_DASH, %r{(?:::)?(?:[-\w]+::)*[-\w]+} do |lexer, value|
|
262
|
+
lexer.warn_if_variable_has_hyphen(value)
|
263
|
+
|
264
|
+
[TOKENS[:VARIABLE], value]
|
265
|
+
end
|
266
|
+
#:stopdoc: # Issue #4161
|
267
|
+
def (TOKENS[:VARIABLE_WITH_DASH]).acceptable?(context={})
|
268
|
+
Puppet[:allow_variables_with_dashes] and TOKENS[:VARIABLE].acceptable?(context)
|
269
|
+
end
|
270
|
+
#:startdoc:
|
271
|
+
|
247
272
|
TOKENS.add_token :VARIABLE, %r{(::)?(\w+::)*\w+}
|
248
273
|
#:stopdoc: # Issue #4161
|
249
274
|
def (TOKENS[:VARIABLE]).acceptable?(context={})
|
@@ -333,7 +358,6 @@ class Puppet::Parser::Lexer
|
|
333
358
|
|
334
359
|
# Find the next token that matches a regex. We look for these first.
|
335
360
|
def find_regex_token
|
336
|
-
@regex += 1
|
337
361
|
best_token = nil
|
338
362
|
best_length = 0
|
339
363
|
|
@@ -354,7 +378,6 @@ class Puppet::Parser::Lexer
|
|
354
378
|
|
355
379
|
# Find the next token, returning the string and the token.
|
356
380
|
def find_token
|
357
|
-
@find += 1
|
358
381
|
shift_token || find_regex_token || find_string_token
|
359
382
|
end
|
360
383
|
|
@@ -367,8 +390,6 @@ class Puppet::Parser::Lexer
|
|
367
390
|
end
|
368
391
|
|
369
392
|
def initialize
|
370
|
-
@find = 0
|
371
|
-
@regex = 0
|
372
393
|
initvars
|
373
394
|
end
|
374
395
|
|
@@ -521,7 +542,7 @@ class Puppet::Parser::Lexer
|
|
521
542
|
|
522
543
|
# we've encountered the start of a string...
|
523
544
|
# slurp in the rest of the string and return it
|
524
|
-
def slurpstring(terminators,escapes=%w{ \\ $ ' " n t s }+["\n"],ignore_invalid_escapes=false)
|
545
|
+
def slurpstring(terminators,escapes=%w{ \\ $ ' " r n t s }+["\n"],ignore_invalid_escapes=false)
|
525
546
|
# we search for the next quote that isn't preceded by a
|
526
547
|
# backslash; the caret is there to match empty strings
|
527
548
|
str = @scanner.scan_until(/([^\\]|^|[^\\])([\\]{2})*[#{terminators}]/) or lex_error "Unclosed quote after '#{last}' in '#{rest}'"
|
@@ -530,6 +551,7 @@ class Puppet::Parser::Lexer
|
|
530
551
|
ch = $1
|
531
552
|
if escapes.include? ch
|
532
553
|
case ch
|
554
|
+
when 'r'; "\r"
|
533
555
|
when 'n'; "\n"
|
534
556
|
when 't'; "\t"
|
535
557
|
when 's'; " "
|
@@ -547,9 +569,15 @@ class Puppet::Parser::Lexer
|
|
547
569
|
def tokenize_interpolated_string(token_type,preamble='')
|
548
570
|
value,terminator = slurpstring('"$')
|
549
571
|
token_queue << [TOKENS[token_type[terminator]],preamble+value]
|
572
|
+
variable_regex = if Puppet[:allow_variables_with_dashes]
|
573
|
+
TOKENS[:VARIABLE_WITH_DASH].regex
|
574
|
+
else
|
575
|
+
TOKENS[:VARIABLE].regex
|
576
|
+
end
|
550
577
|
if terminator != '$' or @scanner.scan(/\{/)
|
551
578
|
token_queue.shift
|
552
|
-
elsif var_name = @scanner.scan(
|
579
|
+
elsif var_name = @scanner.scan(variable_regex)
|
580
|
+
warn_if_variable_has_hyphen(var_name)
|
553
581
|
token_queue << [TOKENS[:VARIABLE],var_name]
|
554
582
|
tokenize_interpolated_string(DQ_continuation_token_types)
|
555
583
|
else
|
@@ -580,4 +608,10 @@ class Puppet::Parser::Lexer
|
|
580
608
|
def commentpush
|
581
609
|
@commentstack.push(['', @line])
|
582
610
|
end
|
611
|
+
|
612
|
+
def warn_if_variable_has_hyphen(var_name)
|
613
|
+
if var_name.include?('-')
|
614
|
+
Puppet.deprecation_warning("Using `-` in variable names is deprecated at #{file || '<string>'}:#{line}. See http://links.puppetlabs.com/puppet-hyphenated-variable-deprecation")
|
615
|
+
end
|
616
|
+
end
|
583
617
|
end
|
@@ -54,7 +54,9 @@ class Puppet::Parser::Relationship
|
|
54
54
|
raise ArgumentError, "Could not find resource '#{target}' for relationship from '#{source}'"
|
55
55
|
end
|
56
56
|
Puppet.debug "Adding relationship from #{source} to #{target} with '#{param_name}'"
|
57
|
-
source_resource[param_name]
|
57
|
+
if source_resource[param_name].class != Array
|
58
|
+
source_resource[param_name] = [source_resource[param_name]].compact
|
59
|
+
end
|
58
60
|
source_resource[param_name] << target
|
59
61
|
end
|
60
62
|
end
|
@@ -6,11 +6,9 @@ require 'puppet/resource'
|
|
6
6
|
class Puppet::Parser::Resource < Puppet::Resource
|
7
7
|
require 'puppet/parser/resource/param'
|
8
8
|
require 'puppet/util/tagging'
|
9
|
-
require 'puppet/file_collection/lookup'
|
10
9
|
require 'puppet/parser/yaml_trimmer'
|
11
10
|
require 'puppet/resource/type_collection_helper'
|
12
11
|
|
13
|
-
include Puppet::FileCollection::Lookup
|
14
12
|
include Puppet::Resource::TypeCollectionHelper
|
15
13
|
|
16
14
|
include Puppet::Util
|
@@ -22,6 +20,7 @@ class Puppet::Parser::Resource < Puppet::Resource
|
|
22
20
|
|
23
21
|
attr_accessor :source, :scope, :collector_id
|
24
22
|
attr_accessor :virtual, :override, :translated, :catalog, :evaluated
|
23
|
+
attr_accessor :file, :line
|
25
24
|
|
26
25
|
attr_reader :exported, :parameters
|
27
26
|
|
@@ -37,7 +36,7 @@ class Puppet::Parser::Resource < Puppet::Resource
|
|
37
36
|
def evaluated?; !!@evaluated; end
|
38
37
|
|
39
38
|
def [](param)
|
40
|
-
param =
|
39
|
+
param = param.intern
|
41
40
|
if param == :title
|
42
41
|
return self.title
|
43
42
|
end
|
@@ -1,20 +1,18 @@
|
|
1
|
-
require 'puppet/file_collection/lookup'
|
2
1
|
require 'puppet/parser/yaml_trimmer'
|
3
2
|
|
4
3
|
# The parameters we stick in Resources.
|
5
4
|
class Puppet::Parser::Resource::Param
|
6
|
-
attr_accessor :name, :value, :source, :add
|
7
5
|
include Puppet::Util
|
8
6
|
include Puppet::Util::Errors
|
9
7
|
include Puppet::Util::MethodHelper
|
10
|
-
|
11
|
-
include Puppet::FileCollection::Lookup
|
12
8
|
include Puppet::Parser::YamlTrimmer
|
13
9
|
|
10
|
+
attr_accessor :name, :value, :source, :add, :file, :line
|
11
|
+
|
14
12
|
def initialize(hash)
|
15
13
|
set_options(hash)
|
16
14
|
requiredopts(:name, :value)
|
17
|
-
@name =
|
15
|
+
@name = @name.intern
|
18
16
|
end
|
19
17
|
|
20
18
|
def line_to_i
|
data/lib/puppet/parser/scope.rb
CHANGED
@@ -458,10 +458,13 @@ class Puppet::Parser::Scope
|
|
458
458
|
method.to_s =~ /^function_(.*)$/
|
459
459
|
super unless $1
|
460
460
|
super unless Puppet::Parser::Functions.function($1)
|
461
|
-
|
462
|
-
#
|
463
|
-
|
464
|
-
|
461
|
+
# In odd circumstances, this might not end up defined by the previous
|
462
|
+
# method, so we might as well be certain.
|
463
|
+
if respond_to? method
|
464
|
+
send(method, *args)
|
465
|
+
else
|
466
|
+
raise Puppet::DevError, "Function #{$1} not defined despite being loaded!"
|
467
|
+
end
|
465
468
|
end
|
466
469
|
|
467
470
|
def resolve_type_and_titles(type, titles)
|
data/lib/puppet/property.rb
CHANGED
@@ -68,9 +68,11 @@ class Puppet::Property < Puppet::Parameter
|
|
68
68
|
|
69
69
|
# Call the provider method.
|
70
70
|
def call_provider(value)
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
method = self.class.name.to_s + "="
|
72
|
+
unless provider.respond_to? method
|
73
|
+
self.fail "The #{provider.class.name} provider can not handle attribute #{self.class.name}"
|
74
|
+
end
|
75
|
+
provider.send(method, value)
|
74
76
|
end
|
75
77
|
|
76
78
|
# Call the dynamically-created method associated with our value, if
|