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
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'puppet/dsl/blank_slate'
|
2
|
+
require 'puppet/dsl/resource_reference'
|
3
|
+
|
4
|
+
module Puppet
|
5
|
+
# @since 3.1
|
6
|
+
# @status EXPERIMENTAL
|
7
|
+
module DSL
|
8
|
+
# Thin decorator layer for accessing attributes of array/hash-like objects.
|
9
|
+
# @see Puppet::DSL::Context#create_resource Context#create_resource for examples of usage
|
10
|
+
#
|
11
|
+
class ResourceDecorator < BlankSlate
|
12
|
+
|
13
|
+
# Initializes new object.
|
14
|
+
# @overload initialize(resource, {|r| block})
|
15
|
+
# @param resource [#[], #[]=] any object responding to these methods
|
16
|
+
# @yieldparam r [ResourceDecorator] the `self` when evaluating the ruby block
|
17
|
+
# @param block [ruby] the Ruby DSL statements to evaluate.
|
18
|
+
#
|
19
|
+
def initialize(resource, &block)
|
20
|
+
@resource = resource
|
21
|
+
block.call self
|
22
|
+
end
|
23
|
+
|
24
|
+
# A proxy method allowing direct access to resource parameters instead of
|
25
|
+
# having to use `#[]` or `#[]=`
|
26
|
+
#
|
27
|
+
# After a first call it creates a cached version of the created access method.
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# # allows using this
|
31
|
+
# r.title = "I am a resource"
|
32
|
+
# # instead of this
|
33
|
+
# r[:title] = "I am a resource"
|
34
|
+
#
|
35
|
+
def method_missing(name, *args)
|
36
|
+
if name.to_s =~ /\A(.*)=\z/
|
37
|
+
define_singleton_method name do |*a|
|
38
|
+
value = a.first
|
39
|
+
value = value.reference if value.is_a? ::Puppet::DSL::ResourceReference
|
40
|
+
value = value.to_s unless value.is_a? ::Puppet::Resource
|
41
|
+
@resource[$1.to_sym] = value
|
42
|
+
end
|
43
|
+
|
44
|
+
self.__send__ name, *args
|
45
|
+
else
|
46
|
+
define_singleton_method name do
|
47
|
+
@resource[name]
|
48
|
+
end
|
49
|
+
|
50
|
+
self.__send__ name, *args
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'puppet/dsl/resource_decorator'
|
2
|
+
require 'puppet/dsl/parser'
|
3
|
+
require 'puppet/parser/resource/param'
|
4
|
+
require 'puppet/parser/resource'
|
5
|
+
|
6
|
+
module Puppet
|
7
|
+
# @since 3.1
|
8
|
+
# @status EXPERIMENTAL
|
9
|
+
module DSL
|
10
|
+
# ResourceReference is a thin wrapper for assigning references to the
|
11
|
+
# resources and creating overrides.
|
12
|
+
#
|
13
|
+
class ResourceReference
|
14
|
+
# @return [Puppet::Parser::Resource] referenced resource
|
15
|
+
#
|
16
|
+
attr_reader :resource
|
17
|
+
|
18
|
+
# Creates a new ResourceReference.
|
19
|
+
# @param typeref [String] the name of the type
|
20
|
+
# @param name [String] the name of a resource instance of this type
|
21
|
+
# @raise [ArgumentError] if the referenced _typename_/_name_ is not found
|
22
|
+
#
|
23
|
+
def initialize(typeref, name)
|
24
|
+
@resource = Puppet::DSL::Parser.current_scope.findresource typeref.type_name, name
|
25
|
+
raise ArgumentError, "resource `#{typeref.type_name}[#{name}]' not found" unless @resource
|
26
|
+
end
|
27
|
+
|
28
|
+
# This method is used by ResourceDecorator for stringifying references.
|
29
|
+
# @return [String] the resource in string form
|
30
|
+
#
|
31
|
+
def reference
|
32
|
+
@resource.to_s
|
33
|
+
end
|
34
|
+
alias to_s reference
|
35
|
+
|
36
|
+
# Creates overrides for a resource and returns the resulting overrides as a Hash.
|
37
|
+
# @overload override(options)
|
38
|
+
# @overload override(options, {|r| block}
|
39
|
+
# @overload override({|r| block})
|
40
|
+
# @param options [Hash] parameter name to value mapping of values to override.
|
41
|
+
# @param r [ResourceReference] the `self` when evaluating the Ruby DSL block.
|
42
|
+
# @param block [ruby] Ruby DSL statements to be executed.
|
43
|
+
# @return [Hash] a hash with a mapping from parameter name to value with overridden name/values.
|
44
|
+
# @raise [ArgumentError] when no block or options have been supplied.
|
45
|
+
#
|
46
|
+
def override(options = {}, &block)
|
47
|
+
raise ArgumentError, "no block or options supplied" if options == {} and block.nil?
|
48
|
+
|
49
|
+
Puppet::DSL::ResourceDecorator.new(options, &block) unless block.nil?
|
50
|
+
scope = Puppet::DSL::Parser.current_scope
|
51
|
+
|
52
|
+
# for compatibility with Puppet parser
|
53
|
+
params = options.map do |k, v|
|
54
|
+
Puppet::Parser::Resource::Param.new :name => k, :value => v, :source => scope.source
|
55
|
+
end
|
56
|
+
|
57
|
+
resource = Puppet::Parser::Resource.new @resource.type, @resource.name,
|
58
|
+
:parameters => params, :scope => scope,
|
59
|
+
:source => scope.source
|
60
|
+
|
61
|
+
override = scope.compiler.add_override resource
|
62
|
+
|
63
|
+
result = {}
|
64
|
+
override.each do |_, v|
|
65
|
+
result.merge! v.name => v.value
|
66
|
+
end
|
67
|
+
result
|
68
|
+
end
|
69
|
+
|
70
|
+
# Realizes referenced virtual resource.
|
71
|
+
# @return [Puppet::Parser::Collector, nil] collector containing the realized resource, or nil if it is not virtual.
|
72
|
+
#
|
73
|
+
def realize
|
74
|
+
return unless @resource.virtual
|
75
|
+
scope = Puppet::DSL::Parser.current_scope
|
76
|
+
c = Puppet::Parser::Collector.new scope, @type, nil, nil, :virtual
|
77
|
+
c.resources = [@resource]
|
78
|
+
scope.compiler.add_collection c
|
79
|
+
c
|
80
|
+
end
|
81
|
+
|
82
|
+
# Collects referenced exported resource
|
83
|
+
# @return [Puppet::Parser::Collector, nil] collector containing the collected resource, or nil if it is not exported.
|
84
|
+
#
|
85
|
+
def collect
|
86
|
+
return unless @resource.exported
|
87
|
+
scope = Puppet::DSL::Parser.current_scope
|
88
|
+
c = Puppet::Parser::Collector.new scope, @type, nil, nil, :exported
|
89
|
+
c.resources = [@resource]
|
90
|
+
scope.compiler.add_collection c
|
91
|
+
c
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'puppet/parser/collector'
|
2
|
+
require 'puppet/parser/resource/param'
|
3
|
+
require 'puppet/dsl/resource_reference'
|
4
|
+
require 'puppet/dsl/resource_decorator'
|
5
|
+
require 'puppet/dsl/parser'
|
6
|
+
|
7
|
+
module Puppet
|
8
|
+
# @since 3.1
|
9
|
+
# @status EXPERIMENTAL
|
10
|
+
module DSL
|
11
|
+
|
12
|
+
# TypeReference object is returned by `Context#const_missing`.
|
13
|
+
# It allows to set defaults, create collections and get references for
|
14
|
+
# resources of given type.
|
15
|
+
#
|
16
|
+
class TypeReference
|
17
|
+
|
18
|
+
# @return [String] Puppet type represented by this reference
|
19
|
+
#
|
20
|
+
attr_reader :type_name
|
21
|
+
alias to_s type_name
|
22
|
+
|
23
|
+
# Creates new TypeReference of the given _typename_ type.
|
24
|
+
# @param typename [String] the name of the type to create a reference to.
|
25
|
+
# @raise [NameError] when resource type is not found
|
26
|
+
#
|
27
|
+
def initialize(typename)
|
28
|
+
name = Puppet::Resource.canonicalize_type typename
|
29
|
+
if Puppet::DSL::Context.const_defined? name
|
30
|
+
@type_name = name
|
31
|
+
@cache = {}
|
32
|
+
else
|
33
|
+
raise NameError, "resource type `#{name}' not found"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Produces a reference to a resource identified by the given _reference_.
|
38
|
+
# The result is cached for future use.
|
39
|
+
# @return [ResourceReference] reference to resource identified by the given _reference_
|
40
|
+
# @raise [ArgumentError] when resource cannot be found.
|
41
|
+
#
|
42
|
+
def [](reference)
|
43
|
+
@cache[reference] ||= Puppet::DSL::ResourceReference.new self, reference
|
44
|
+
end
|
45
|
+
|
46
|
+
# Creates a collection for exported resources.
|
47
|
+
# @return [Puppet::Parser::Collector] for exported instances of this type reference's type.
|
48
|
+
#
|
49
|
+
def collect
|
50
|
+
scope = Puppet::DSL::Parser.current_scope
|
51
|
+
c = Puppet::Parser::Collector.new scope, @type_name, nil, nil, :exported
|
52
|
+
scope.compiler.add_collection c
|
53
|
+
c
|
54
|
+
end
|
55
|
+
|
56
|
+
# Creates a collection for virtual resources.
|
57
|
+
# @return [Puppet::Parser::Collector] for virtual instances of this type reference's type.
|
58
|
+
#
|
59
|
+
def realize
|
60
|
+
scope = Puppet::DSL::Parser.current_scope
|
61
|
+
c = Puppet::Parser::Collector.new scope, @type_name, nil, nil, :virtual
|
62
|
+
scope.compiler.add_collection c
|
63
|
+
c
|
64
|
+
end
|
65
|
+
|
66
|
+
# Sets and/or gets defaults for the resource type this type reference represents. The values
|
67
|
+
# returned are the defaults in effect after the operation.
|
68
|
+
# @overload defaults()
|
69
|
+
# @return [Hash] a parameter to value mapping of the current set of defaults.
|
70
|
+
#
|
71
|
+
# @overload defaults(options)
|
72
|
+
# Sets the defaults in the given options hash as new default values. Only changes
|
73
|
+
# values for the given keys.
|
74
|
+
# @param options [Hash] mapping from parameter name to value of new defaults to set.
|
75
|
+
#
|
76
|
+
# @overload defaults(options, {|r| block})
|
77
|
+
# @param options [Hash] a parameter to value mapping of the new defaults to set.
|
78
|
+
# @param r [ResourceDecorator] the `self` when evaluating the Ruby DSL block.
|
79
|
+
# @param block [ruby] a block in which Ruby DSL statements can be executed for the resource type.
|
80
|
+
# @return [Hash] mapping from parameter name to value of the resulting set of defaults.
|
81
|
+
#
|
82
|
+
def defaults(options = {}, &block)
|
83
|
+
if options != {} or block
|
84
|
+
Puppet::DSL::ResourceDecorator.new(options, &block) unless block.nil?
|
85
|
+
|
86
|
+
# for compatibility with Puppet parser
|
87
|
+
options = options.map do |k, v|
|
88
|
+
Puppet::Parser::Resource::Param.new :name => k, :value => v
|
89
|
+
end
|
90
|
+
Puppet::DSL::Parser.current_scope.define_settings @type_name, options
|
91
|
+
end
|
92
|
+
|
93
|
+
result = {}
|
94
|
+
Puppet::DSL::Parser.current_scope.lookupdefaults(@type_name).map do |_, v|
|
95
|
+
result[v.name] = v.value
|
96
|
+
end
|
97
|
+
result
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/lib/puppet/error.rb
CHANGED
data/lib/puppet/face/help.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'puppet/face'
|
2
2
|
require 'puppet/application/face_base'
|
3
|
-
require 'puppet/util/command_line'
|
4
3
|
require 'puppet/util/constant_inflector'
|
5
4
|
require 'pathname'
|
6
5
|
require 'erb'
|
@@ -123,7 +122,7 @@ Detail: "#{detail.message}"
|
|
123
122
|
|
124
123
|
# Return a list of applications that are not simply just stubs for Faces.
|
125
124
|
def legacy_applications
|
126
|
-
Puppet::
|
125
|
+
Puppet::Application.available_application_names.reject do |appname|
|
127
126
|
(is_face_app?(appname)) or (exclude_from_docs?(appname))
|
128
127
|
end.sort
|
129
128
|
end
|
@@ -134,7 +133,7 @@ Detail: "#{detail.message}"
|
|
134
133
|
# element in the outer array is a pair whose first element is a String containing the application
|
135
134
|
# name, and whose second element is a String containing the summary for that application.
|
136
135
|
def all_application_summaries()
|
137
|
-
Puppet::
|
136
|
+
Puppet::Application.available_application_names.sort.inject([]) do |result, appname|
|
138
137
|
next result if exclude_from_docs?(appname)
|
139
138
|
|
140
139
|
if (is_face_app?(appname))
|
@@ -152,7 +151,6 @@ Detail: "#{detail.message}"
|
|
152
151
|
|
153
152
|
def horribly_extract_summary_from(appname)
|
154
153
|
begin
|
155
|
-
require "puppet/application/#{appname}"
|
156
154
|
help = Puppet::Application[appname].help.split("\n")
|
157
155
|
# Now we find the line with our summary, extract it, and return it. This
|
158
156
|
# depends on the implementation coincidence of how our pages are
|
data/lib/puppet/face/man.rb
CHANGED
@@ -59,7 +59,13 @@ Puppet::Face.define(:man, '0.0.1') do
|
|
59
59
|
# OK, if we have Ronn on the path we can delegate to it and override the
|
60
60
|
# normal output process. Otherwise delegate to a pager on the raw text,
|
61
61
|
# otherwise we finally just delegate to our parent. Oh, well.
|
62
|
-
|
62
|
+
|
63
|
+
# These are the same options for less that git normally uses.
|
64
|
+
# -R : Pass through color control codes (allows display of colors)
|
65
|
+
# -X : Don't init/deinit terminal (leave display on screen on exit)
|
66
|
+
# -F : automatically exit if display fits entirely on one screen
|
67
|
+
# -S : don't wrap long lines
|
68
|
+
ENV['LESS'] ||= 'FRSX'
|
63
69
|
|
64
70
|
ronn = Puppet::Util.which('ronn')
|
65
71
|
pager = [ENV['MANPAGER'], ENV['PAGER'], 'less', 'most', 'more'].
|
@@ -84,7 +90,7 @@ Puppet::Face.define(:man, '0.0.1') do
|
|
84
90
|
|
85
91
|
def legacy_applications
|
86
92
|
# The list of applications, less those that are duplicated as a face.
|
87
|
-
Puppet::
|
93
|
+
Puppet::Application.available_application_names.reject do |appname|
|
88
94
|
Puppet::Face.face? appname.to_sym, :current or
|
89
95
|
# ...this is a nasty way to exclude non-applications. :(
|
90
96
|
%w{face_base indirection_base}.include? appname
|
data/lib/puppet/feature/pson.rb
CHANGED
@@ -5,6 +5,9 @@ require 'puppet/resource/catalog'
|
|
5
5
|
class Puppet::Resource::Catalog::ActiveRecord < Puppet::Indirector::ActiveRecord
|
6
6
|
use_ar_model Puppet::Rails::Host
|
7
7
|
|
8
|
+
desc "A component of ActiveRecord storeconfigs. ActiveRecord-based storeconfigs
|
9
|
+
and inventory are deprecated. See http://links.puppetlabs.com/activerecord-deprecation"
|
10
|
+
|
8
11
|
def initialize
|
9
12
|
Puppet.deprecation_warning "ActiveRecord-based storeconfigs and inventory are deprecated. See http://links.puppetlabs.com/activerecord-deprecation"
|
10
13
|
super
|
@@ -4,8 +4,7 @@ require 'puppet/indirector/code'
|
|
4
4
|
require 'yaml'
|
5
5
|
|
6
6
|
class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
|
7
|
-
desc "
|
8
|
-
Puppet's compiler"
|
7
|
+
desc "Compiles catalogs on demand using Puppet's compiler."
|
9
8
|
|
10
9
|
include Puppet::Util
|
11
10
|
|
@@ -2,4 +2,8 @@ require 'puppet/resource/catalog'
|
|
2
2
|
require 'puppet/indirector/queue'
|
3
3
|
|
4
4
|
class Puppet::Resource::Catalog::Queue < Puppet::Indirector::Queue
|
5
|
+
|
6
|
+
desc "Part of async storeconfigs, requiring the puppet queue daemon. ActiveRecord-based storeconfigs
|
7
|
+
and inventory are deprecated. See http://links.puppetlabs.com/activerecord-deprecation"
|
8
|
+
|
5
9
|
end
|
@@ -3,6 +3,36 @@ require 'puppet/resource/catalog'
|
|
3
3
|
require 'puppet/indirector/code'
|
4
4
|
|
5
5
|
class Puppet::Resource::Catalog::StaticCompiler < Puppet::Indirector::Code
|
6
|
+
|
7
|
+
desc %q{Compiles catalogs on demand using the optional static compiler. This
|
8
|
+
functions similarly to the normal compiler, but it replaces puppet:/// file
|
9
|
+
URLs with explicit metadata and file content hashes, expecting puppet agent
|
10
|
+
to fetch the exact specified content from the filebucket. This guarantees
|
11
|
+
that a given catalog will always result in the same file states. It also
|
12
|
+
decreases catalog application time and fileserver load, at the cost of
|
13
|
+
increased compilation time.
|
14
|
+
|
15
|
+
This terminus works today, but cannot be used without additional
|
16
|
+
configuration. Specifically:
|
17
|
+
|
18
|
+
You must create a `Filebucket['puppet']` resource in site.pp (or somewhere
|
19
|
+
else where it will be added to every node's catalog). The title of this
|
20
|
+
resource **MUST** be "puppet"; the static compiler treats this title as magical.
|
21
|
+
|
22
|
+
# Note: the special $servername var always contains the master's FQDN,
|
23
|
+
# even if it was reached at a different name.
|
24
|
+
filebucket { puppet:
|
25
|
+
server => $servername,
|
26
|
+
path => false,
|
27
|
+
}
|
28
|
+
|
29
|
+
You must set `catalog_terminus = static_compiler` in the puppet master's puppet.conf.
|
30
|
+
|
31
|
+
If you are using multiple puppet masters, you must configure load balancer
|
32
|
+
affinity for agent nodes. This is because puppet masters other than the one
|
33
|
+
that compiled a given catalog may not have stored the required file contents
|
34
|
+
in their filebuckets.}
|
35
|
+
|
6
36
|
def compiler
|
7
37
|
@compiler ||= indirection.terminus(:compiler)
|
8
38
|
end
|
@@ -7,6 +7,10 @@ require 'puppet/ssl/host'
|
|
7
7
|
require 'puppet/ssl/key'
|
8
8
|
|
9
9
|
class Puppet::Indirector::CertificateStatus::File < Puppet::Indirector::Code
|
10
|
+
|
11
|
+
desc "Manipulate certificate status on the local filesystem. Only functional
|
12
|
+
on the CA."
|
13
|
+
|
10
14
|
def ca
|
11
15
|
raise ArgumentError, "This process is not configured as a certificate authority" unless Puppet::SSL::CertificateAuthority.ca?
|
12
16
|
Puppet::SSL::CertificateAuthority.new
|
@@ -6,6 +6,9 @@ require 'puppet/indirector/active_record'
|
|
6
6
|
class Puppet::Node::Facts::ActiveRecord < Puppet::Indirector::ActiveRecord
|
7
7
|
use_ar_model Puppet::Rails::Host
|
8
8
|
|
9
|
+
desc "A component of ActiveRecord storeconfigs and inventory. ActiveRecord-based storeconfigs
|
10
|
+
and inventory are deprecated. See http://links.puppetlabs.com/activerecord-deprecation"
|
11
|
+
|
9
12
|
def initialize
|
10
13
|
Puppet.deprecation_warning "ActiveRecord-based storeconfigs and inventory are deprecated. See http://links.puppetlabs.com/activerecord-deprecation"
|
11
14
|
super
|