puppet 3.1.0.rc1 → 3.1.0.rc2
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/COMMITTERS.md +185 -0
- data/ext/debian/changelog.erb +6 -0
- data/ext/debian/puppet-common.manpages +1 -0
- data/ext/debian/puppet.default +3 -1
- data/ext/debian/puppetmaster.default +6 -3
- data/ext/redhat/puppet.spec.erb +16 -5
- data/lib/puppet.rb +3 -5
- data/lib/puppet/defaults.rb +6 -5
- data/lib/puppet/dsl.rb +3 -7
- data/lib/puppet/dsl/resource_api.rb +120 -0
- data/lib/puppet/dsl/resource_type_api.rb +34 -0
- data/lib/puppet/module_tool.rb +23 -11
- data/lib/puppet/network/formats.rb +1 -1
- data/lib/puppet/node/environment.rb +1 -3
- data/lib/puppet/parser/ast/definition.rb +5 -2
- data/lib/puppet/parser/ast/hostclass.rb +3 -2
- data/lib/puppet/parser/ast/node.rb +5 -2
- data/lib/puppet/parser/ast/resourceparam.rb +1 -1
- data/lib/puppet/parser/compiler.rb +0 -10
- data/lib/puppet/parser/lexer.rb +50 -39
- data/lib/puppet/parser/parser_support.rb +29 -11
- data/lib/puppet/parser/scope.rb +2 -2
- data/lib/puppet/parser/type_loader.rb +7 -31
- data/lib/puppet/provider/package/openbsd.rb +16 -2
- data/lib/puppet/provider/package/pip.rb +11 -2
- data/lib/puppet/provider/package/portage.rb +29 -12
- data/lib/puppet/provider/service/launchd.rb +19 -14
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/user/hpux.rb +37 -2
- data/lib/puppet/resource.rb +25 -38
- data/lib/puppet/resource/type.rb +6 -14
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/ssl/certificate_authority.rb +4 -1
- data/lib/puppet/ssl/certificate_request.rb +3 -1
- data/lib/puppet/ssl/certificate_signer.rb +22 -0
- data/lib/puppet/type.rb +4 -4
- data/lib/puppet/util/methodhelper.rb +0 -19
- data/lib/puppet/util/rubygems.rb +3 -1
- data/lib/puppet/util/selinux.rb +1 -6
- data/lib/puppet/version.rb +1 -1
- data/man/man5/puppet.conf.5 +81 -95
- data/man/man8/extlookup2hiera.8 +23 -0
- data/man/man8/puppet-agent.8 +3 -3
- data/man/man8/puppet-apply.8 +2 -6
- data/man/man8/puppet-ca.8 +6 -7
- data/man/man8/puppet-catalog.8 +6 -7
- data/man/man8/puppet-cert.8 +4 -4
- data/man/man8/puppet-certificate.8 +6 -7
- data/man/man8/puppet-certificate_request.8 +6 -7
- data/man/man8/puppet-certificate_revocation_list.8 +6 -7
- data/man/man8/puppet-config.8 +4 -8
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +3 -3
- data/man/man8/puppet-facts.8 +4 -8
- data/man/man8/puppet-file.8 +6 -7
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-help.8 +2 -6
- data/man/man8/puppet-inspect.8 +1 -1
- data/man/man8/puppet-instrumentation_data.8 +3 -7
- data/man/man8/puppet-instrumentation_listener.8 +3 -7
- data/man/man8/puppet-instrumentation_probe.8 +3 -7
- data/man/man8/puppet-key.8 +6 -7
- data/man/man8/puppet-kick.8 +5 -1
- data/man/man8/puppet-man.8 +2 -6
- data/man/man8/puppet-master.8 +2 -2
- data/man/man8/puppet-module.8 +11 -9
- data/man/man8/puppet-node.8 +38 -37
- data/man/man8/puppet-parser.8 +2 -6
- data/man/man8/puppet-plugin.8 +2 -6
- data/man/man8/puppet-queue.8 +1 -1
- data/man/man8/puppet-report.8 +3 -7
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-resource_type.8 +3 -7
- data/man/man8/puppet-secret_agent.8 +2 -6
- data/man/man8/puppet-status.8 +3 -7
- data/man/man8/puppet.8 +1 -1
- data/spec/integration/parser/ruby_manifest_spec.rb +128 -0
- data/spec/lib/puppet_spec/compiler.rb +0 -11
- data/spec/spec_helper.rb +3 -4
- data/spec/unit/dsl/resource_api_spec.rb +180 -0
- data/spec/unit/dsl/resource_type_api_spec.rb +53 -0
- data/spec/unit/module_tool_spec.rb +79 -46
- data/spec/unit/network/formats_spec.rb +4 -0
- data/spec/unit/node/environment_spec.rb +0 -13
- data/spec/unit/parser/compiler_spec.rb +0 -26
- data/spec/unit/parser/parser_spec.rb +14 -0
- data/spec/unit/parser/type_loader_spec.rb +4 -15
- data/spec/unit/provider/package/openbsd_spec.rb +148 -35
- data/spec/unit/provider/package/pip_spec.rb +49 -25
- data/spec/unit/provider/package/portage_spec.rb +65 -0
- data/spec/unit/provider/service/launchd_spec.rb +6 -5
- data/spec/unit/provider/user/hpux_spec.rb +39 -11
- data/spec/unit/provider/user/useradd_spec.rb +14 -14
- data/spec/unit/resource/type_spec.rb +7 -49
- data/spec/unit/resource_spec.rb +0 -32
- data/spec/unit/ssl/certificate_request_spec.rb +18 -0
- data/spec/unit/util/rubygems_spec.rb +1 -1
- data/spec/unit/util/selinux_spec.rb +0 -2
- metadata +17 -50
- data/lib/puppet/dsl/actions.rb +0 -283
- data/lib/puppet/dsl/blank_slate.rb +0 -55
- data/lib/puppet/dsl/context.rb +0 -393
- data/lib/puppet/dsl/parser.rb +0 -57
- data/lib/puppet/dsl/resource_decorator.rb +0 -56
- data/lib/puppet/dsl/resource_reference.rb +0 -95
- data/lib/puppet/dsl/type_reference.rb +0 -102
- data/lib/puppet/util/manifest_filetype_helper.rb +0 -22
- data/spec/integration/dsl/classes_spec.rb +0 -191
- data/spec/integration/dsl/defaults_spec.rb +0 -38
- data/spec/integration/dsl/definitions_spec.rb +0 -73
- data/spec/integration/dsl/functions_spec.rb +0 -95
- data/spec/integration/dsl/nodes_spec.rb +0 -96
- data/spec/integration/dsl/params_spec.rb +0 -146
- data/spec/integration/dsl/relationships_spec.rb +0 -46
- data/spec/integration/dsl/resources_spec.rb +0 -202
- data/spec/integration/dsl/type_loading_spec.rb +0 -64
- data/spec/lib/matchers/catalog.rb +0 -50
- data/spec/lib/puppet_spec/dsl.rb +0 -29
- data/spec/unit/dsl/actions_spec.rb +0 -402
- data/spec/unit/dsl/blank_slate_spec.rb +0 -27
- data/spec/unit/dsl/context_spec.rb +0 -678
- data/spec/unit/dsl/parser_spec.rb +0 -56
- data/spec/unit/dsl/resource_decorator_spec.rb +0 -94
- data/spec/unit/dsl/resource_reference_spec.rb +0 -150
- data/spec/unit/dsl/type_reference_spec.rb +0 -164
- data/spec/unit/util/manifest_filetype_helper_spec.rb +0 -29
@@ -1,56 +0,0 @@
|
|
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
|
@@ -1,95 +0,0 @@
|
|
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
|
@@ -1,102 +0,0 @@
|
|
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
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Puppet
|
2
|
-
module Util
|
3
|
-
|
4
|
-
##
|
5
|
-
# Module that gathers helper functions for determining type of manifests.
|
6
|
-
##
|
7
|
-
module ManifestFiletypeHelper
|
8
|
-
extend self
|
9
|
-
|
10
|
-
def is_ruby_filename?(file)
|
11
|
-
!!(file =~ /\.rb\z/i)
|
12
|
-
end
|
13
|
-
|
14
|
-
def is_puppet_filename?(file)
|
15
|
-
!!(file =~ /\.pp\z/i)
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
@@ -1,191 +0,0 @@
|
|
1
|
-
require 'puppet'
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'matchers/catalog'
|
4
|
-
require 'puppet_spec/compiler'
|
5
|
-
|
6
|
-
include PuppetSpec::Compiler
|
7
|
-
|
8
|
-
describe Puppet::DSL do
|
9
|
-
prepare_compiler
|
10
|
-
|
11
|
-
describe "classes" do
|
12
|
-
|
13
|
-
it "should be able to create a class" do
|
14
|
-
p = compile_to_catalog(<<-MANIFEST)
|
15
|
-
class foo {}
|
16
|
-
MANIFEST
|
17
|
-
|
18
|
-
r = compile_ruby_to_catalog(<<-MANIFEST)
|
19
|
-
hostclass :foo do; end
|
20
|
-
MANIFEST
|
21
|
-
|
22
|
-
r.should be_equivalent_to_catalog p
|
23
|
-
end
|
24
|
-
|
25
|
-
it "shouldn't evaluate the body of the class until it is used" do
|
26
|
-
p = compile_to_catalog(<<-MANIFEST)
|
27
|
-
class foo {
|
28
|
-
notify {"bar": }
|
29
|
-
}
|
30
|
-
MANIFEST
|
31
|
-
|
32
|
-
r = compile_ruby_to_catalog(<<-MANIFEST)
|
33
|
-
hostclass :foo do
|
34
|
-
notify "bar"
|
35
|
-
end
|
36
|
-
MANIFEST
|
37
|
-
r.should be_equivalent_to_catalog p
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should be able to use created class" do
|
41
|
-
p = compile_to_catalog(<<-MANIFEST)
|
42
|
-
class foo {
|
43
|
-
}
|
44
|
-
|
45
|
-
node default {
|
46
|
-
include foo
|
47
|
-
}
|
48
|
-
MANIFEST
|
49
|
-
|
50
|
-
r = compile_ruby_to_catalog(<<-MANIFEST)
|
51
|
-
hostclass :foo do
|
52
|
-
end
|
53
|
-
|
54
|
-
node "default" do
|
55
|
-
use :foo
|
56
|
-
end
|
57
|
-
MANIFEST
|
58
|
-
|
59
|
-
r.should be_equivalent_to_catalog p
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should evaluate contents of the class when the class is used" do
|
63
|
-
p = compile_to_catalog(<<-MANIFEST)
|
64
|
-
class foo {
|
65
|
-
notify {"bar": }
|
66
|
-
}
|
67
|
-
|
68
|
-
include foo
|
69
|
-
MANIFEST
|
70
|
-
|
71
|
-
r = compile_ruby_to_catalog(<<-MANIFEST)
|
72
|
-
hostclass :foo do
|
73
|
-
notify "bar"
|
74
|
-
end
|
75
|
-
|
76
|
-
use :foo
|
77
|
-
MANIFEST
|
78
|
-
|
79
|
-
r.should be_equivalent_to_catalog p
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should be able to create class with arguments and use them" do
|
83
|
-
p = compile_to_catalog(<<-MANIFEST)
|
84
|
-
class foo($param = "value") {}
|
85
|
-
|
86
|
-
MANIFEST
|
87
|
-
|
88
|
-
r = compile_ruby_to_catalog(<<-MANIFEST)
|
89
|
-
hostclass :foo, :arguments => {:param => "value"} do; end
|
90
|
-
MANIFEST
|
91
|
-
|
92
|
-
r.should be_equivalent_to_catalog p
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should be able to use class with arguments" do
|
96
|
-
p = compile_to_catalog(<<-MANIFEST)
|
97
|
-
class foo($param = "value") {
|
98
|
-
notify {"$param": }
|
99
|
-
}
|
100
|
-
|
101
|
-
class {"foo": param => "bar"}
|
102
|
-
MANIFEST
|
103
|
-
|
104
|
-
r = compile_ruby_to_catalog(<<-MANIFEST)
|
105
|
-
hostclass :foo, :arguments => {:param => "value"} do
|
106
|
-
notify params[:param]
|
107
|
-
end
|
108
|
-
|
109
|
-
use :foo, :param => "bar"
|
110
|
-
MANIFEST
|
111
|
-
|
112
|
-
r.should be_equivalent_to_catalog p
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should be able to create class with arguments with default values" do
|
116
|
-
p = compile_to_catalog(<<-MANIFEST)
|
117
|
-
class foo($param = "value") {
|
118
|
-
notify {"$param": }
|
119
|
-
}
|
120
|
-
|
121
|
-
class {"foo": param => "bar"}
|
122
|
-
MANIFEST
|
123
|
-
|
124
|
-
r = compile_ruby_to_catalog(<<-MANIFEST)
|
125
|
-
hostclass :foo, :arguments => {:param => "value"} do
|
126
|
-
notify params[:param]
|
127
|
-
end
|
128
|
-
|
129
|
-
use :foo, :param => "bar"
|
130
|
-
MANIFEST
|
131
|
-
|
132
|
-
r.should be_equivalent_to_catalog p
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should allow inheritance" do
|
136
|
-
p = compile_to_catalog(<<-MANIFEST)
|
137
|
-
class foo {
|
138
|
-
notify {"foo": }
|
139
|
-
}
|
140
|
-
|
141
|
-
class bar inherits foo {
|
142
|
-
notify {"bar": }
|
143
|
-
}
|
144
|
-
MANIFEST
|
145
|
-
|
146
|
-
r = compile_ruby_to_catalog(<<-MANIFEST)
|
147
|
-
hostclass :foo do
|
148
|
-
notify "foo"
|
149
|
-
end
|
150
|
-
|
151
|
-
hostclass :bar, :inherits => :foo do
|
152
|
-
notify "bar"
|
153
|
-
end
|
154
|
-
|
155
|
-
use :bar
|
156
|
-
MANIFEST
|
157
|
-
|
158
|
-
r.should be_equivalent_to_catalog p
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should allow inheritance with arguments" do
|
162
|
-
p = compile_to_catalog(<<-MANIFEST)
|
163
|
-
class foo {
|
164
|
-
notify {"foo": }
|
165
|
-
}
|
166
|
-
|
167
|
-
class bar($msg) inherits foo {
|
168
|
-
notify {"bar": message => $msg}
|
169
|
-
}
|
170
|
-
|
171
|
-
class {"bar": msg => "foobarbaz"}
|
172
|
-
MANIFEST
|
173
|
-
|
174
|
-
r = compile_ruby_to_catalog(<<-MANIFEST)
|
175
|
-
hostclass :foo do
|
176
|
-
notify "foo"
|
177
|
-
end
|
178
|
-
|
179
|
-
hostclass :bar, :inherits => :foo, :arguments => {:msg => nil} do
|
180
|
-
notify "bar", :message => params[:msg]
|
181
|
-
end
|
182
|
-
|
183
|
-
use "bar", :msg => "foobarbaz"
|
184
|
-
MANIFEST
|
185
|
-
|
186
|
-
r.should be_equivalent_to_catalog p
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|