puppet 3.0.2 → 3.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/Gemfile +13 -11
- data/README.md +9 -7
- data/README_DEVELOPER.md +21 -30
- data/bin/extlookup2hiera +0 -0
- data/conf/auth.conf +42 -26
- data/conf/fileserver.conf +41 -0
- data/conf/tagmail.conf +16 -0
- data/examples/hiera/modules/data/manifests/common.pp +2 -1
- data/examples/hiera/modules/ntp/manifests/config.pp +4 -3
- data/examples/hiera/modules/ntp/manifests/data.pp +2 -1
- data/examples/hiera/modules/users/manifests/common.pp +2 -1
- data/examples/hiera/modules/users/manifests/dc1.pp +2 -1
- data/examples/hiera/modules/users/manifests/development.pp +2 -1
- data/examples/hiera/site.pp +1 -1
- data/ext/debian/fileserver.conf +39 -15
- data/ext/envpuppet +2 -0
- data/ext/gentoo/puppet/fileserver.conf +41 -12
- data/ext/ips/puppet-agent +1 -6
- data/ext/ips/puppetagent.xml +0 -4
- data/ext/osx/postflight.erb +109 -0
- data/ext/project_data.yaml +2 -2
- data/ext/redhat/fileserver.conf +41 -12
- data/ext/redhat/puppet.spec.erb +8 -13
- data/install.rb +2 -5
- data/lib/puppet.rb +30 -13
- data/lib/puppet/application.rb +34 -16
- data/lib/puppet/application/agent.rb +4 -4
- data/lib/puppet/application/master.rb +25 -5
- data/lib/puppet/defaults.rb +11 -7
- data/lib/puppet/dsl.rb +7 -3
- data/lib/puppet/dsl/actions.rb +283 -0
- data/lib/puppet/dsl/blank_slate.rb +55 -0
- data/lib/puppet/dsl/context.rb +393 -0
- data/lib/puppet/dsl/parser.rb +57 -0
- data/lib/puppet/dsl/resource_decorator.rb +56 -0
- data/lib/puppet/dsl/resource_reference.rb +95 -0
- data/lib/puppet/dsl/type_reference.rb +102 -0
- data/lib/puppet/error.rb +1 -1
- data/lib/puppet/face/help.rb +2 -4
- data/lib/puppet/face/man.rb +8 -2
- data/lib/puppet/feature/pson.rb +1 -3
- data/lib/puppet/indirector/catalog/active_record.rb +3 -0
- data/lib/puppet/indirector/catalog/compiler.rb +1 -2
- data/lib/puppet/indirector/catalog/queue.rb +4 -0
- data/lib/puppet/indirector/catalog/static_compiler.rb +30 -0
- data/lib/puppet/indirector/catalog/store_configs.rb +3 -0
- data/lib/puppet/indirector/certificate_request/rest.rb +1 -0
- data/lib/puppet/indirector/certificate_revocation_list/rest.rb +1 -0
- data/lib/puppet/indirector/certificate_status/file.rb +4 -0
- data/lib/puppet/indirector/certificate_status/rest.rb +1 -0
- data/lib/puppet/indirector/facts/active_record.rb +3 -0
- data/lib/puppet/indirector/facts/couch.rb +3 -0
- data/lib/puppet/indirector/facts/inventory_active_record.rb +4 -0
- data/lib/puppet/indirector/facts/store_configs.rb +3 -0
- data/lib/puppet/indirector/file_metadata/rest.rb +2 -0
- data/lib/puppet/indirector/instrumentation_data/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_data/rest.rb +3 -0
- data/lib/puppet/indirector/instrumentation_listener/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_listener/rest.rb +3 -0
- data/lib/puppet/indirector/instrumentation_probe/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_probe/rest.rb +3 -0
- data/lib/puppet/indirector/node/active_record.rb +3 -0
- data/lib/puppet/indirector/node/rest.rb +2 -2
- data/lib/puppet/indirector/node/store_configs.rb +3 -0
- data/lib/puppet/indirector/node/write_only_yaml.rb +32 -0
- data/lib/puppet/indirector/queue.rb +0 -1
- data/lib/puppet/indirector/request.rb +1 -2
- data/lib/puppet/indirector/resource/active_record.rb +4 -0
- data/lib/puppet/indirector/resource/ral.rb +3 -0
- data/lib/puppet/indirector/resource/rest.rb +3 -0
- data/lib/puppet/indirector/resource/store_configs.rb +3 -0
- data/lib/puppet/indirector/run/local.rb +3 -0
- data/lib/puppet/indirector/ssl_file.rb +16 -14
- data/lib/puppet/indirector/status/local.rb +3 -0
- data/lib/puppet/indirector/status/rest.rb +4 -0
- data/lib/puppet/interface.rb +78 -3
- data/lib/puppet/interface/action.rb +39 -3
- data/lib/puppet/interface/action_builder.rb +74 -1
- data/lib/puppet/interface/action_manager.rb +33 -3
- data/lib/puppet/interface/documentation.rb +116 -5
- data/lib/puppet/interface/face_collection.rb +6 -7
- data/lib/puppet/interface/option.rb +10 -1
- data/lib/puppet/interface/option_builder.rb +29 -1
- data/lib/puppet/interface/option_manager.rb +21 -6
- data/lib/puppet/metatype/manager.rb +47 -9
- data/lib/puppet/module_tool.rb +0 -1
- data/lib/puppet/network/formats.rb +0 -2
- data/lib/puppet/node.rb +2 -3
- data/lib/puppet/node/environment.rb +14 -1
- data/lib/puppet/parameter.rb +309 -44
- data/lib/puppet/parameter/package_options.rb +5 -0
- data/lib/puppet/parameter/path.rb +26 -3
- data/lib/puppet/parameter/value.rb +30 -6
- data/lib/puppet/parameter/value_collection.rb +82 -20
- data/lib/puppet/parser.rb +3 -0
- data/lib/puppet/parser/ast/definition.rb +2 -5
- data/lib/puppet/parser/ast/hostclass.rb +2 -3
- data/lib/puppet/parser/ast/node.rb +2 -5
- data/lib/puppet/parser/ast/resourceparam.rb +1 -1
- data/lib/puppet/parser/compiler.rb +10 -0
- data/lib/puppet/parser/functions.rb +111 -7
- data/lib/puppet/parser/functions/create_resources.rb +23 -2
- data/lib/puppet/parser/functions/defined.rb +1 -1
- data/lib/puppet/parser/functions/extlookup.rb +2 -1
- data/lib/puppet/parser/functions/fail.rb +1 -1
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/fqdn_rand.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +1 -1
- data/lib/puppet/parser/functions/hiera.rb +1 -1
- data/lib/puppet/parser/functions/hiera_array.rb +1 -1
- data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/include.rb +1 -1
- data/lib/puppet/parser/functions/inline_template.rb +1 -1
- data/lib/puppet/parser/functions/md5.rb +1 -1
- data/lib/puppet/parser/functions/realize.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +54 -57
- data/lib/puppet/parser/functions/require.rb +1 -0
- data/lib/puppet/parser/functions/search.rb +1 -1
- data/lib/puppet/parser/functions/sha1.rb +1 -1
- data/lib/puppet/parser/functions/shellquote.rb +1 -1
- data/lib/puppet/parser/functions/split.rb +1 -2
- data/lib/puppet/parser/functions/sprintf.rb +7 -10
- data/lib/puppet/parser/functions/tag.rb +1 -1
- data/lib/puppet/parser/functions/tagged.rb +1 -1
- data/lib/puppet/parser/functions/template.rb +1 -1
- data/lib/puppet/parser/functions/versioncmp.rb +1 -5
- data/lib/puppet/parser/parser_support.rb +11 -27
- data/lib/puppet/parser/scope.rb +48 -4
- data/lib/puppet/parser/type_loader.rb +31 -7
- data/lib/puppet/property.rb +304 -70
- data/lib/puppet/property/ensure.rb +14 -1
- data/lib/puppet/property/keyvalue.rb +17 -8
- data/lib/puppet/property/list.rb +3 -0
- data/lib/puppet/property/ordered_list.rb +7 -0
- data/lib/puppet/provider.rb +275 -53
- data/lib/puppet/provider/augeas/augeas.rb +17 -3
- data/lib/puppet/provider/confiner.rb +30 -1
- data/lib/puppet/provider/group/pw.rb +2 -2
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkgin.rb +2 -0
- data/lib/puppet/provider/service/bsd.rb +1 -1
- data/lib/puppet/provider/service/freebsd.rb +10 -6
- data/lib/puppet/provider/service/init.rb +1 -1
- data/lib/puppet/provider/service/service.rb +1 -1
- data/lib/puppet/provider/user/pw.rb +2 -2
- data/lib/puppet/provider/user/useradd.rb +2 -3
- data/lib/puppet/reference/configuration.rb +6 -0
- data/lib/puppet/reports.rb +44 -4
- data/lib/puppet/reports/tagmail.rb +1 -1
- data/lib/puppet/resource.rb +38 -25
- data/lib/puppet/resource/type.rb +14 -6
- data/lib/puppet/settings.rb +66 -142
- data/lib/puppet/settings/config_file.rb +99 -0
- data/lib/puppet/settings/file_setting.rb +92 -24
- data/lib/puppet/settings/value_translator.rb +15 -0
- data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
- data/lib/puppet/test/test_helper.rb +8 -3
- data/lib/puppet/transaction.rb +1 -2
- data/lib/puppet/transaction/report.rb +122 -13
- data/lib/puppet/type.rb +763 -150
- data/lib/puppet/type/augeas.rb +4 -0
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/group.rb +1 -1
- data/lib/puppet/type/file/mode.rb +2 -0
- data/lib/puppet/type/file/selcontext.rb +1 -0
- data/lib/puppet/type/group.rb +12 -0
- data/lib/puppet/type/mount.rb +2 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/router.rb +1 -1
- data/lib/puppet/type/service.rb +1 -0
- data/lib/puppet/type/ssh_authorized_key.rb +3 -1
- data/lib/puppet/type/user.rb +8 -1
- data/lib/puppet/util.rb +8 -0
- data/lib/puppet/util/autoload.rb +7 -10
- data/lib/puppet/util/classgen.rb +58 -33
- data/lib/puppet/util/command_line.rb +120 -77
- data/lib/puppet/util/constant_inflector.rb +2 -0
- data/lib/puppet/util/execution.rb +63 -33
- data/lib/puppet/util/filetype.rb +1 -1
- data/lib/puppet/util/manifest_filetype_helper.rb +22 -0
- data/lib/puppet/util/methodhelper.rb +19 -0
- data/lib/puppet/util/monkey_patches.rb +46 -0
- data/lib/puppet/util/plugins.rb +2 -2
- data/lib/puppet/util/provider_features.rb +24 -8
- data/lib/puppet/util/rubygems.rb +8 -1
- data/lib/puppet/util/zaml.rb +1 -1
- data/lib/puppet/version.rb +74 -3
- data/spec/integration/application/apply_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +1 -0
- data/spec/integration/dsl/classes_spec.rb +191 -0
- data/spec/integration/dsl/defaults_spec.rb +38 -0
- data/spec/integration/dsl/definitions_spec.rb +73 -0
- data/spec/integration/dsl/functions_spec.rb +95 -0
- data/spec/integration/dsl/nodes_spec.rb +96 -0
- data/spec/integration/dsl/params_spec.rb +146 -0
- data/spec/integration/dsl/relationships_spec.rb +46 -0
- data/spec/integration/dsl/resources_spec.rb +202 -0
- data/spec/integration/dsl/type_loading_spec.rb +64 -0
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
- data/spec/integration/network/formats_spec.rb +32 -45
- data/spec/integration/parser/collector_spec.rb +105 -25
- data/spec/integration/parser/scope_spec.rb +64 -1
- data/spec/integration/resource/catalog_spec.rb +2 -4
- data/spec/integration/type/package_spec.rb +1 -1
- data/spec/lib/matchers/catalog.rb +50 -0
- data/spec/lib/puppet_spec/compiler.rb +11 -0
- data/spec/lib/puppet_spec/dsl.rb +29 -0
- data/spec/spec_helper.rb +17 -3
- data/spec/unit/application/agent_spec.rb +0 -1
- data/spec/unit/application/apply_spec.rb +1 -1
- data/spec/unit/application/face_base_spec.rb +11 -4
- data/spec/unit/application/indirection_base_spec.rb +4 -8
- data/spec/unit/application/kick_spec.rb +5 -2
- data/spec/unit/application/master_spec.rb +0 -6
- data/spec/unit/application_spec.rb +38 -14
- data/spec/unit/dsl/actions_spec.rb +402 -0
- data/spec/unit/dsl/blank_slate_spec.rb +27 -0
- data/spec/unit/dsl/context_spec.rb +678 -0
- data/spec/unit/dsl/parser_spec.rb +56 -0
- data/spec/unit/dsl/resource_decorator_spec.rb +94 -0
- data/spec/unit/dsl/resource_reference_spec.rb +150 -0
- data/spec/unit/dsl/type_reference_spec.rb +164 -0
- data/spec/unit/face/help_spec.rb +5 -7
- data/spec/unit/indirector/certificate_request/rest_spec.rb +4 -0
- data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +4 -0
- data/spec/unit/indirector/certificate_status/rest_spec.rb +4 -0
- data/spec/unit/indirector/file_metadata/rest_spec.rb +5 -0
- data/spec/unit/indirector/hiera_spec.rb +3 -1
- data/spec/unit/indirector/queue_spec.rb +1 -7
- data/spec/unit/indirector/ssl_file_spec.rb +66 -39
- data/spec/unit/module_spec.rb +1 -1
- data/spec/unit/network/authstore_spec.rb +22 -1
- data/spec/unit/network/formats_spec.rb +1 -1
- data/spec/unit/node/environment_spec.rb +13 -0
- data/spec/unit/parser/collector_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +26 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +12 -1
- data/spec/unit/parser/functions/extlookup_spec.rb +4 -4
- data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_spec.rb +1 -1
- data/spec/unit/parser/functions/regsubst_spec.rb +4 -4
- data/spec/unit/parser/functions/split_spec.rb +4 -4
- data/spec/unit/parser/functions/sprintf_spec.rb +2 -2
- data/spec/unit/parser/functions/versioncmp_spec.rb +4 -4
- data/spec/unit/parser/functions_spec.rb +51 -1
- data/spec/unit/parser/parser_spec.rb +0 -14
- data/spec/unit/parser/type_loader_spec.rb +15 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +31 -0
- data/spec/unit/provider/package/apt_spec.rb +0 -2
- data/spec/unit/provider/package/pip_spec.rb +12 -2
- data/spec/unit/provider/service/freebsd_spec.rb +8 -0
- data/spec/unit/provider/service/gentoo_spec.rb +20 -20
- data/spec/unit/provider/service/openrc_spec.rb +20 -20
- data/spec/unit/provider/service/src_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_spec.rb +0 -8
- data/spec/unit/provider/service/windows_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +2 -9
- data/spec/unit/relationship_spec.rb +2 -2
- data/spec/unit/resource/catalog_spec.rb +2 -2
- data/spec/unit/resource/type_spec.rb +49 -25
- data/spec/unit/resource_spec.rb +34 -2
- data/spec/unit/settings/config_file_spec.rb +100 -0
- data/spec/unit/settings/file_setting_spec.rb +87 -84
- data/spec/unit/settings/value_translator_spec.rb +77 -0
- data/spec/unit/settings_spec.rb +96 -29
- data/spec/unit/type/file/ensure_spec.rb +75 -36
- data/spec/unit/type/file_spec.rb +0 -68
- data/spec/unit/type/group_spec.rb +10 -0
- data/spec/unit/util/autoload_spec.rb +6 -0
- data/spec/unit/util/command_line_spec.rb +54 -62
- data/spec/unit/util/manifest_filetype_helper_spec.rb +29 -0
- data/spec/unit/util/metric_spec.rb +0 -9
- data/spec/unit/util/posix_spec.rb +0 -4
- data/spec/unit/util/rdoc_spec.rb +0 -12
- data/spec/unit/util/zaml_spec.rb +188 -130
- data/spec/unit/version_spec.rb +42 -0
- metadata +123 -90
- data/README_HIERA.md +0 -148
- data/conf/epm.list +0 -8
- data/conf/namespaceauth.conf +0 -20
- data/conf/puppet-queue.conf +0 -10
- data/examples/allatonce +0 -13
- data/examples/assignments +0 -11
- data/examples/components +0 -73
- data/examples/etc/init.d/sleeper +0 -70
- data/examples/etc/otherfile +0 -0
- data/examples/etc/puppet/fileserver.conf +0 -13
- data/examples/etc/puppet/namespaceauth.conf +0 -20
- data/examples/etc/puppet/puppet.conf +0 -10
- data/examples/etc/puppet/tagmail.conf +0 -1
- data/examples/execs +0 -16
- data/examples/file.bl +0 -11
- data/examples/filedefaults +0 -10
- data/examples/fileparsing +0 -116
- data/examples/filerecursion +0 -15
- data/examples/functions +0 -3
- data/examples/groups +0 -7
- data/examples/head +0 -30
- data/examples/importing +0 -8
- data/examples/mac_dscl.pp +0 -28
- data/examples/mac_dscl_revert.pp +0 -26
- data/examples/mac_pkgdmg.pp +0 -7
- data/examples/modules/sample_module.pp +0 -10
- data/examples/modules/sample_module/lib/puppet/parser/functions/hostname_to_dn.rb +0 -36
- data/examples/modules/sample_module/manifests/init.pp +0 -12
- data/examples/modules/sample_module/templates/sample.erb +0 -5
- data/examples/nodes +0 -20
- data/examples/one +0 -8
- data/examples/relationships +0 -34
- data/examples/selectors +0 -28
- data/examples/simpletests +0 -11
- data/examples/svncommit +0 -13
- data/lib/puppet/dsl/resource_api.rb +0 -120
- data/lib/puppet/dsl/resource_type_api.rb +0 -34
- data/spec/integration/parser/ruby_manifest_spec.rb +0 -127
- data/spec/unit/dsl/resource_api_spec.rb +0 -180
- data/spec/unit/dsl/resource_type_api_spec.rb +0 -53
@@ -6,7 +6,7 @@ require 'puppet/application/apply'
|
|
6
6
|
describe "apply" do
|
7
7
|
include PuppetSpec::Files
|
8
8
|
|
9
|
-
describe "when applying provided catalogs"
|
9
|
+
describe "when applying provided catalogs" do
|
10
10
|
it "should be able to apply catalogs provided in a file in pson" do
|
11
11
|
file_to_create = tmpfile("pson_catalog")
|
12
12
|
catalog = Puppet::Resource::Catalog.new
|
@@ -87,6 +87,7 @@ describe "Puppet defaults" do
|
|
87
87
|
|
88
88
|
it "should use the service user and group for the yamldir" do
|
89
89
|
Puppet.settings.stubs(:service_user_available?).returns true
|
90
|
+
Puppet.settings.stubs(:service_group_available?).returns true
|
90
91
|
Puppet.settings.setting(:yamldir).owner.should == Puppet.settings[:user]
|
91
92
|
Puppet.settings.setting(:yamldir).group.should == Puppet.settings[:group]
|
92
93
|
end
|
@@ -0,0 +1,191 @@
|
|
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
|
+
|
@@ -0,0 +1,38 @@
|
|
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
|
+
before :each do
|
12
|
+
@catalog = compile_to_catalog(<<-MANIFEST)
|
13
|
+
Notify { message => "foo" }
|
14
|
+
MANIFEST
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "defaults" do
|
18
|
+
|
19
|
+
it "should be able to update defaults for a resource" do
|
20
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
21
|
+
Notify.defaults :message => "foo"
|
22
|
+
MANIFEST
|
23
|
+
|
24
|
+
@catalog.should be_equivalent_to_catalog r
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should be able to update defaults for a resource passing a block" do
|
28
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
29
|
+
Notify.defaults do |n|
|
30
|
+
n.message = "foo"
|
31
|
+
end
|
32
|
+
MANIFEST
|
33
|
+
|
34
|
+
@catalog.should be_equivalent_to_catalog r
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'matchers/catalog'
|
3
|
+
require 'puppet_spec/compiler'
|
4
|
+
|
5
|
+
include PuppetSpec::Compiler
|
6
|
+
|
7
|
+
describe Puppet::DSL do
|
8
|
+
prepare_compiler
|
9
|
+
|
10
|
+
describe "definitions" do
|
11
|
+
|
12
|
+
it "should be able to create the definition" do
|
13
|
+
p = compile_to_catalog(<<-MANIFEST)
|
14
|
+
define foo() {
|
15
|
+
notify {"foo": }
|
16
|
+
}
|
17
|
+
MANIFEST
|
18
|
+
|
19
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
20
|
+
define :foo do
|
21
|
+
notify "foo"
|
22
|
+
end
|
23
|
+
MANIFEST
|
24
|
+
|
25
|
+
r.should be_equivalent_to_catalog p
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be able to create a resource using definition" do
|
29
|
+
p = compile_to_catalog(<<-MANIFEST)
|
30
|
+
define foo() {
|
31
|
+
notify {"foo": }
|
32
|
+
}
|
33
|
+
|
34
|
+
foo {"bar": }
|
35
|
+
MANIFEST
|
36
|
+
|
37
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
38
|
+
define :foo do
|
39
|
+
notify "foo"
|
40
|
+
end
|
41
|
+
|
42
|
+
foo "bar"
|
43
|
+
MANIFEST
|
44
|
+
r.resources.map(&:name).should include "Foo/bar"
|
45
|
+
|
46
|
+
r.should be_equivalent_to_catalog p
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should be able to create a definition with arguments" do
|
50
|
+
p = compile_to_catalog(<<-MANIFEST)
|
51
|
+
define foo($name) {
|
52
|
+
notify {"$name": }
|
53
|
+
}
|
54
|
+
|
55
|
+
foo {"bar": name => "asdf"}
|
56
|
+
MANIFEST
|
57
|
+
|
58
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
59
|
+
define :foo, :arguments => {:name => nil} do
|
60
|
+
notify params[:name]
|
61
|
+
end
|
62
|
+
|
63
|
+
foo "bar", :name => "asdf"
|
64
|
+
MANIFEST
|
65
|
+
r.resources.map(&:name).should include "Notify/asdf"
|
66
|
+
|
67
|
+
r.should be_equivalent_to_catalog p
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,95 @@
|
|
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 "functions" do
|
12
|
+
|
13
|
+
it "should be able to use a function from a node" do
|
14
|
+
p = compile_to_catalog(<<-MANIFEST)
|
15
|
+
node default {
|
16
|
+
notice("foo")
|
17
|
+
}
|
18
|
+
MANIFEST
|
19
|
+
|
20
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
21
|
+
node "default" do
|
22
|
+
notice "foo"
|
23
|
+
end
|
24
|
+
MANIFEST
|
25
|
+
|
26
|
+
r.should be_equivalent_to_catalog p
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be able to use a function from a hostclass" do
|
30
|
+
p = compile_to_catalog(<<-MANIFEST)
|
31
|
+
class foo {
|
32
|
+
notice("foo")
|
33
|
+
}
|
34
|
+
|
35
|
+
include foo
|
36
|
+
MANIFEST
|
37
|
+
|
38
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
39
|
+
hostclass :foo do
|
40
|
+
notice "foo"
|
41
|
+
end
|
42
|
+
|
43
|
+
use :foo
|
44
|
+
MANIFEST
|
45
|
+
|
46
|
+
r.should be_equivalent_to_catalog p
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should be able to use a function from a definition" do
|
50
|
+
p = compile_to_catalog(<<-MANIFEST)
|
51
|
+
define foo() {
|
52
|
+
notice("foo")
|
53
|
+
}
|
54
|
+
|
55
|
+
foo {"bar": }
|
56
|
+
MANIFEST
|
57
|
+
|
58
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
59
|
+
define :foo do
|
60
|
+
notice "foo"
|
61
|
+
end
|
62
|
+
|
63
|
+
foo "bar"
|
64
|
+
MANIFEST
|
65
|
+
|
66
|
+
r.should be_equivalent_to_catalog p
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should be able to use a function from top level scope" do
|
70
|
+
p = compile_to_catalog(<<-MANIFEST)
|
71
|
+
notice("foo")
|
72
|
+
MANIFEST
|
73
|
+
|
74
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
75
|
+
notice "foo"
|
76
|
+
MANIFEST
|
77
|
+
|
78
|
+
r.should be_equivalent_to_catalog p
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should be able to pass parameters to the function" do
|
82
|
+
p = compile_to_catalog(<<-MANIFEST)
|
83
|
+
notice("foo", "bar", 3)
|
84
|
+
MANIFEST
|
85
|
+
|
86
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
87
|
+
notice "foo", "bar", 3
|
88
|
+
MANIFEST
|
89
|
+
|
90
|
+
r.should be_equivalent_to_catalog p
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,96 @@
|
|
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 "nodes" do
|
12
|
+
|
13
|
+
it "should be able to create default node" do
|
14
|
+
p = compile_to_catalog(<<-MANIFEST)
|
15
|
+
node default {
|
16
|
+
notify{"foo": }
|
17
|
+
}
|
18
|
+
MANIFEST
|
19
|
+
|
20
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
21
|
+
node "default" do
|
22
|
+
notify "foo"
|
23
|
+
end
|
24
|
+
MANIFEST
|
25
|
+
r.resources.map(&:name).should include "Notify/foo"
|
26
|
+
|
27
|
+
r.should be_equivalent_to_catalog p
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be able to create named node" do
|
31
|
+
p = compile_to_catalog(<<-MANIFEST)
|
32
|
+
node "foonode" {
|
33
|
+
notify{"foo": }
|
34
|
+
}
|
35
|
+
MANIFEST
|
36
|
+
|
37
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
38
|
+
node "foonode" do
|
39
|
+
notify "foo"
|
40
|
+
end
|
41
|
+
MANIFEST
|
42
|
+
r.resources.map(&:name).should include "Notify/foo"
|
43
|
+
|
44
|
+
r.should be_equivalent_to_catalog p
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should be able to create node with regexp" do
|
48
|
+
p = compile_to_catalog(<<-MANIFEST)
|
49
|
+
node /^foo/ {
|
50
|
+
notify{"foo": }
|
51
|
+
}
|
52
|
+
MANIFEST
|
53
|
+
|
54
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
55
|
+
node /^foo/ do
|
56
|
+
notify "foo"
|
57
|
+
end
|
58
|
+
MANIFEST
|
59
|
+
r.resources.map(&:name).should include "Notify/foo"
|
60
|
+
|
61
|
+
r.should be_equivalent_to_catalog p
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should be able to create node inheriting from another node" do
|
65
|
+
p = compile_to_catalog(<<-MANIFEST)
|
66
|
+
node "base.example.com" {
|
67
|
+
notify {"base": }
|
68
|
+
}
|
69
|
+
|
70
|
+
node "foonode" inherits "base.example.com" {
|
71
|
+
notify {"foonode": }
|
72
|
+
}
|
73
|
+
MANIFEST
|
74
|
+
|
75
|
+
r = compile_ruby_to_catalog(<<-MANIFEST)
|
76
|
+
node "base.example.com" do
|
77
|
+
notify "base"
|
78
|
+
end
|
79
|
+
|
80
|
+
node "foonode", :inherits => "base.example.com" do
|
81
|
+
notify "foonode"
|
82
|
+
end
|
83
|
+
MANIFEST
|
84
|
+
|
85
|
+
r.resources.map(&:name).tap do |names|
|
86
|
+
%w[base foonode].each do |node_name|
|
87
|
+
names.should include "Notify/#{node_name}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
r.should be_equivalent_to_catalog p
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|