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
data/lib/puppet/type/augeas.rb
CHANGED
@@ -116,6 +116,10 @@ Puppet::Type.newtype(:augeas) do
|
|
116
116
|
: Sets the node at `PATH` to `NULL`, creating it if needed
|
117
117
|
|
118
118
|
|
119
|
+
`clearm <PATH> <SUB>`
|
120
|
+
: Sets multiple nodes (matching `SUB` relative to `PATH`) to `NULL`
|
121
|
+
|
122
|
+
|
119
123
|
`ins <LABEL> (before|after) <PATH>`
|
120
124
|
: Inserts an empty node `LABEL` either before or after `PATH`.
|
121
125
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# Manage file modes. This state should support different formats
|
2
2
|
# for specification (e.g., u+rwx, or -0011), but for now only supports
|
3
3
|
# specifying the full mode.
|
4
|
+
|
5
|
+
|
4
6
|
module Puppet
|
5
7
|
Puppet::Type.type(:file).newproperty(:mode) do
|
6
8
|
require 'puppet/util/symbolic_file_mode'
|
data/lib/puppet/type/group.rb
CHANGED
@@ -145,5 +145,17 @@ module Puppet
|
|
145
145
|
|
146
146
|
defaultto false
|
147
147
|
end
|
148
|
+
|
149
|
+
# This method has been exposed for puppet to manage users and groups of
|
150
|
+
# files in its settings and should not be considered available outside of
|
151
|
+
# puppet.
|
152
|
+
#
|
153
|
+
# (see Puppet::Settings#service_group_available?)
|
154
|
+
#
|
155
|
+
# @returns [Boolean] if the group exists on the system
|
156
|
+
# @api private
|
157
|
+
def exists?
|
158
|
+
provider.exists?
|
159
|
+
end
|
148
160
|
end
|
149
161
|
end
|
data/lib/puppet/type/mount.rb
CHANGED
@@ -15,7 +15,7 @@ module Puppet
|
|
15
15
|
# call code when sync is called.
|
16
16
|
newproperty(:ensure) do
|
17
17
|
desc "Control what to do with this mount. Set this attribute to
|
18
|
-
`
|
18
|
+
`unmounted` to make sure the filesystem is in the filesystem table
|
19
19
|
but not mounted (if the filesystem is currently mounted, it will be
|
20
20
|
unmounted). Set it to `absent` to unmount (if necessary) and remove
|
21
21
|
the filesystem from the fstab. Set to `mounted` to add it to the
|
@@ -207,7 +207,7 @@ module Puppet
|
|
207
207
|
newvalues(:true, :false)
|
208
208
|
defaultto do
|
209
209
|
case Facter.value(:operatingsystem)
|
210
|
-
when "FreeBSD", "Darwin", "AIX"
|
210
|
+
when "FreeBSD", "Darwin", "AIX", "DragonFly"
|
211
211
|
false
|
212
212
|
else
|
213
213
|
true
|
data/lib/puppet/type/notify.rb
CHANGED
data/lib/puppet/type/router.rb
CHANGED
data/lib/puppet/type/service.rb
CHANGED
@@ -27,7 +27,9 @@ module Puppet
|
|
27
27
|
end
|
28
28
|
|
29
29
|
newproperty(:key) do
|
30
|
-
desc "The key itself; generally a long string of hex
|
30
|
+
desc "The public key itself; generally a long string of hex characters. The key attribute
|
31
|
+
may not contain whitespace: Omit key headers (e.g. 'ssh-rsa') and key identifiers
|
32
|
+
(e.g. 'joe@joescomputer.local') found in the public key file."
|
31
33
|
|
32
34
|
validate do |value|
|
33
35
|
raise Puppet::Error, "Key must not contain whitespace: #{value}" if value =~ /\s/
|
data/lib/puppet/type/user.rb
CHANGED
@@ -355,7 +355,14 @@ module Puppet
|
|
355
355
|
autos
|
356
356
|
end
|
357
357
|
|
358
|
-
#
|
358
|
+
# This method has been exposed for puppet to manage users and groups of
|
359
|
+
# files in its settings and should not be considered available outside of
|
360
|
+
# puppet.
|
361
|
+
#
|
362
|
+
# (see Puppet::Settings#service_user_available?)
|
363
|
+
#
|
364
|
+
# @returns [Boolean] if the user exists on the system
|
365
|
+
# @api private
|
359
366
|
def exists?
|
360
367
|
provider.exists?
|
361
368
|
end
|
data/lib/puppet/util.rb
CHANGED
@@ -185,6 +185,13 @@ module Util
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
188
|
+
# Resolve a path for an executable to the absolute path. This tries to behave
|
189
|
+
# in the same manner as the unix `which` command and uses the `PATH`
|
190
|
+
# environment variable.
|
191
|
+
#
|
192
|
+
# @api public
|
193
|
+
# @param bin [String] the name of the executable to find.
|
194
|
+
# @return [String] the absolute path to the found executable.
|
188
195
|
def which(bin)
|
189
196
|
if absolute_path?(bin)
|
190
197
|
return bin if FileTest.file? bin and FileTest.executable? bin
|
@@ -489,6 +496,7 @@ module Util
|
|
489
496
|
# Executes a block of code, wrapped with some special exception handling. Causes the ruby interpreter to
|
490
497
|
# exit if the block throws an exception.
|
491
498
|
#
|
499
|
+
# @api public
|
492
500
|
# @param [String] message a message to log if the block fails
|
493
501
|
# @param [Integer] code the exit code that the ruby interpreter should return if the block fails
|
494
502
|
# @yield
|
data/lib/puppet/util/autoload.rb
CHANGED
@@ -19,13 +19,6 @@ class Puppet::Util::Autoload
|
|
19
19
|
@gem_source ||= Puppet::Util::RubyGems::Source.new
|
20
20
|
end
|
21
21
|
|
22
|
-
# List all loaded files.
|
23
|
-
def list_loaded
|
24
|
-
loaded.keys.sort { |a,b| a[0] <=> b[0] }.collect do |path, hash|
|
25
|
-
"#{path}: #{hash[:file]}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
22
|
# Has a given path been loaded? This is used for testing whether a
|
30
23
|
# changed file should be loaded or just ignored. This is only
|
31
24
|
# used in network/client/master, when downloading plugins, to
|
@@ -205,7 +198,7 @@ class Puppet::Util::Autoload
|
|
205
198
|
end
|
206
199
|
|
207
200
|
def load(name, env=nil)
|
208
|
-
self.class.load_file(
|
201
|
+
self.class.load_file(expand(name), env)
|
209
202
|
end
|
210
203
|
|
211
204
|
# Load all instances that we can. This uses require, rather than load,
|
@@ -215,14 +208,18 @@ class Puppet::Util::Autoload
|
|
215
208
|
end
|
216
209
|
|
217
210
|
def loaded?(name)
|
218
|
-
self.class.loaded?(
|
211
|
+
self.class.loaded?(expand(name))
|
219
212
|
end
|
220
213
|
|
221
214
|
def changed?(name)
|
222
|
-
self.class.changed?(
|
215
|
+
self.class.changed?(expand(name))
|
223
216
|
end
|
224
217
|
|
225
218
|
def files_to_load
|
226
219
|
self.class.files_to_load(@path)
|
227
220
|
end
|
221
|
+
|
222
|
+
def expand(name)
|
223
|
+
::File.join(@path, name.to_s)
|
224
|
+
end
|
228
225
|
end
|
data/lib/puppet/util/classgen.rb
CHANGED
@@ -3,51 +3,66 @@ module Puppet
|
|
3
3
|
class SubclassAlreadyDefined < Error; end
|
4
4
|
end
|
5
5
|
|
6
|
+
# This is a utility module for generating classes.
|
7
|
+
# @api public
|
8
|
+
#
|
6
9
|
module Puppet::Util::ClassGen
|
7
10
|
include Puppet::Util::MethodHelper
|
8
11
|
include Puppet::Util
|
9
12
|
|
10
|
-
# Create a new
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
13
|
+
# Create a new class.
|
14
|
+
# @param name [String] the name of the generated class
|
15
|
+
# @param options [Hash] a hash of options
|
16
|
+
# @option options [Array<Class>] :array if specified, the generated class is appended to this array
|
17
|
+
# @option options [Hash<{String => Object}>] :attributes a hash that is applied to the generated class
|
18
|
+
# by calling setter methods corresponding to this hash's keys/value pairs. This is done before the given
|
19
|
+
# block is evaluated.
|
20
|
+
# @option options [Proc] :block a block to evaluate in the context of the class (this block can be provided
|
21
|
+
# this way, or as a normal yield block).
|
22
|
+
# @option options [String] :constant (name with first letter capitalized) what to set the constant that references
|
23
|
+
# the generated class to.
|
24
|
+
# @option options [Hash] :hash a hash of existing classes that this class is appended to (name => class).
|
25
|
+
# This hash must be specified if the `:overwrite` option is set to `true`.
|
26
|
+
# @option options [Boolean] :overwrite whether an overwrite of an existing class should be allowed (requires also
|
27
|
+
# defining the `:hash` with existing classes as the test is based on the content of this hash).
|
28
|
+
# @option options [Class] :parent (self) the parent class of the generated class.
|
29
|
+
# @option options [String] ('') :prefix the constant prefix to prepend to the constant name referencing the
|
30
|
+
# generated class.
|
31
|
+
# @return [Class] the generated class
|
32
|
+
#
|
27
33
|
def genclass(name, options = {}, &block)
|
28
34
|
genthing(name, Class, options, block)
|
29
35
|
end
|
30
36
|
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
37
|
+
# Creates a new module.
|
38
|
+
# @param name [String] the name of the generated module
|
39
|
+
# @param optinos [Hash] hash with options
|
40
|
+
# @option options [Array<Class>] :array if specified, the generated class is appended to this array
|
41
|
+
# @option options [Hash<{String => Object}>] :attributes a hash that is applied to the generated class
|
42
|
+
# by calling setter methods corresponding to this hash's keys/value pairs. This is done before the given
|
43
|
+
# block is evaluated.
|
44
|
+
# @option options [Proc] :block a block to evaluate in the context of the class (this block can be provided
|
45
|
+
# this way, or as a normal yield block).
|
46
|
+
# @option options [String] :constant (name with first letter capitalized) what to set the constant that references
|
47
|
+
# the generated class to.
|
48
|
+
# @option options [Hash] :hash a hash of existing classes that this class is appended to (name => class).
|
49
|
+
# This hash must be specified if the `:overwrite` option is set to `true`.
|
50
|
+
# @option options [Boolean] :overwrite whether an overwrite of an existing class should be allowed (requires also
|
51
|
+
# defining the `:hash` with existing classes as the test is based on the content of this hash).
|
45
52
|
# the capitalized name is appended and the result is set as the constant.
|
53
|
+
# @option options [String] ('') :prefix the constant prefix to prepend to the constant name referencing the
|
54
|
+
# generated class.
|
55
|
+
# @return [Module] the generated Module
|
46
56
|
def genmodule(name, options = {}, &block)
|
47
57
|
genthing(name, Module, options, block)
|
48
58
|
end
|
49
59
|
|
50
|
-
#
|
60
|
+
# Removes an existing class.
|
61
|
+
# @param name [String] the name of the class to remove
|
62
|
+
# @param options [Hash] options
|
63
|
+
# @option options [Hash] :hash a hash of existing classes from which the class to be removed is also removed
|
64
|
+
# @return [Boolean] whether the class was removed or not
|
65
|
+
#
|
51
66
|
def rmclass(name, options)
|
52
67
|
options = symbolize_options(options)
|
53
68
|
const = genconst_string(name, options)
|
@@ -68,7 +83,8 @@ module Puppet::Util::ClassGen
|
|
68
83
|
|
69
84
|
private
|
70
85
|
|
71
|
-
#
|
86
|
+
# Generates the constant to create or remove.
|
87
|
+
# @api private
|
72
88
|
def genconst_string(name, options)
|
73
89
|
unless const = options[:constant]
|
74
90
|
prefix = options[:prefix] || ""
|
@@ -80,6 +96,7 @@ module Puppet::Util::ClassGen
|
|
80
96
|
|
81
97
|
# This does the actual work of creating our class or module. It's just a
|
82
98
|
# slightly abstract version of genclass.
|
99
|
+
# @api private
|
83
100
|
def genthing(name, type, options, block)
|
84
101
|
options = symbolize_options(options)
|
85
102
|
|
@@ -128,6 +145,8 @@ module Puppet::Util::ClassGen
|
|
128
145
|
# of which class hierarchy it polls for nested namespaces
|
129
146
|
#
|
130
147
|
# See http://redmine.ruby-lang.org/issues/show/1915
|
148
|
+
# @api private
|
149
|
+
#
|
131
150
|
def is_constant_defined?(const)
|
132
151
|
if ::RUBY_VERSION =~ /1.9/
|
133
152
|
const_defined?(const, false)
|
@@ -137,6 +156,8 @@ module Puppet::Util::ClassGen
|
|
137
156
|
end
|
138
157
|
|
139
158
|
# Handle the setting and/or removing of the associated constant.
|
159
|
+
# @api private
|
160
|
+
#
|
140
161
|
def handleclassconst(klass, name, options)
|
141
162
|
const = genconst_string(name, options)
|
142
163
|
|
@@ -155,6 +176,8 @@ module Puppet::Util::ClassGen
|
|
155
176
|
end
|
156
177
|
|
157
178
|
# Perform the initializations on the class.
|
179
|
+
# @api private
|
180
|
+
#
|
158
181
|
def initclass(klass, options)
|
159
182
|
klass.initvars if klass.respond_to? :initvars
|
160
183
|
|
@@ -178,11 +201,13 @@ module Puppet::Util::ClassGen
|
|
178
201
|
end
|
179
202
|
|
180
203
|
# Convert our name to a constant.
|
204
|
+
# @api private
|
181
205
|
def name2const(name)
|
182
206
|
name.to_s.capitalize
|
183
207
|
end
|
184
208
|
|
185
209
|
# Store the class in the appropriate places.
|
210
|
+
# @api private
|
186
211
|
def storeclass(klass, klassname, options)
|
187
212
|
if hash = options[:hash]
|
188
213
|
if hash.include? klassname and ! options[:overwrite]
|
@@ -10,125 +10,168 @@ if not defined? ::Bundler
|
|
10
10
|
end
|
11
11
|
|
12
12
|
require 'puppet'
|
13
|
+
require 'puppet/util'
|
13
14
|
require "puppet/util/plugins"
|
14
15
|
require "puppet/util/rubygems"
|
15
16
|
|
16
17
|
module Puppet
|
17
18
|
module Util
|
19
|
+
# This is the main entry point for all puppet applications / faces; it
|
20
|
+
# is basically where the bootstrapping process / lifecycle of an app
|
21
|
+
# begins.
|
18
22
|
class CommandLine
|
23
|
+
OPTION_OR_MANIFEST_FILE = /^-|\.pp$|\.rb$/
|
19
24
|
|
25
|
+
# @param zero [String] the name of the executable
|
26
|
+
# @param argv [Array<String>] the arguments passed on the command line
|
27
|
+
# @param stdin [IO] (unused)
|
20
28
|
def initialize(zero = $0, argv = ARGV, stdin = STDIN)
|
21
|
-
@
|
22
|
-
@argv
|
23
|
-
@stdin = stdin
|
24
|
-
|
25
|
-
@subcommand_name, @args = subcommand_and_args(@zero, @argv, @stdin)
|
29
|
+
@command = File.basename(zero, '.rb')
|
30
|
+
@argv = argv
|
26
31
|
Puppet::Plugins.on_commandline_initialization(:command_line_object => self)
|
27
32
|
end
|
28
33
|
|
29
|
-
|
30
|
-
|
34
|
+
# @return [String] name of the subcommand is being executed
|
35
|
+
# @api public
|
36
|
+
def subcommand_name
|
37
|
+
return @command if @command != 'puppet'
|
31
38
|
|
32
|
-
|
33
|
-
|
39
|
+
if @argv.first =~ OPTION_OR_MANIFEST_FILE
|
40
|
+
nil
|
41
|
+
else
|
42
|
+
@argv.first
|
43
|
+
end
|
34
44
|
end
|
35
45
|
|
46
|
+
# @return [Array<String>] the command line arguments being passed to the subcommand
|
47
|
+
# @api public
|
48
|
+
def args
|
49
|
+
return @argv if @command != 'puppet'
|
50
|
+
|
51
|
+
if subcommand_name.nil?
|
52
|
+
@argv
|
53
|
+
else
|
54
|
+
@argv[1..-1]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# @api private
|
59
|
+
# @deprecated
|
36
60
|
def self.available_subcommands
|
37
|
-
|
38
|
-
|
39
|
-
# module path when loading, and we don't want to allow apps / faces to
|
40
|
-
# load from there. Once that is resolved, this should be replaced.
|
41
|
-
# --cprice 2012-03-06
|
42
|
-
#
|
43
|
-
# But we do want to load from rubygems --hightower
|
44
|
-
search_path = Puppet::Util::RubyGems::Source.new.directories + $LOAD_PATH
|
45
|
-
absolute_appdirs = search_path.uniq.collect do |x|
|
46
|
-
File.join(x,'puppet','application')
|
47
|
-
end.select{ |x| File.directory?(x) }
|
48
|
-
absolute_appdirs.inject([]) do |commands, dir|
|
49
|
-
commands + Dir[File.join(dir, '*.rb')].map{|fn| File.basename(fn, '.rb')}
|
50
|
-
end.uniq
|
61
|
+
Puppet.deprecation_warning('Puppet::Util::CommandLine.available_subcommands is deprecated; please use Puppet::Application.available_application_names instead.')
|
62
|
+
Puppet::Application.available_application_names
|
51
63
|
end
|
64
|
+
|
52
65
|
# available_subcommands was previously an instance method, not a class
|
53
66
|
# method, and we have an unknown number of user-implemented applications
|
54
67
|
# that depend on that behaviour. Forwarding allows us to preserve a
|
55
68
|
# backward compatible API. --daniel 2011-04-11
|
69
|
+
# @api private
|
70
|
+
# @deprecated
|
56
71
|
def available_subcommands
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def require_application(application)
|
61
|
-
require File.join(appdir, application)
|
72
|
+
Puppet.deprecation_warning('Puppet::Util::CommandLine#available_subcommands is deprecated; please use Puppet::Application.available_application_names instead.')
|
73
|
+
Puppet::Application.available_application_names
|
62
74
|
end
|
63
75
|
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
76
|
+
# Run the puppet subcommand. If the subcommand is determined to be an
|
77
|
+
# external executable, this method will never return and the current
|
78
|
+
# process will be replaced via {Kernel#exec}.
|
79
|
+
#
|
80
|
+
# @return [void]
|
67
81
|
def execute
|
68
|
-
# Build up our settings - we don't need that until after version check.
|
69
82
|
Puppet::Util.exit_on_fail("intialize global default settings") do
|
70
|
-
Puppet.
|
83
|
+
Puppet.initialize_settings(args)
|
71
84
|
end
|
72
85
|
|
73
|
-
|
74
|
-
|
75
|
-
# libdir is... which means that we can now look for our available
|
76
|
-
# applications / subcommands / faces.
|
86
|
+
find_subcommand.run
|
87
|
+
end
|
77
88
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
# Longer-term, use the autoloader. See comments in
|
83
|
-
# #available_subcommands method above. --cprice 2012-03-06
|
84
|
-
app = Puppet::Application.find(subcommand_name).new(self)
|
85
|
-
Puppet::Plugins.on_application_initialization(:application_object => self)
|
89
|
+
# @api private
|
90
|
+
def external_subcommand
|
91
|
+
Puppet::Util.which("puppet-#{subcommand_name}")
|
92
|
+
end
|
86
93
|
|
87
|
-
|
88
|
-
elsif ! execute_external_subcommand then
|
89
|
-
unless subcommand_name.nil? then
|
90
|
-
puts "Error: Unknown Puppet subcommand '#{subcommand_name}'"
|
91
|
-
end
|
94
|
+
private
|
92
95
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
def find_subcommand
|
97
|
+
if subcommand_name.nil?
|
98
|
+
NilSubcommand.new(self)
|
99
|
+
elsif Puppet::Application.available_application_names.include?(subcommand_name)
|
100
|
+
ApplicationSubcommand.new(subcommand_name, self)
|
101
|
+
elsif path_to_subcommand = external_subcommand
|
102
|
+
ExternalSubcommand.new(path_to_subcommand, self)
|
103
|
+
else
|
104
|
+
UnknownSubcommand.new(subcommand_name, self)
|
99
105
|
end
|
100
106
|
end
|
101
107
|
|
102
|
-
|
103
|
-
|
108
|
+
# @api private
|
109
|
+
class ApplicationSubcommand
|
110
|
+
def initialize(subcommand_name, command_line)
|
111
|
+
@subcommand_name = subcommand_name
|
112
|
+
@command_line = command_line
|
113
|
+
end
|
114
|
+
|
115
|
+
def run
|
116
|
+
# For most applications, we want to be able to load code from the modulepath,
|
117
|
+
# such as apply, describe, resource, and faces.
|
118
|
+
# For agent, we only want to load pluginsync'ed code from libdir.
|
119
|
+
# For master, we shouldn't ever be loading per-enviroment code into the master's
|
120
|
+
# ruby process, but that requires fixing (#17210, #12173, #8750). So for now
|
121
|
+
# we try to restrict to only code that can be autoloaded from the node's
|
122
|
+
# environment.
|
123
|
+
if @subcommand_name != 'master' and @subcommand_name != 'agent'
|
124
|
+
Puppet::Node::Environment.new.each_plugin_directory do |dir|
|
125
|
+
$LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
|
126
|
+
end
|
127
|
+
end
|
104
128
|
|
105
|
-
|
106
|
-
|
107
|
-
return false unless path_to_subcommand
|
129
|
+
app = Puppet::Application.find(@subcommand_name).new(@command_line)
|
130
|
+
Puppet::Plugins.on_application_initialization(:application_object => @command_line)
|
108
131
|
|
109
|
-
|
132
|
+
app.run
|
133
|
+
end
|
110
134
|
end
|
111
135
|
|
112
|
-
private
|
136
|
+
# @api private
|
137
|
+
class ExternalSubcommand
|
138
|
+
def initialize(path_to_subcommand, command_line)
|
139
|
+
@path_to_subcommand = path_to_subcommand
|
140
|
+
@command_line = command_line
|
141
|
+
end
|
142
|
+
|
143
|
+
def run
|
144
|
+
Kernel.exec(@path_to_subcommand, *@command_line.args)
|
145
|
+
end
|
146
|
+
end
|
113
147
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
[argv.first, argv[1..-1]]
|
148
|
+
# @api private
|
149
|
+
class NilSubcommand
|
150
|
+
def initialize(command_line)
|
151
|
+
@command_line = command_line
|
152
|
+
end
|
153
|
+
|
154
|
+
def run
|
155
|
+
if @command_line.args.include? "--version" or @command_line.args.include? "-V"
|
156
|
+
puts Puppet.version
|
157
|
+
else
|
158
|
+
puts "See 'puppet help' for help on available puppet subcommands"
|
126
159
|
end
|
127
|
-
else
|
128
|
-
[zero, argv]
|
129
160
|
end
|
130
161
|
end
|
131
162
|
|
163
|
+
# @api private
|
164
|
+
class UnknownSubcommand < NilSubcommand
|
165
|
+
def initialize(subcommand_name, command_line)
|
166
|
+
@subcommand_name = subcommand_name
|
167
|
+
super(command_line)
|
168
|
+
end
|
169
|
+
|
170
|
+
def run
|
171
|
+
puts "Error: Unknown Puppet subcommand '#{@subcommand_name}'"
|
172
|
+
super
|
173
|
+
end
|
174
|
+
end
|
132
175
|
end
|
133
176
|
end
|
134
177
|
end
|