puppet 3.0.2 → 3.1.0.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/Gemfile +13 -11
- data/README.md +9 -7
- data/README_DEVELOPER.md +21 -30
- data/bin/extlookup2hiera +0 -0
- data/conf/auth.conf +42 -26
- data/conf/fileserver.conf +41 -0
- data/conf/tagmail.conf +16 -0
- data/examples/hiera/modules/data/manifests/common.pp +2 -1
- data/examples/hiera/modules/ntp/manifests/config.pp +4 -3
- data/examples/hiera/modules/ntp/manifests/data.pp +2 -1
- data/examples/hiera/modules/users/manifests/common.pp +2 -1
- data/examples/hiera/modules/users/manifests/dc1.pp +2 -1
- data/examples/hiera/modules/users/manifests/development.pp +2 -1
- data/examples/hiera/site.pp +1 -1
- data/ext/debian/fileserver.conf +39 -15
- data/ext/envpuppet +2 -0
- data/ext/gentoo/puppet/fileserver.conf +41 -12
- data/ext/ips/puppet-agent +1 -6
- data/ext/ips/puppetagent.xml +0 -4
- data/ext/osx/postflight.erb +109 -0
- data/ext/project_data.yaml +2 -2
- data/ext/redhat/fileserver.conf +41 -12
- data/ext/redhat/puppet.spec.erb +8 -13
- data/install.rb +2 -5
- data/lib/puppet.rb +30 -13
- data/lib/puppet/application.rb +34 -16
- data/lib/puppet/application/agent.rb +4 -4
- data/lib/puppet/application/master.rb +25 -5
- data/lib/puppet/defaults.rb +11 -7
- data/lib/puppet/dsl.rb +7 -3
- data/lib/puppet/dsl/actions.rb +283 -0
- data/lib/puppet/dsl/blank_slate.rb +55 -0
- data/lib/puppet/dsl/context.rb +393 -0
- data/lib/puppet/dsl/parser.rb +57 -0
- data/lib/puppet/dsl/resource_decorator.rb +56 -0
- data/lib/puppet/dsl/resource_reference.rb +95 -0
- data/lib/puppet/dsl/type_reference.rb +102 -0
- data/lib/puppet/error.rb +1 -1
- data/lib/puppet/face/help.rb +2 -4
- data/lib/puppet/face/man.rb +8 -2
- data/lib/puppet/feature/pson.rb +1 -3
- data/lib/puppet/indirector/catalog/active_record.rb +3 -0
- data/lib/puppet/indirector/catalog/compiler.rb +1 -2
- data/lib/puppet/indirector/catalog/queue.rb +4 -0
- data/lib/puppet/indirector/catalog/static_compiler.rb +30 -0
- data/lib/puppet/indirector/catalog/store_configs.rb +3 -0
- data/lib/puppet/indirector/certificate_request/rest.rb +1 -0
- data/lib/puppet/indirector/certificate_revocation_list/rest.rb +1 -0
- data/lib/puppet/indirector/certificate_status/file.rb +4 -0
- data/lib/puppet/indirector/certificate_status/rest.rb +1 -0
- data/lib/puppet/indirector/facts/active_record.rb +3 -0
- data/lib/puppet/indirector/facts/couch.rb +3 -0
- data/lib/puppet/indirector/facts/inventory_active_record.rb +4 -0
- data/lib/puppet/indirector/facts/store_configs.rb +3 -0
- data/lib/puppet/indirector/file_metadata/rest.rb +2 -0
- data/lib/puppet/indirector/instrumentation_data/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_data/rest.rb +3 -0
- data/lib/puppet/indirector/instrumentation_listener/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_listener/rest.rb +3 -0
- data/lib/puppet/indirector/instrumentation_probe/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_probe/rest.rb +3 -0
- data/lib/puppet/indirector/node/active_record.rb +3 -0
- data/lib/puppet/indirector/node/rest.rb +2 -2
- data/lib/puppet/indirector/node/store_configs.rb +3 -0
- data/lib/puppet/indirector/node/write_only_yaml.rb +32 -0
- data/lib/puppet/indirector/queue.rb +0 -1
- data/lib/puppet/indirector/request.rb +1 -2
- data/lib/puppet/indirector/resource/active_record.rb +4 -0
- data/lib/puppet/indirector/resource/ral.rb +3 -0
- data/lib/puppet/indirector/resource/rest.rb +3 -0
- data/lib/puppet/indirector/resource/store_configs.rb +3 -0
- data/lib/puppet/indirector/run/local.rb +3 -0
- data/lib/puppet/indirector/ssl_file.rb +16 -14
- data/lib/puppet/indirector/status/local.rb +3 -0
- data/lib/puppet/indirector/status/rest.rb +4 -0
- data/lib/puppet/interface.rb +78 -3
- data/lib/puppet/interface/action.rb +39 -3
- data/lib/puppet/interface/action_builder.rb +74 -1
- data/lib/puppet/interface/action_manager.rb +33 -3
- data/lib/puppet/interface/documentation.rb +116 -5
- data/lib/puppet/interface/face_collection.rb +6 -7
- data/lib/puppet/interface/option.rb +10 -1
- data/lib/puppet/interface/option_builder.rb +29 -1
- data/lib/puppet/interface/option_manager.rb +21 -6
- data/lib/puppet/metatype/manager.rb +47 -9
- data/lib/puppet/module_tool.rb +0 -1
- data/lib/puppet/network/formats.rb +0 -2
- data/lib/puppet/node.rb +2 -3
- data/lib/puppet/node/environment.rb +14 -1
- data/lib/puppet/parameter.rb +309 -44
- data/lib/puppet/parameter/package_options.rb +5 -0
- data/lib/puppet/parameter/path.rb +26 -3
- data/lib/puppet/parameter/value.rb +30 -6
- data/lib/puppet/parameter/value_collection.rb +82 -20
- data/lib/puppet/parser.rb +3 -0
- data/lib/puppet/parser/ast/definition.rb +2 -5
- data/lib/puppet/parser/ast/hostclass.rb +2 -3
- data/lib/puppet/parser/ast/node.rb +2 -5
- data/lib/puppet/parser/ast/resourceparam.rb +1 -1
- data/lib/puppet/parser/compiler.rb +10 -0
- data/lib/puppet/parser/functions.rb +111 -7
- data/lib/puppet/parser/functions/create_resources.rb +23 -2
- data/lib/puppet/parser/functions/defined.rb +1 -1
- data/lib/puppet/parser/functions/extlookup.rb +2 -1
- data/lib/puppet/parser/functions/fail.rb +1 -1
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/fqdn_rand.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +1 -1
- data/lib/puppet/parser/functions/hiera.rb +1 -1
- data/lib/puppet/parser/functions/hiera_array.rb +1 -1
- data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/include.rb +1 -1
- data/lib/puppet/parser/functions/inline_template.rb +1 -1
- data/lib/puppet/parser/functions/md5.rb +1 -1
- data/lib/puppet/parser/functions/realize.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +54 -57
- data/lib/puppet/parser/functions/require.rb +1 -0
- data/lib/puppet/parser/functions/search.rb +1 -1
- data/lib/puppet/parser/functions/sha1.rb +1 -1
- data/lib/puppet/parser/functions/shellquote.rb +1 -1
- data/lib/puppet/parser/functions/split.rb +1 -2
- data/lib/puppet/parser/functions/sprintf.rb +7 -10
- data/lib/puppet/parser/functions/tag.rb +1 -1
- data/lib/puppet/parser/functions/tagged.rb +1 -1
- data/lib/puppet/parser/functions/template.rb +1 -1
- data/lib/puppet/parser/functions/versioncmp.rb +1 -5
- data/lib/puppet/parser/parser_support.rb +11 -27
- data/lib/puppet/parser/scope.rb +48 -4
- data/lib/puppet/parser/type_loader.rb +31 -7
- data/lib/puppet/property.rb +304 -70
- data/lib/puppet/property/ensure.rb +14 -1
- data/lib/puppet/property/keyvalue.rb +17 -8
- data/lib/puppet/property/list.rb +3 -0
- data/lib/puppet/property/ordered_list.rb +7 -0
- data/lib/puppet/provider.rb +275 -53
- data/lib/puppet/provider/augeas/augeas.rb +17 -3
- data/lib/puppet/provider/confiner.rb +30 -1
- data/lib/puppet/provider/group/pw.rb +2 -2
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkgin.rb +2 -0
- data/lib/puppet/provider/service/bsd.rb +1 -1
- data/lib/puppet/provider/service/freebsd.rb +10 -6
- data/lib/puppet/provider/service/init.rb +1 -1
- data/lib/puppet/provider/service/service.rb +1 -1
- data/lib/puppet/provider/user/pw.rb +2 -2
- data/lib/puppet/provider/user/useradd.rb +2 -3
- data/lib/puppet/reference/configuration.rb +6 -0
- data/lib/puppet/reports.rb +44 -4
- data/lib/puppet/reports/tagmail.rb +1 -1
- data/lib/puppet/resource.rb +38 -25
- data/lib/puppet/resource/type.rb +14 -6
- data/lib/puppet/settings.rb +66 -142
- data/lib/puppet/settings/config_file.rb +99 -0
- data/lib/puppet/settings/file_setting.rb +92 -24
- data/lib/puppet/settings/value_translator.rb +15 -0
- data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
- data/lib/puppet/test/test_helper.rb +8 -3
- data/lib/puppet/transaction.rb +1 -2
- data/lib/puppet/transaction/report.rb +122 -13
- data/lib/puppet/type.rb +763 -150
- data/lib/puppet/type/augeas.rb +4 -0
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/group.rb +1 -1
- data/lib/puppet/type/file/mode.rb +2 -0
- data/lib/puppet/type/file/selcontext.rb +1 -0
- data/lib/puppet/type/group.rb +12 -0
- data/lib/puppet/type/mount.rb +2 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/router.rb +1 -1
- data/lib/puppet/type/service.rb +1 -0
- data/lib/puppet/type/ssh_authorized_key.rb +3 -1
- data/lib/puppet/type/user.rb +8 -1
- data/lib/puppet/util.rb +8 -0
- data/lib/puppet/util/autoload.rb +7 -10
- data/lib/puppet/util/classgen.rb +58 -33
- data/lib/puppet/util/command_line.rb +120 -77
- data/lib/puppet/util/constant_inflector.rb +2 -0
- data/lib/puppet/util/execution.rb +63 -33
- data/lib/puppet/util/filetype.rb +1 -1
- data/lib/puppet/util/manifest_filetype_helper.rb +22 -0
- data/lib/puppet/util/methodhelper.rb +19 -0
- data/lib/puppet/util/monkey_patches.rb +46 -0
- data/lib/puppet/util/plugins.rb +2 -2
- data/lib/puppet/util/provider_features.rb +24 -8
- data/lib/puppet/util/rubygems.rb +8 -1
- data/lib/puppet/util/zaml.rb +1 -1
- data/lib/puppet/version.rb +74 -3
- data/spec/integration/application/apply_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +1 -0
- data/spec/integration/dsl/classes_spec.rb +191 -0
- data/spec/integration/dsl/defaults_spec.rb +38 -0
- data/spec/integration/dsl/definitions_spec.rb +73 -0
- data/spec/integration/dsl/functions_spec.rb +95 -0
- data/spec/integration/dsl/nodes_spec.rb +96 -0
- data/spec/integration/dsl/params_spec.rb +146 -0
- data/spec/integration/dsl/relationships_spec.rb +46 -0
- data/spec/integration/dsl/resources_spec.rb +202 -0
- data/spec/integration/dsl/type_loading_spec.rb +64 -0
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
- data/spec/integration/network/formats_spec.rb +32 -45
- data/spec/integration/parser/collector_spec.rb +105 -25
- data/spec/integration/parser/scope_spec.rb +64 -1
- data/spec/integration/resource/catalog_spec.rb +2 -4
- data/spec/integration/type/package_spec.rb +1 -1
- data/spec/lib/matchers/catalog.rb +50 -0
- data/spec/lib/puppet_spec/compiler.rb +11 -0
- data/spec/lib/puppet_spec/dsl.rb +29 -0
- data/spec/spec_helper.rb +17 -3
- data/spec/unit/application/agent_spec.rb +0 -1
- data/spec/unit/application/apply_spec.rb +1 -1
- data/spec/unit/application/face_base_spec.rb +11 -4
- data/spec/unit/application/indirection_base_spec.rb +4 -8
- data/spec/unit/application/kick_spec.rb +5 -2
- data/spec/unit/application/master_spec.rb +0 -6
- data/spec/unit/application_spec.rb +38 -14
- data/spec/unit/dsl/actions_spec.rb +402 -0
- data/spec/unit/dsl/blank_slate_spec.rb +27 -0
- data/spec/unit/dsl/context_spec.rb +678 -0
- data/spec/unit/dsl/parser_spec.rb +56 -0
- data/spec/unit/dsl/resource_decorator_spec.rb +94 -0
- data/spec/unit/dsl/resource_reference_spec.rb +150 -0
- data/spec/unit/dsl/type_reference_spec.rb +164 -0
- data/spec/unit/face/help_spec.rb +5 -7
- data/spec/unit/indirector/certificate_request/rest_spec.rb +4 -0
- data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +4 -0
- data/spec/unit/indirector/certificate_status/rest_spec.rb +4 -0
- data/spec/unit/indirector/file_metadata/rest_spec.rb +5 -0
- data/spec/unit/indirector/hiera_spec.rb +3 -1
- data/spec/unit/indirector/queue_spec.rb +1 -7
- data/spec/unit/indirector/ssl_file_spec.rb +66 -39
- data/spec/unit/module_spec.rb +1 -1
- data/spec/unit/network/authstore_spec.rb +22 -1
- data/spec/unit/network/formats_spec.rb +1 -1
- data/spec/unit/node/environment_spec.rb +13 -0
- data/spec/unit/parser/collector_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +26 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +12 -1
- data/spec/unit/parser/functions/extlookup_spec.rb +4 -4
- data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_spec.rb +1 -1
- data/spec/unit/parser/functions/regsubst_spec.rb +4 -4
- data/spec/unit/parser/functions/split_spec.rb +4 -4
- data/spec/unit/parser/functions/sprintf_spec.rb +2 -2
- data/spec/unit/parser/functions/versioncmp_spec.rb +4 -4
- data/spec/unit/parser/functions_spec.rb +51 -1
- data/spec/unit/parser/parser_spec.rb +0 -14
- data/spec/unit/parser/type_loader_spec.rb +15 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +31 -0
- data/spec/unit/provider/package/apt_spec.rb +0 -2
- data/spec/unit/provider/package/pip_spec.rb +12 -2
- data/spec/unit/provider/service/freebsd_spec.rb +8 -0
- data/spec/unit/provider/service/gentoo_spec.rb +20 -20
- data/spec/unit/provider/service/openrc_spec.rb +20 -20
- data/spec/unit/provider/service/src_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_spec.rb +0 -8
- data/spec/unit/provider/service/windows_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +2 -9
- data/spec/unit/relationship_spec.rb +2 -2
- data/spec/unit/resource/catalog_spec.rb +2 -2
- data/spec/unit/resource/type_spec.rb +49 -25
- data/spec/unit/resource_spec.rb +34 -2
- data/spec/unit/settings/config_file_spec.rb +100 -0
- data/spec/unit/settings/file_setting_spec.rb +87 -84
- data/spec/unit/settings/value_translator_spec.rb +77 -0
- data/spec/unit/settings_spec.rb +96 -29
- data/spec/unit/type/file/ensure_spec.rb +75 -36
- data/spec/unit/type/file_spec.rb +0 -68
- data/spec/unit/type/group_spec.rb +10 -0
- data/spec/unit/util/autoload_spec.rb +6 -0
- data/spec/unit/util/command_line_spec.rb +54 -62
- data/spec/unit/util/manifest_filetype_helper_spec.rb +29 -0
- data/spec/unit/util/metric_spec.rb +0 -9
- data/spec/unit/util/posix_spec.rb +0 -4
- data/spec/unit/util/rdoc_spec.rb +0 -12
- data/spec/unit/util/zaml_spec.rb +188 -130
- data/spec/unit/version_spec.rb +42 -0
- metadata +123 -90
- data/README_HIERA.md +0 -148
- data/conf/epm.list +0 -8
- data/conf/namespaceauth.conf +0 -20
- data/conf/puppet-queue.conf +0 -10
- data/examples/allatonce +0 -13
- data/examples/assignments +0 -11
- data/examples/components +0 -73
- data/examples/etc/init.d/sleeper +0 -70
- data/examples/etc/otherfile +0 -0
- data/examples/etc/puppet/fileserver.conf +0 -13
- data/examples/etc/puppet/namespaceauth.conf +0 -20
- data/examples/etc/puppet/puppet.conf +0 -10
- data/examples/etc/puppet/tagmail.conf +0 -1
- data/examples/execs +0 -16
- data/examples/file.bl +0 -11
- data/examples/filedefaults +0 -10
- data/examples/fileparsing +0 -116
- data/examples/filerecursion +0 -15
- data/examples/functions +0 -3
- data/examples/groups +0 -7
- data/examples/head +0 -30
- data/examples/importing +0 -8
- data/examples/mac_dscl.pp +0 -28
- data/examples/mac_dscl_revert.pp +0 -26
- data/examples/mac_pkgdmg.pp +0 -7
- data/examples/modules/sample_module.pp +0 -10
- data/examples/modules/sample_module/lib/puppet/parser/functions/hostname_to_dn.rb +0 -36
- data/examples/modules/sample_module/manifests/init.pp +0 -12
- data/examples/modules/sample_module/templates/sample.erb +0 -5
- data/examples/nodes +0 -20
- data/examples/one +0 -8
- data/examples/relationships +0 -34
- data/examples/selectors +0 -28
- data/examples/simpletests +0 -11
- data/examples/svncommit +0 -13
- data/lib/puppet/dsl/resource_api.rb +0 -120
- data/lib/puppet/dsl/resource_type_api.rb +0 -34
- data/spec/integration/parser/ruby_manifest_spec.rb +0 -127
- data/spec/unit/dsl/resource_api_spec.rb +0 -180
- data/spec/unit/dsl/resource_type_api_spec.rb +0 -53
@@ -6,16 +6,31 @@ module Puppet
|
|
6
6
|
class ExecutionFailure < Puppet::Error
|
7
7
|
end
|
8
8
|
|
9
|
+
# This module defines methods for execution of system commands. It is intented for inclusion
|
10
|
+
# in classes that needs to execute system commands.
|
11
|
+
# @api public
|
9
12
|
module Util::Execution
|
10
13
|
|
11
|
-
#
|
12
|
-
# pipe object.
|
14
|
+
# Executes the provided command with STDIN connected to a pipe, yielding the
|
15
|
+
# pipe object.
|
16
|
+
# This allows data to be fed to the subprocess.
|
13
17
|
#
|
14
18
|
# The command can be a simple string, which is executed as-is, or an Array,
|
15
|
-
# which is treated as a set of command arguments to pass through
|
19
|
+
# which is treated as a set of command arguments to pass through.
|
16
20
|
#
|
17
21
|
# In all cases this is passed directly to the shell, and STDOUT and STDERR
|
18
22
|
# are connected together during execution.
|
23
|
+
# @param command [String, Array<String>] the command to execute as one string, or as parts in an array.
|
24
|
+
# the parts of the array are joined with one separating space between each entry when converting to
|
25
|
+
# the command line string to execute.
|
26
|
+
# @param failonfail [Boolean] (true) if the execution should fail with Exception on failure or not.
|
27
|
+
# @yield [pipe] to a block executing a subprocess
|
28
|
+
# @yieldparam pipe [IO] the opened pipe
|
29
|
+
# @yieldreturn [String] the output to return
|
30
|
+
# @raise [ExecutionFailure] if the executed chiled process did not exit with status == 0 and `failonfail` is
|
31
|
+
# `true`.
|
32
|
+
# @return [String] a string with the output from the subprocess executed by the given block
|
33
|
+
#
|
19
34
|
def self.execpipe(command, failonfail = true)
|
20
35
|
if respond_to? :debug
|
21
36
|
debug "Executing '#{command}'"
|
@@ -44,6 +59,9 @@ module Util::Execution
|
|
44
59
|
output
|
45
60
|
end
|
46
61
|
|
62
|
+
# Wraps execution of {execute} with mapping of exception to given exception (and output as argument).
|
63
|
+
# @raise [exception] under same conditions as {execute}, but raises the given `exception` with the output as argument
|
64
|
+
# @return (see execute)
|
47
65
|
def self.execfail(command, exception)
|
48
66
|
output = execute(command)
|
49
67
|
return output
|
@@ -51,35 +69,37 @@ module Util::Execution
|
|
51
69
|
raise exception, output
|
52
70
|
end
|
53
71
|
|
72
|
+
# Default empty options for {execute}
|
73
|
+
NoOptionsSpecified = {}
|
54
74
|
|
55
|
-
#
|
75
|
+
# Executes the desired command, and return the status and output.
|
56
76
|
# def execute(command, options)
|
57
|
-
#
|
77
|
+
# @param command [Array<String>, String] the command to execute. If it is
|
58
78
|
# an Array the first element should be the executable and the rest of the
|
59
79
|
# elements should be the individual arguments to that executable.
|
60
|
-
# [
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
80
|
+
# @param options [Hash] a Hash of options
|
81
|
+
# @option options [Boolean] :failonfail if this value is set to true, then this method will raise an error if the
|
82
|
+
# command is not executed successfully.
|
83
|
+
# @option options [?] :uid (nil) the user id of the user that the process should be run as
|
84
|
+
# @option options [?] :gid (nil) the group id of the group that the process should be run as
|
85
|
+
# @option options [Boolean] :combine sets whether or not to combine stdout/stderr in the output
|
86
|
+
# @option options [String] :stdinfile (nil) sets a file that can be used for stdin. Passing a string for stdin is not currently
|
87
|
+
# supported.
|
88
|
+
# @option options [Boolean] :squelch (true) if true, ignore stdout / stderr completely.
|
89
|
+
# @option options [Boolean] :override_locale (true) by default (and if this option is set to true), we will temporarily override
|
90
|
+
# the user/system locale to "C" (via environment variables LANG and LC_*) while we are executing the command.
|
91
|
+
# This ensures that the output of the command will be formatted consistently, making it predictable for parsing.
|
92
|
+
# Passing in a value of false for this option will allow the command to be executed using the user/system locale.
|
93
|
+
# @option options [Hash<{String => String}>] :custom_environment ({}) a hash of key/value pairs to set as environment variables for the duration
|
94
|
+
# of the command.
|
95
|
+
# @return [String] output as specified by options
|
96
|
+
# @note Unfortunately, the default behavior for failonfail and combine (since
|
97
|
+
# 0.22.4 and 0.24.7, respectively) depend on whether options are specified
|
98
|
+
# or not. If specified, then failonfail and combine default to false (even
|
99
|
+
# when the options specified are neither failonfail nor combine). If no
|
100
|
+
# options are specified, then failonfail and combine default to true.
|
101
|
+
# @comment See commits efe9a833c and d32d7f30
|
75
102
|
#
|
76
|
-
# Unfortunately, the default behavior for failonfail and combine (since
|
77
|
-
# 0.22.4 and 0.24.7, respectively) depend on whether options are specified
|
78
|
-
# or not. If specified, then failonfail and combine default to false (even
|
79
|
-
# when the options specified are neither failonfail nor combine). If no
|
80
|
-
# options are specified, then failonfail and combine default to true. See
|
81
|
-
# commits efe9a833c and d32d7f30
|
82
|
-
NoOptionsSpecified = {}
|
83
103
|
def self.execute(command, options = NoOptionsSpecified)
|
84
104
|
# specifying these here rather than in the method signature to allow callers to pass in a partial
|
85
105
|
# set of overrides without affecting the default values for options that they don't pass in
|
@@ -147,9 +167,10 @@ module Util::Execution
|
|
147
167
|
output
|
148
168
|
end
|
149
169
|
|
150
|
-
#
|
151
|
-
# it's not in the PATH... so this is slightly safer than just using
|
152
|
-
#
|
170
|
+
# Returns the path to the ruby executable (available via Config object, even if
|
171
|
+
# it's not in the PATH... so this is slightly safer than just using Puppet::Util.which)
|
172
|
+
# @return [String] the path to the Ruby executable
|
173
|
+
#
|
153
174
|
def self.ruby_path()
|
154
175
|
File.join(RbConfig::CONFIG['bindir'],
|
155
176
|
RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']).
|
@@ -162,7 +183,10 @@ module Util::Execution
|
|
162
183
|
end
|
163
184
|
|
164
185
|
|
165
|
-
#
|
186
|
+
# This is private method.
|
187
|
+
# @comment see call to private_class_method after method definition
|
188
|
+
# @api private
|
189
|
+
#
|
166
190
|
def self.execute_posix(command, options, stdin, stdout, stderr)
|
167
191
|
child_pid = Puppet::Util.safe_posix_fork(stdin, stdout, stderr) do
|
168
192
|
|
@@ -208,7 +232,10 @@ module Util::Execution
|
|
208
232
|
private_class_method :execute_posix
|
209
233
|
|
210
234
|
|
211
|
-
#
|
235
|
+
# This is private method.
|
236
|
+
# @comment see call to private_class_method after method definition
|
237
|
+
# @api private
|
238
|
+
#
|
212
239
|
def self.execute_windows(command, options, stdin, stdout, stderr)
|
213
240
|
command = command.map do |part|
|
214
241
|
part.include?(' ') ? %Q["#{part.gsub(/"/, '\"')}"] : part
|
@@ -222,7 +249,10 @@ module Util::Execution
|
|
222
249
|
private_class_method :execute_windows
|
223
250
|
|
224
251
|
|
225
|
-
#
|
252
|
+
# This is private method.
|
253
|
+
# @comment see call to private_class_method after method definition
|
254
|
+
# @api private
|
255
|
+
#
|
226
256
|
def self.wait_for_output(stdout)
|
227
257
|
# Make sure the file's actually been written. This is basically a race
|
228
258
|
# condition, and is probably a horrible way to handle it, but, well, oh
|
data/lib/puppet/util/filetype.rb
CHANGED
@@ -181,7 +181,7 @@ class Puppet::Util::FileType
|
|
181
181
|
|
182
182
|
# Remove a specific @path's cron tab.
|
183
183
|
def remove
|
184
|
-
if %w{Darwin FreeBSD}.include?(Facter.value("operatingsystem"))
|
184
|
+
if %w{Darwin FreeBSD DragonFly}.include?(Facter.value("operatingsystem"))
|
185
185
|
%x{/bin/echo yes | #{cmdbase} -r 2>/dev/null}
|
186
186
|
else
|
187
187
|
%x{#{cmdbase} -r 2>/dev/null}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Puppet
|
2
|
+
module Util
|
3
|
+
|
4
|
+
##
|
5
|
+
# Module that gathers helper functions for determining type of manifests.
|
6
|
+
##
|
7
|
+
module ManifestFiletypeHelper
|
8
|
+
extend self
|
9
|
+
|
10
|
+
def is_ruby_filename?(file)
|
11
|
+
!!(file =~ /\.rb\z/i)
|
12
|
+
end
|
13
|
+
|
14
|
+
def is_puppet_filename?(file)
|
15
|
+
!!(file =~ /\.pp\z/i)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# Where we store helper methods related to, um, methods.
|
2
2
|
module Puppet::Util::MethodHelper
|
3
|
+
extend self
|
4
|
+
|
3
5
|
def requiredopts(*names)
|
4
6
|
names.each do |name|
|
5
7
|
devfail("#{name} is a required option for #{self.class}") if self.send(name).nil?
|
@@ -29,4 +31,21 @@ module Puppet::Util::MethodHelper
|
|
29
31
|
hash
|
30
32
|
end
|
31
33
|
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Helper to validate options. Example:
|
37
|
+
#
|
38
|
+
# validate_options [:arguments, :inherits], options
|
39
|
+
#
|
40
|
+
# It expects list of valid options and a hash to validate as a last
|
41
|
+
# argument.
|
42
|
+
##
|
43
|
+
def validate_options(allow, options = {})
|
44
|
+
options.each do |k, _|
|
45
|
+
unless Array(allow).include? k
|
46
|
+
raise ArgumentError, "unrecognized option #{k}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
32
51
|
end
|
@@ -310,3 +310,49 @@ if RUBY_VERSION == '1.8.5'
|
|
310
310
|
module_function :move
|
311
311
|
end
|
312
312
|
end
|
313
|
+
|
314
|
+
# Ruby 1.8.6 doesn't have it either
|
315
|
+
# From https://github.com/puppetlabs/hiera/pull/47/files:
|
316
|
+
# In ruby 1.8.5 Dir does not have mktmpdir defined, so this monkey patches
|
317
|
+
# Dir to include the 1.8.7 definition of that method if it isn't already defined.
|
318
|
+
# Method definition borrowed from ruby-1.8.7-p357/lib/ruby/1.8/tmpdir.rb
|
319
|
+
unless Dir.respond_to?(:mktmpdir)
|
320
|
+
def Dir.mktmpdir(prefix_suffix=nil, tmpdir=nil)
|
321
|
+
case prefix_suffix
|
322
|
+
when nil
|
323
|
+
prefix = "d"
|
324
|
+
suffix = ""
|
325
|
+
when String
|
326
|
+
prefix = prefix_suffix
|
327
|
+
suffix = ""
|
328
|
+
when Array
|
329
|
+
prefix = prefix_suffix[0]
|
330
|
+
suffix = prefix_suffix[1]
|
331
|
+
else
|
332
|
+
raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
|
333
|
+
end
|
334
|
+
tmpdir ||= Dir.tmpdir
|
335
|
+
t = Time.now.strftime("%Y%m%d")
|
336
|
+
n = nil
|
337
|
+
begin
|
338
|
+
path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
339
|
+
path << "-#{n}" if n
|
340
|
+
path << suffix
|
341
|
+
Dir.mkdir(path, 0700)
|
342
|
+
rescue Errno::EEXIST
|
343
|
+
n ||= 0
|
344
|
+
n += 1
|
345
|
+
retry
|
346
|
+
end
|
347
|
+
|
348
|
+
if block_given?
|
349
|
+
begin
|
350
|
+
yield path
|
351
|
+
ensure
|
352
|
+
FileUtils.remove_entry_secure path
|
353
|
+
end
|
354
|
+
else
|
355
|
+
path
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
data/lib/puppet/util/plugins.rb
CHANGED
@@ -25,8 +25,8 @@
|
|
25
25
|
# Note that the instance variables are local to this Puppet::Plugin (and so may be used
|
26
26
|
# for maintaining state, etc.) but the plugin system does not provide any thread safety
|
27
27
|
# assurances, so they may not be adequate for some complex use cases.
|
28
|
-
|
29
|
-
|
28
|
+
|
29
|
+
|
30
30
|
module Puppet
|
31
31
|
class Plugins
|
32
32
|
Paths = [] # Where we might find plugin initialization code
|
@@ -2,10 +2,15 @@
|
|
2
2
|
require 'puppet/util/methodhelper'
|
3
3
|
require 'puppet/util/docs'
|
4
4
|
require 'puppet/util'
|
5
|
+
# This module models provider features and handles checking whether the features
|
6
|
+
# are present.
|
7
|
+
# @todo Unclear what is api and what is private in this module.
|
8
|
+
#
|
5
9
|
module Puppet::Util::ProviderFeatures
|
6
10
|
include Puppet::Util::Docs
|
7
|
-
#
|
11
|
+
# This class models provider features and handles checking whether the features
|
8
12
|
# are present.
|
13
|
+
# @todo Unclear what is api and what is private in this class
|
9
14
|
class ProviderFeature
|
10
15
|
include Puppet::Util
|
11
16
|
include Puppet::Util::MethodHelper
|
@@ -13,6 +18,9 @@ module Puppet::Util::ProviderFeatures
|
|
13
18
|
attr_accessor :name, :docs, :methods
|
14
19
|
|
15
20
|
# Are all of the requirements met?
|
21
|
+
# Requirements are checked by checking if feature predicate methods have been generated - see {#methods_available?}.
|
22
|
+
# @param obj [Object, Class] the object or class to check if requirements are met
|
23
|
+
# @return [Boolean] whether all requirements for this feature are met or not.
|
16
24
|
def available?(obj)
|
17
25
|
if self.methods
|
18
26
|
return !!methods_available?(obj)
|
@@ -33,7 +41,9 @@ module Puppet::Util::ProviderFeatures
|
|
33
41
|
|
34
42
|
private
|
35
43
|
|
36
|
-
#
|
44
|
+
# Checks whether all feature predicate methods are available.
|
45
|
+
# @param obj [Object, Class] the object or class to check if feature predicates are available or not.
|
46
|
+
# @return [Boolean] Returns whether all of the required methods are available or not in the given object.
|
37
47
|
def methods_available?(obj)
|
38
48
|
methods.each do |m|
|
39
49
|
if obj.is_a?(Class)
|
@@ -46,9 +56,11 @@ module Puppet::Util::ProviderFeatures
|
|
46
56
|
end
|
47
57
|
end
|
48
58
|
|
49
|
-
#
|
59
|
+
# Defines one feature.
|
60
|
+
# At a minimum, a feature requires a name
|
50
61
|
# and docs, and at this point they should also specify a list of methods
|
51
62
|
# required to determine if the feature is present.
|
63
|
+
# @todo How methods that determine if the feature is present are specified.
|
52
64
|
def feature(name, docs, hash = {})
|
53
65
|
@features ||= {}
|
54
66
|
raise(Puppet::DevError, "Feature #{name} is already defined") if @features.include?(name)
|
@@ -64,7 +76,7 @@ module Puppet::Util::ProviderFeatures
|
|
64
76
|
end
|
65
77
|
end
|
66
78
|
|
67
|
-
#
|
79
|
+
# @return [String] Returns a string with documentation covering all features.
|
68
80
|
def featuredocs
|
69
81
|
str = ""
|
70
82
|
@features ||= {}
|
@@ -94,14 +106,14 @@ module Puppet::Util::ProviderFeatures
|
|
94
106
|
str
|
95
107
|
end
|
96
108
|
|
97
|
-
#
|
109
|
+
# @return [Array<String>] Returns a list of features.
|
98
110
|
def features
|
99
111
|
@features ||= {}
|
100
112
|
@features.keys
|
101
113
|
end
|
102
114
|
|
103
|
-
#
|
104
|
-
#
|
115
|
+
# Generates a module that sets up the boolean predicate methods to test for given features.
|
116
|
+
#
|
105
117
|
def feature_module
|
106
118
|
unless defined?(@feature_module)
|
107
119
|
@features ||= {}
|
@@ -158,7 +170,11 @@ module Puppet::Util::ProviderFeatures
|
|
158
170
|
@feature_module
|
159
171
|
end
|
160
172
|
|
161
|
-
#
|
173
|
+
# @return [ProviderFeature] Returns a provider feature instance by name.
|
174
|
+
# @param name [String] the name of the feature to return
|
175
|
+
# @note Should only be used for testing.
|
176
|
+
# @api private
|
177
|
+
#
|
162
178
|
def provider_feature(name)
|
163
179
|
return nil unless defined?(@features)
|
164
180
|
|
data/lib/puppet/util/rubygems.rb
CHANGED
@@ -2,9 +2,12 @@ require 'puppet/util'
|
|
2
2
|
|
3
3
|
module Puppet::Util::RubyGems
|
4
4
|
|
5
|
-
#Base/factory class for rubygems source
|
5
|
+
# Base/factory class for rubygems source. These classes introspec into
|
6
|
+
# rubygems to in order to list where the rubygems system will look for files
|
7
|
+
# to load.
|
6
8
|
class Source
|
7
9
|
class << self
|
10
|
+
# @api private
|
8
11
|
def has_rubygems?
|
9
12
|
# Gems are not actually available when Bundler is loaded, even
|
10
13
|
# though the Gem constant is defined. This is because Bundler
|
@@ -15,6 +18,7 @@ module Puppet::Util::RubyGems
|
|
15
18
|
defined? ::Gem and not defined? ::Bundler
|
16
19
|
end
|
17
20
|
|
21
|
+
# @api private
|
18
22
|
def source
|
19
23
|
if has_rubygems?
|
20
24
|
Gem::Specification.respond_to?(:latest_specs) ? Gems18Source : OldGemsSource
|
@@ -32,6 +36,7 @@ module Puppet::Util::RubyGems
|
|
32
36
|
end
|
33
37
|
|
34
38
|
# For RubyGems >= 1.8.0
|
39
|
+
# @api private
|
35
40
|
class Gems18Source < Source
|
36
41
|
def directories
|
37
42
|
Gem::Specification.latest_specs.collect do |spec|
|
@@ -41,12 +46,14 @@ module Puppet::Util::RubyGems
|
|
41
46
|
end
|
42
47
|
|
43
48
|
# RubyGems < 1.8.0
|
49
|
+
# @api private
|
44
50
|
class OldGemsSource < Source
|
45
51
|
def directories
|
46
52
|
@paths ||= Gem.latest_load_paths
|
47
53
|
end
|
48
54
|
end
|
49
55
|
|
56
|
+
# @api private
|
50
57
|
class NoGemsSource < Source
|
51
58
|
def directories
|
52
59
|
[]
|
data/lib/puppet/util/zaml.rb
CHANGED
@@ -376,7 +376,7 @@ class Time
|
|
376
376
|
def to_zaml(z)
|
377
377
|
# 2008-12-06 10:06:51.373758 -07:00
|
378
378
|
ms = ("%0.6f" % (usec * 1e-6))[2..-1]
|
379
|
-
offset = "%+0.2i:%0.2i" % [utc_offset / 3600, (utc_offset / 60) % 60]
|
379
|
+
offset = "%+0.2i:%0.2i" % [utc_offset / 3600.0, (utc_offset / 60) % 60]
|
380
380
|
z.emit(self.strftime("%Y-%m-%d %H:%M:%S.#{ms} #{offset}"))
|
381
381
|
end
|
382
382
|
end
|
data/lib/puppet/version.rb
CHANGED
@@ -4,15 +4,86 @@
|
|
4
4
|
#
|
5
5
|
# The version is programatically settable because we want to allow the
|
6
6
|
# Raketasks and such to set the version based on the output of `git describe`
|
7
|
-
|
7
|
+
|
8
|
+
|
8
9
|
module Puppet
|
9
|
-
PUPPETVERSION = '3.0
|
10
|
+
PUPPETVERSION = '3.1.0-rc1'
|
10
11
|
|
12
|
+
##
|
13
|
+
# version is a public API method intended to always provide a fast and
|
14
|
+
# lightweight way to determine the version of Puppet.
|
15
|
+
#
|
16
|
+
# The intent is that software external to Puppet be able to determine the
|
17
|
+
# Puppet version with no side-effects. The expected use is:
|
18
|
+
#
|
19
|
+
# require 'puppet/version'
|
20
|
+
# version = Puppet.version
|
21
|
+
#
|
22
|
+
# This function has the following ordering precedence. This precedence list
|
23
|
+
# is designed to facilitate automated packaging tasks by simply writing to
|
24
|
+
# the VERSION file in the same directory as this source file.
|
25
|
+
#
|
26
|
+
# 1. If a version has been explicitly assigned using the Puppet.version=
|
27
|
+
# method, return that version.
|
28
|
+
# 2. If there is a VERSION file, read the contents, trim any
|
29
|
+
# trailing whitespace, and return that version string.
|
30
|
+
# 3. Return the value of the Puppet::PUPPETVERSION constant hard-coded into
|
31
|
+
# the source code.
|
32
|
+
#
|
33
|
+
# If there is no VERSION file, the method must return the version string of
|
34
|
+
# the nearest parent version that is an officially released version. That is
|
35
|
+
# to say, if a branch named 3.1.x contains 25 patches on top of the most
|
36
|
+
# recent official release of 3.1.1, then the version method must return the
|
37
|
+
# string "3.1.1" if no "VERSION" file is present.
|
38
|
+
#
|
39
|
+
# By design the version identifier is _not_ intended to vary during the life
|
40
|
+
# a process. There is no guarantee provided that writing to the VERSION file
|
41
|
+
# while a Puppet process is running will cause the version string to be
|
42
|
+
# updated. On the contrary, the contents of the VERSION are cached to reduce
|
43
|
+
# filesystem accesses.
|
44
|
+
#
|
45
|
+
# The VERSION file is intended to be used by package maintainers who may be
|
46
|
+
# applying patches or otherwise changing the software version in a manner
|
47
|
+
# that warrants a different software version identifier. The VERSION file is
|
48
|
+
# intended to be managed and owned by the release process and packaging
|
49
|
+
# related tasks, and as such should not reside in version control. The
|
50
|
+
# PUPPETVERSION constant is intended to be version controlled in history.
|
51
|
+
#
|
52
|
+
# Ideally, this behavior will allow package maintainers to precisely specify
|
53
|
+
# the version of the software they're packaging as in the following example:
|
54
|
+
#
|
55
|
+
# $ git describe --match "3.0.*" > lib/puppet/VERSION
|
56
|
+
# $ ruby -r puppet -e 'puts Puppet.version'
|
57
|
+
# 3.0.1-260-g9ca4e54
|
58
|
+
#
|
59
|
+
# @api public
|
60
|
+
#
|
61
|
+
# @return [String] containing the puppet version, e.g. "3.0.1"
|
11
62
|
def self.version
|
12
|
-
|
63
|
+
version_file = File.join(File.dirname(__FILE__), 'VERSION')
|
64
|
+
return @puppet_version if @puppet_version
|
65
|
+
if version = read_version_file(version_file)
|
66
|
+
@puppet_version = version
|
67
|
+
end
|
68
|
+
@puppet_version ||= PUPPETVERSION
|
13
69
|
end
|
14
70
|
|
15
71
|
def self.version=(version)
|
16
72
|
@puppet_version = version
|
17
73
|
end
|
74
|
+
|
75
|
+
##
|
76
|
+
# read_version_file reads the content of the "VERSION" file that lives in the
|
77
|
+
# same directory as this source code file.
|
78
|
+
#
|
79
|
+
# @api private
|
80
|
+
#
|
81
|
+
# @return [String] for example: "1.6.14-6-gea42046" or nil if the VERSION
|
82
|
+
# file does not exist.
|
83
|
+
def self.read_version_file(path)
|
84
|
+
if File.exists?(path)
|
85
|
+
File.read(path).chomp
|
86
|
+
end
|
87
|
+
end
|
88
|
+
private_class_method :read_version_file
|
18
89
|
end
|