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
@@ -1,4 +1,4 @@
|
|
1
|
-
Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC') do |args|
|
1
|
+
Puppet::Parser::Functions::newfunction(:create_resources, :arity => -3, :doc => <<-'ENDHEREDOC') do |args|
|
2
2
|
Converts a hash into a set of resources and adds them to the catalog.
|
3
3
|
|
4
4
|
This function takes two mandatory arguments: a resource type, and a hash describing
|
@@ -31,12 +31,31 @@ Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC
|
|
31
31
|
|
32
32
|
This function can be used to create defined resources and classes, as well
|
33
33
|
as native resources.
|
34
|
+
|
35
|
+
Virtual and Exported resources may be created by prefixing the type name
|
36
|
+
with @ or @@ respectively. For example, the $myusers hash may be exported
|
37
|
+
in the following manner:
|
38
|
+
|
39
|
+
create_resources("@@user", $myusers)
|
40
|
+
|
41
|
+
The $myusers may be declared as virtual resources using:
|
42
|
+
|
43
|
+
create_resources("@user", $myusers)
|
44
|
+
|
34
45
|
ENDHEREDOC
|
35
|
-
raise ArgumentError, ("create_resources(): wrong number of arguments (#{args.length}; must be 2 or 3)") if args.length
|
46
|
+
raise ArgumentError, ("create_resources(): wrong number of arguments (#{args.length}; must be 2 or 3)") if args.length > 3
|
36
47
|
|
37
48
|
# figure out what kind of resource we are
|
38
49
|
type_of_resource = nil
|
39
50
|
type_name = args[0].downcase
|
51
|
+
type_exported, type_virtual = false
|
52
|
+
if type_name.start_with? '@@'
|
53
|
+
type_name = type_name[2..-1]
|
54
|
+
type_exported = true
|
55
|
+
elsif type_name.start_with? '@'
|
56
|
+
type_name = type_name[1..-1]
|
57
|
+
type_virtual = true
|
58
|
+
end
|
40
59
|
if type_name == 'class'
|
41
60
|
type_of_resource = :class
|
42
61
|
else
|
@@ -58,6 +77,8 @@ Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC
|
|
58
77
|
# for a defined type.
|
59
78
|
when :type, :define
|
60
79
|
p_resource = Puppet::Parser::Resource.new(type_name, title, :scope => self, :source => resource)
|
80
|
+
p_resource.virtual = type_virtual
|
81
|
+
p_resource.exported = type_exported
|
61
82
|
{:name => title}.merge(params).each do |k,v|
|
62
83
|
p_resource.set_parameter(k,v)
|
63
84
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Test whether a given class or definition is defined
|
2
|
-
Puppet::Parser::Functions::newfunction(:defined, :type => :rvalue, :doc => "Determine whether
|
2
|
+
Puppet::Parser::Functions::newfunction(:defined, :type => :rvalue, :arity => -2, :doc => "Determine whether
|
3
3
|
a given class or resource type is defined. This function can also determine whether a
|
4
4
|
specific resource has been declared. Returns true or false. Accepts class names,
|
5
5
|
type names, and resource references.
|
@@ -3,6 +3,7 @@ require 'csv'
|
|
3
3
|
module Puppet::Parser::Functions
|
4
4
|
newfunction(:extlookup,
|
5
5
|
:type => :rvalue,
|
6
|
+
:arity => -2,
|
6
7
|
:doc => "This is a parser function to read data from external files, this version
|
7
8
|
uses CSV files but the concept can easily be adjust for databases, yaml
|
8
9
|
or any other queryable data source.
|
@@ -89,7 +90,7 @@ This is for back compatibility to interpolate variables with %. % interpolation
|
|
89
90
|
default = args[1]
|
90
91
|
datafile = args[2]
|
91
92
|
|
92
|
-
raise
|
93
|
+
raise ArgumentError, ("extlookup(): wrong number of arguments (#{args.length}; must be <= 3)") if args.length > 3
|
93
94
|
|
94
95
|
extlookup_datadir = undef_as('',self['::extlookup_datadir'])
|
95
96
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Puppet::Parser::Functions::newfunction(:fail, :doc => "Fail with a parse error.") do |vals|
|
1
|
+
Puppet::Parser::Functions::newfunction(:fail, :arity => -1, :doc => "Fail with a parse error.") do |vals|
|
2
2
|
vals = vals.collect { |s| s.to_s }.join(" ") if vals.is_a? Array
|
3
3
|
raise Puppet::ParseError, vals.to_s
|
4
4
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Returns the contents of a file
|
2
2
|
|
3
3
|
Puppet::Parser::Functions::newfunction(
|
4
|
-
:file, :type => :rvalue,
|
4
|
+
:file, :arity => -2, :type => :rvalue,
|
5
5
|
:doc => "Return the contents of a file. Multiple files
|
6
6
|
can be passed, and the first file that exists will be read in."
|
7
7
|
) do |vals|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'digest/md5'
|
2
2
|
|
3
|
-
Puppet::Parser::Functions::newfunction(:fqdn_rand, :type => :rvalue, :doc =>
|
3
|
+
Puppet::Parser::Functions::newfunction(:fqdn_rand, :arity => -2, :type => :rvalue, :doc =>
|
4
4
|
"Generates random numbers based on the node's fqdn. Generated random values
|
5
5
|
will be a range from 0 up to and excluding n, where n is the first parameter.
|
6
6
|
The second argument specifies a number to add to the seed and is optional, for example:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Runs an external command and returns the results
|
2
|
-
Puppet::Parser::Functions::newfunction(:generate, :type => :rvalue,
|
2
|
+
Puppet::Parser::Functions::newfunction(:generate, :arity => -2, :type => :rvalue,
|
3
3
|
:doc => "Calls an external command on the Puppet master and returns
|
4
4
|
the results of the command. Any arguments are passed to the external command as
|
5
5
|
arguments. If the generator does not exit with return code of 0,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Puppet::Parser::Functions
|
2
|
-
newfunction(:hiera, :type => :rvalue) do |*args|
|
2
|
+
newfunction(:hiera, :type => :rvalue, :arity => -2) do |*args|
|
3
3
|
require 'hiera_puppet'
|
4
4
|
key, default, override = HieraPuppet.parse_args(args)
|
5
5
|
HieraPuppet.lookup(key, default, self, override, :priority)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Puppet::Parser::Functions
|
2
|
-
newfunction(:hiera_array, :type => :rvalue) do |*args|
|
2
|
+
newfunction(:hiera_array, :type => :rvalue, :arity => -2) do |*args|
|
3
3
|
require 'hiera_puppet'
|
4
4
|
key, default, override = HieraPuppet.parse_args(args)
|
5
5
|
HieraPuppet.lookup(key, default, self, override, :array)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Puppet::Parser::Functions
|
2
|
-
newfunction(:hiera_hash, :type => :rvalue) do |*args|
|
2
|
+
newfunction(:hiera_hash, :type => :rvalue, :arity => -2) do |*args|
|
3
3
|
require 'hiera_puppet'
|
4
4
|
key, default, override = HieraPuppet.parse_args(args)
|
5
5
|
HieraPuppet.lookup(key, default, self, override, :hash)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Puppet::Parser::Functions
|
2
|
-
newfunction(:hiera_include) do |*args|
|
2
|
+
newfunction(:hiera_include, :arity => -2) do |*args|
|
3
3
|
require 'hiera_puppet'
|
4
4
|
key, default, override = HieraPuppet.parse_args(args)
|
5
5
|
if answer = HieraPuppet.lookup(key, default, self, override, :array)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Include the specified classes
|
2
|
-
Puppet::Parser::Functions::newfunction(:include, :doc => "Evaluate one or more classes.") do |vals|
|
2
|
+
Puppet::Parser::Functions::newfunction(:include, :arity => -2, :doc => "Evaluate one or more classes.") do |vals|
|
3
3
|
if vals.is_a?(Array)
|
4
4
|
# Protect against array inside array
|
5
5
|
vals = vals.flatten
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :doc =>
|
1
|
+
Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :arity => -2, :doc =>
|
2
2
|
"Evaluate a template string and return its value. See
|
3
3
|
[the templating docs](http://docs.puppetlabs.com/guides/templating.html) for
|
4
4
|
more information. Note that if multiple template strings are specified, their
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'digest/md5'
|
2
2
|
|
3
|
-
Puppet::Parser::Functions::newfunction(:md5, :type => :rvalue, :doc => "Returns a MD5 hash value from a provided string.") do |args|
|
3
|
+
Puppet::Parser::Functions::newfunction(:md5, :type => :rvalue, :arity => 1, :doc => "Returns a MD5 hash value from a provided string.") do |args|
|
4
4
|
Digest::MD5.hexdigest(args[0])
|
5
5
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# This is just syntactic sugar for a collection, although it will generally
|
2
2
|
# be a good bit faster.
|
3
3
|
|
4
|
-
Puppet::Parser::Functions::newfunction(:realize, :doc => "Make a virtual object real. This is useful
|
4
|
+
Puppet::Parser::Functions::newfunction(:realize, :arity => -2, :doc => "Make a virtual object real. This is useful
|
5
5
|
when you want to know the name of the virtual object and don't want to
|
6
6
|
bother with a full collection. It is slightly faster than a collection,
|
7
7
|
and, of course, is a bit shorter. You must pass the object using a
|
@@ -24,10 +24,9 @@
|
|
24
24
|
# other dealings in this Software without prior written authorization
|
25
25
|
# from Thomas Bellman.
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
newfunction(
|
27
|
+
Puppet::Parser::Functions::newfunction(
|
30
28
|
:regsubst, :type => :rvalue,
|
29
|
+
:arity => -4,
|
31
30
|
|
32
31
|
:doc => "
|
33
32
|
Perform regexp replacement on a string or array of strings.
|
@@ -56,64 +55,62 @@ Get the third octet from the node's IP address:
|
|
56
55
|
Put angle brackets around each octet in the node's IP address:
|
57
56
|
|
58
57
|
$x = regsubst($ipaddress, '([0-9]+)', '<\\1>', 'G')
|
59
|
-
")
|
60
|
-
|
61
|
-
unless args.length.between?(3, 5)
|
58
|
+
") do |args|
|
59
|
+
unless args.length.between?(3, 5)
|
62
60
|
|
63
|
-
|
64
|
-
|
61
|
+
raise(
|
62
|
+
ArgumentError,
|
65
63
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
64
|
+
"regsubst(): got #{args.length} arguments, expected 3 to 5")
|
65
|
+
end
|
66
|
+
target, regexp, replacement, flags, lang = args
|
67
|
+
reflags = 0
|
68
|
+
operation = :sub
|
69
|
+
if flags == nil
|
70
|
+
flags = []
|
71
|
+
elsif flags.respond_to?(:split)
|
72
|
+
flags = flags.split('')
|
73
|
+
else
|
74
|
+
|
75
|
+
raise(
|
76
|
+
Puppet::ParseError,
|
77
|
+
|
78
|
+
"regsubst(): bad flags parameter #{flags.class}:`#{flags}'")
|
79
|
+
end
|
80
|
+
flags.each do |f|
|
81
|
+
case f
|
82
|
+
when 'G' then operation = :gsub
|
83
|
+
when 'E' then reflags |= Regexp::EXTENDED
|
84
|
+
when 'I' then reflags |= Regexp::IGNORECASE
|
85
|
+
when 'M' then reflags |= Regexp::MULTILINE
|
86
|
+
else raise(Puppet::ParseError, "regsubst(): bad flag `#{f}'")
|
90
87
|
end
|
91
|
-
|
92
|
-
|
93
|
-
|
88
|
+
end
|
89
|
+
begin
|
90
|
+
re = Regexp.compile(regexp, reflags, lang)
|
91
|
+
rescue RegexpError, TypeError
|
94
92
|
|
95
|
-
|
96
|
-
|
93
|
+
raise(
|
94
|
+
Puppet::ParseError,
|
97
95
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
117
|
-
return result
|
96
|
+
"regsubst(): Bad regular expression `#{regexp}'")
|
97
|
+
end
|
98
|
+
if target.respond_to?(operation)
|
99
|
+
# String parameter -> string result
|
100
|
+
result = target.send(operation, re, replacement)
|
101
|
+
elsif target.respond_to?(:collect) and
|
102
|
+
target.respond_to?(:all?) and
|
103
|
+
target.all? { |e| e.respond_to?(operation) }
|
104
|
+
# Array parameter -> array result
|
105
|
+
result = target.collect { |e|
|
106
|
+
e.send(operation, re, replacement)
|
107
|
+
}
|
108
|
+
else
|
109
|
+
|
110
|
+
raise(
|
111
|
+
Puppet::ParseError,
|
112
|
+
|
113
|
+
"regsubst(): bad target #{target.class}:`#{target}'")
|
118
114
|
end
|
115
|
+
return result
|
119
116
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Puppet::Parser::Functions::newfunction(:search, :doc => "Add another namespace for this class to search.
|
1
|
+
Puppet::Parser::Functions::newfunction(:search, :arity => -2, :doc => "Add another namespace for this class to search.
|
2
2
|
This allows you to create classes with sets of definitions and add
|
3
3
|
those classes to another class's search path.") do |vals|
|
4
4
|
vals.each do |val|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'digest/sha1'
|
2
2
|
|
3
|
-
Puppet::Parser::Functions::newfunction(:sha1, :type => :rvalue, :doc => "Returns a SHA1 hash value from a provided string.") do |args|
|
3
|
+
Puppet::Parser::Functions::newfunction(:sha1, :type => :rvalue, :arity => 1, :doc => "Returns a SHA1 hash value from a provided string.") do |args|
|
4
4
|
Digest::SHA1.hexdigest(args[0])
|
5
5
|
end
|
@@ -24,7 +24,7 @@
|
|
24
24
|
# other dealings in this Software without prior written authorization
|
25
25
|
# from Thomas Bellman.
|
26
26
|
|
27
|
-
Puppet::Parser::Functions.newfunction(:shellquote, :type => :rvalue, :doc => "\
|
27
|
+
Puppet::Parser::Functions.newfunction(:shellquote, :type => :rvalue, :arity => -1, :doc => "\
|
28
28
|
Quote and concatenate arguments for use in Bourne shell.
|
29
29
|
|
30
30
|
Each argument is quoted separately, and then all are concatenated
|
@@ -2,6 +2,7 @@ module Puppet::Parser::Functions
|
|
2
2
|
|
3
3
|
newfunction(
|
4
4
|
:split, :type => :rvalue,
|
5
|
+
:arity => 2,
|
5
6
|
|
6
7
|
:doc => "\
|
7
8
|
Split a string variable into an array using the specified split regexp.
|
@@ -22,8 +23,6 @@ a regexp meta-character (.), which must be escaped. A simple
|
|
22
23
|
way to do that for a single character is to enclose it in square
|
23
24
|
brackets; a backslash will also escape a single character.") do |args|
|
24
25
|
|
25
|
-
raise Puppet::ParseError, ("split(): wrong number of arguments (#{args.length}; must be 2)") if args.length != 2
|
26
|
-
|
27
26
|
return args[0].split(Regexp.compile(args[1]))
|
28
27
|
end
|
29
28
|
end
|
@@ -24,16 +24,13 @@
|
|
24
24
|
# other dealings in this Software without prior written authorization
|
25
25
|
# from Thomas Bellman.
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
newfunction(
|
27
|
+
Puppet::Parser::Functions::newfunction(
|
30
28
|
:sprintf, :type => :rvalue,
|
29
|
+
:arity => -2,
|
30
|
+
:doc => "Perform printf-style formatting of text.
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
fmt = args.shift
|
37
|
-
return sprintf(fmt, *args)
|
38
|
-
end
|
32
|
+
The first parameter is format string describing how the rest of the parameters should be formatted. See the documentation for the `Kernel::sprintf` function in Ruby for all the details."
|
33
|
+
) do |args|
|
34
|
+
fmt = args.shift
|
35
|
+
return sprintf(fmt, *args)
|
39
36
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Tag the current scope with each passed name
|
2
|
-
Puppet::Parser::Functions::newfunction(:tag, :doc => "Add the specified tags to the containing class
|
2
|
+
Puppet::Parser::Functions::newfunction(:tag, :arity => -2, :doc => "Add the specified tags to the containing class
|
3
3
|
or definition. All contained objects will then acquire that tag, also.
|
4
4
|
") do |vals|
|
5
5
|
self.resource.tag(*vals)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Test whether a given tag is set. This functions as a big OR -- if any of the specified tags are unset, we return false.
|
2
|
-
Puppet::Parser::Functions::newfunction(:tagged, :type => :rvalue, :doc => "A boolean function that
|
2
|
+
Puppet::Parser::Functions::newfunction(:tagged, :type => :rvalue, :arity => -2, :doc => "A boolean function that
|
3
3
|
tells you whether the current container is tagged with the specified tags.
|
4
4
|
The tags are ANDed, so that all of the specified tags must be included for
|
5
5
|
the function to return true.") do |vals|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :doc =>
|
1
|
+
Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :arity => -2, :doc =>
|
2
2
|
"Evaluate a template and return its value. See
|
3
3
|
[the templating docs](http://docs.puppetlabs.com/guides/templating.html) for
|
4
4
|
more information.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'puppet/util/package'
|
2
2
|
|
3
|
-
Puppet::Parser::Functions::newfunction( :versioncmp, :type => :rvalue, :doc =>
|
3
|
+
Puppet::Parser::Functions::newfunction( :versioncmp, :type => :rvalue, :arity => 2, :doc =>
|
4
4
|
"Compares two version numbers.
|
5
5
|
|
6
6
|
Prototype:
|
@@ -26,9 +26,5 @@ This function uses the same version comparison algorithm used by Puppet's
|
|
26
26
|
|
27
27
|
") do |args|
|
28
28
|
|
29
|
-
unless args.length == 2
|
30
|
-
raise Puppet::ParseError, "versioncmp should have 2 arguments"
|
31
|
-
end
|
32
|
-
|
33
29
|
return Puppet::Util::Package.versioncmp(args[0], args[1])
|
34
30
|
end
|
@@ -136,34 +136,18 @@ class Puppet::Parser::Parser
|
|
136
136
|
|
137
137
|
# how should I do error handling here?
|
138
138
|
def parse(string = nil)
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
rescue => except
|
151
|
-
raise Puppet::ParseError.new(except.message, @lexer.file, @lexer.line, except)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
# Store the results as the top-level class.
|
155
|
-
return Puppet::Parser::AST::Hostclass.new('', :code => main)
|
139
|
+
self.string = string if string
|
140
|
+
|
141
|
+
@yydebug = false
|
142
|
+
code = yyparse(@lexer, :scan)
|
143
|
+
Puppet::Parser::AST::Hostclass.new('', :code => code)
|
144
|
+
rescue Puppet::ParseError => except
|
145
|
+
except.line ||= @lexer.line
|
146
|
+
except.file ||= @lexer.file
|
147
|
+
raise except
|
148
|
+
rescue => except
|
149
|
+
raise Puppet::ParseError.new(except.message, @lexer.file, @lexer.line, except)
|
156
150
|
ensure
|
157
151
|
@lexer.clear
|
158
152
|
end
|
159
|
-
|
160
|
-
def parse_ruby_file
|
161
|
-
# Execute the contents of the file inside its own "main" object so
|
162
|
-
# that it can call methods in the resource type API.
|
163
|
-
main_object = Puppet::DSL::ResourceTypeAPI.new
|
164
|
-
main_object.instance_eval(File.read(self.file))
|
165
|
-
|
166
|
-
# Then extract any types that were created.
|
167
|
-
Puppet::Parser::AST::ASTArray.new :children => main_object.instance_eval { @__created_ast_objects__ }
|
168
|
-
end
|
169
153
|
end
|