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
@@ -455,7 +455,6 @@ describe Puppet::Application::Agent do
|
|
455
455
|
|
456
456
|
describe "when setting up listen" do
|
457
457
|
before :each do
|
458
|
-
Puppet[:authconfig] = 'auth'
|
459
458
|
FileTest.stubs(:exists?).with('auth').returns(true)
|
460
459
|
File.stubs(:exist?).returns(true)
|
461
460
|
@puppetd.options.stubs(:[]).with(:serve).returns([])
|
@@ -208,7 +208,7 @@ describe Puppet::Application::Apply do
|
|
208
208
|
it "should raise an error if we can't find the node" do
|
209
209
|
Puppet::Node.indirection.expects(:find).returns(nil)
|
210
210
|
|
211
|
-
lambda { @apply.main }.should raise_error
|
211
|
+
lambda { @apply.main }.should raise_error(RuntimeError, /Could not find node/)
|
212
212
|
end
|
213
213
|
|
214
214
|
it "should load custom classes if loadclasses" do
|
@@ -58,9 +58,10 @@ describe Puppet::Application::FaceBase do
|
|
58
58
|
|
59
59
|
it "should stop if the first thing found is not an action" do
|
60
60
|
app.command_line.stubs(:args).returns %w{banana count_args}
|
61
|
+
|
61
62
|
expect { app.run }.to exit_with 1
|
62
|
-
|
63
|
-
@logs.
|
63
|
+
|
64
|
+
@logs.map(&:message).should == ["'basetest' has no 'banana' action. See `puppet help basetest`."]
|
64
65
|
end
|
65
66
|
|
66
67
|
it "should use the default action if not given any arguments" do
|
@@ -161,12 +162,18 @@ describe Puppet::Application::FaceBase do
|
|
161
162
|
|
162
163
|
it "does not skip when a puppet global setting is given as one item" do
|
163
164
|
app.command_line.stubs(:args).returns %w{--confdir=/tmp/puppet foo}
|
164
|
-
|
165
|
+
app.preinit
|
166
|
+
app.parse_options
|
167
|
+
app.action.name.should == :foo
|
168
|
+
app.options.should == {}
|
165
169
|
end
|
166
170
|
|
167
171
|
it "does not skip when a puppet global setting is given as two items" do
|
168
172
|
app.command_line.stubs(:args).returns %w{--confdir /tmp/puppet foo}
|
169
|
-
|
173
|
+
app.preinit
|
174
|
+
app.parse_options
|
175
|
+
app.action.name.should == :foo
|
176
|
+
app.options.should == {}
|
170
177
|
end
|
171
178
|
|
172
179
|
{ "boolean options before" => %w{--trace foo},
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
require 'spec_helper'
|
3
|
+
require 'puppet/util/command_line'
|
3
4
|
require 'puppet/application/indirection_base'
|
4
5
|
require 'puppet/indirector/face'
|
5
6
|
|
@@ -20,8 +21,6 @@ Puppet::Face.register(face)
|
|
20
21
|
########################################################################
|
21
22
|
|
22
23
|
describe Puppet::Application::IndirectionBase do
|
23
|
-
subject { Puppet::Application::TestIndirection.new }
|
24
|
-
|
25
24
|
it "should accept a terminus command line option" do
|
26
25
|
# It would be nice not to have to stub this, but whatever... writing an
|
27
26
|
# entire indirection stack would cause us more grief. --daniel 2011-03-31
|
@@ -35,14 +34,11 @@ describe Puppet::Application::IndirectionBase do
|
|
35
34
|
Puppet::Indirector::Indirection.expects(:instance).
|
36
35
|
with(:test_indirection).returns(terminus)
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
# Not a very nice thing. :(
|
41
|
-
$stderr.stubs(:puts)
|
42
|
-
Puppet.stubs(:err)
|
37
|
+
command_line = Puppet::Util::CommandLine.new("puppet", %w{test_indirection --terminus foo save bar})
|
38
|
+
application = Puppet::Application::TestIndirection.new(command_line)
|
43
39
|
|
44
40
|
expect {
|
45
|
-
|
41
|
+
application.run
|
46
42
|
}.to exit_with 0
|
47
43
|
end
|
48
44
|
end
|
@@ -14,8 +14,11 @@ describe Puppet::Application::Kick, :if => Puppet.features.posix? do
|
|
14
14
|
|
15
15
|
describe ".new" do
|
16
16
|
it "should take a command-line object as an argument" do
|
17
|
-
command_line =
|
18
|
-
|
17
|
+
command_line = Puppet::Util::CommandLine.new("puppet", ['kick', 'myhost'])
|
18
|
+
app = Puppet::Application::Kick.new(command_line)
|
19
|
+
|
20
|
+
app.command_line.subcommand_name.should == "kick"
|
21
|
+
app.command_line.args.should == ['myhost']
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
@@ -242,12 +242,6 @@ describe Puppet::Application::Master, :unless => Puppet.features.microsoft_windo
|
|
242
242
|
Puppet[:manifest] = "site.pp"
|
243
243
|
Puppet.stubs(:err)
|
244
244
|
@master.stubs(:jj)
|
245
|
-
Puppet.features.stubs(:pson?).returns true
|
246
|
-
end
|
247
|
-
|
248
|
-
it "should fail if pson isn't available" do
|
249
|
-
Puppet.features.expects(:pson?).returns false
|
250
|
-
lambda { @master.compile }.should raise_error
|
251
245
|
end
|
252
246
|
|
253
247
|
it "should compile a catalog for the specified node" do
|
@@ -17,6 +17,20 @@ describe Puppet::Application do
|
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
+
describe "application commandline" do
|
21
|
+
it "should not pick up changes to the array of arguments" do
|
22
|
+
args = %w{subcommand --arg}
|
23
|
+
command_line = Puppet::Util::CommandLine.new('puppet', args)
|
24
|
+
app = Puppet::Application.new(command_line)
|
25
|
+
|
26
|
+
args[0] = 'different_subcommand'
|
27
|
+
args[1] = '--other-arg'
|
28
|
+
|
29
|
+
app.command_line.subcommand_name.should == 'subcommand'
|
30
|
+
app.command_line.args.should == ['--arg']
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
20
34
|
describe "application defaults" do
|
21
35
|
it "should fail if required app default values are missing" do
|
22
36
|
@app.stubs(:app_defaults).returns({ :foo => 'bar' })
|
@@ -48,7 +62,9 @@ describe Puppet::Application do
|
|
48
62
|
value =~ /no such file to load|cannot load such file/
|
49
63
|
end
|
50
64
|
|
51
|
-
expect {
|
65
|
+
expect {
|
66
|
+
@klass.find("ThisShallNeverEverEverExist")
|
67
|
+
}.to raise_error(LoadError)
|
52
68
|
end
|
53
69
|
|
54
70
|
it "#12114: should prevent File namespace collisions" do
|
@@ -58,6 +74,27 @@ describe Puppet::Application do
|
|
58
74
|
end
|
59
75
|
end
|
60
76
|
|
77
|
+
describe "#available_application_names" do
|
78
|
+
it 'should be able to find available application names' do
|
79
|
+
apps = %w{describe filebucket kick queue resource agent cert apply doc master}
|
80
|
+
Puppet::Util::Autoload.expects(:files_to_load).returns(apps)
|
81
|
+
|
82
|
+
Puppet::Application.available_application_names.should =~ apps
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should find applications from multiple paths' do
|
86
|
+
Puppet::Util::Autoload.expects(:files_to_load).with('puppet/application').returns(%w{ /a/foo.rb /b/bar.rb })
|
87
|
+
|
88
|
+
Puppet::Application.available_application_names.should =~ %w{ foo bar }
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should return unique application names' do
|
92
|
+
Puppet::Util::Autoload.expects(:files_to_load).with('puppet/application').returns(%w{ /a/foo.rb /b/foo.rb })
|
93
|
+
|
94
|
+
Puppet::Application.available_application_names.should == %w{ foo }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
61
98
|
describe ".run_mode" do
|
62
99
|
it "should default to user" do
|
63
100
|
@appclass.run_mode.name.should == :user
|
@@ -103,19 +140,6 @@ describe Puppet::Application do
|
|
103
140
|
end
|
104
141
|
end
|
105
142
|
|
106
|
-
|
107
|
-
it "it should not allow initialize_app_defaults to be called multiple times" do
|
108
|
-
app = Puppet::Application.new
|
109
|
-
expect {
|
110
|
-
app.initialize_app_defaults
|
111
|
-
}.to_not raise_error
|
112
|
-
|
113
|
-
expect {
|
114
|
-
app.initialize_app_defaults
|
115
|
-
}.to raise_error
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
143
|
it "should explode when an invalid run mode is set at runtime, for great victory" do
|
120
144
|
expect {
|
121
145
|
class InvalidRunModeTestApp < Puppet::Application
|
@@ -0,0 +1,402 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet_spec/dsl'
|
3
|
+
|
4
|
+
require 'puppet/dsl/actions'
|
5
|
+
|
6
|
+
include PuppetSpec::DSL
|
7
|
+
|
8
|
+
describe Puppet::DSL::Actions do
|
9
|
+
prepare_compiler_and_scope_for_evaluation
|
10
|
+
subject { Puppet::DSL::Actions.new :undefined }
|
11
|
+
|
12
|
+
describe "#type_reference" do
|
13
|
+
it "returns a type reference object" do
|
14
|
+
evaluate_in_scope do
|
15
|
+
subject.type_reference("file").should be_a Puppet::DSL::TypeReference
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns a type reference for a given type" do
|
20
|
+
evaluate_in_scope do
|
21
|
+
subject.type_reference("file").type_name.should == "File"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#is_resource_type?" do
|
27
|
+
|
28
|
+
it "should return true when type is a class" do
|
29
|
+
evaluate_in_scope do
|
30
|
+
subject.is_resource_type?(:class).should be true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return true when type is a node" do
|
35
|
+
evaluate_in_scope do
|
36
|
+
subject.is_resource_type?(:node).should be true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return true when type is a builtin type" do
|
41
|
+
evaluate_in_scope do
|
42
|
+
subject.is_resource_type?(:file).should be true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return true when type is defined in manifests" do
|
47
|
+
evaluate_in_context { define(:foo) {} }
|
48
|
+
evaluate_in_scope do
|
49
|
+
subject.is_resource_type?(:foo).should be true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should return false otherwise" do
|
54
|
+
evaluate_in_scope do
|
55
|
+
subject.is_resource_type?(:asdasdasfasf).should be false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#is_function?" do
|
62
|
+
it "should return true when a puppet function exists" do
|
63
|
+
subject.is_function?("notice").should be true
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should return false otherwise" do
|
67
|
+
subject.is_function?("asdfasdf").should be false
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#get_resource" do
|
72
|
+
|
73
|
+
it "should return the reference if it's already a resource" do
|
74
|
+
ref = Puppet::Resource.new "foo", "bar"
|
75
|
+
subject.send(:get_resource, ref).should == ref
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should get a resource from Puppet::DSL::ResourceReference" do
|
79
|
+
res = evaluate_in_context { file "foo" }.first
|
80
|
+
ref = evaluate_in_context { type("file")["foo"] }
|
81
|
+
subject.send(:get_resource, ref).should == res
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should get a resource from a string" do
|
85
|
+
res = evaluate_in_context { file "foo" }.first
|
86
|
+
evaluate_in_scope { subject.send(:get_resource, "File[foo]").should == res }
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return a string when the string reference doesn't exist" do
|
90
|
+
reference = "File[foo]"
|
91
|
+
evaluate_in_scope { subject.send(:get_resource, reference).should == reference }
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should stringify the parameter when resource can't be found" do
|
95
|
+
evaluate_in_scope { subject.send(:get_resource, 3).should == "3" }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "#params" do
|
100
|
+
it "returns current scope" do
|
101
|
+
evaluate_in_scope do
|
102
|
+
subject.params.should == Puppet::DSL::Parser.current_scope
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#create_node" do
|
109
|
+
it "raises NoMethodError when called from invalid nesting" do
|
110
|
+
lambda do
|
111
|
+
subject.create_node "foo", {}, 1 do
|
112
|
+
end
|
113
|
+
end.should raise_error NoMethodError
|
114
|
+
end
|
115
|
+
|
116
|
+
it "raises ArgumentError when code is nil" do
|
117
|
+
lambda do
|
118
|
+
subject.create_node "foo", {}, nil, 0
|
119
|
+
end.should raise_error ArgumentError
|
120
|
+
end
|
121
|
+
|
122
|
+
it "creates a new puppet node" do
|
123
|
+
evaluate_in_scope do
|
124
|
+
subject.create_node("foo", {}, 0) {}.tap do |r|
|
125
|
+
r.type.should == :node
|
126
|
+
r.name.should == "foo"
|
127
|
+
end.should be_a Puppet::Resource::Type
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it "allows to pass a regex instead of name" do
|
132
|
+
evaluate_in_scope do
|
133
|
+
subject.create_node(/foo/, {}, 0) {}.tap do |r|
|
134
|
+
r.name_is_regex?.should be true
|
135
|
+
end.should be_a Puppet::Resource::Type
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
it "sets options for puppet node" do
|
140
|
+
evaluate_in_scope do
|
141
|
+
subject.create_node("foo", {:inherits => "bar"}, 0) {}.parent.should == "bar"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
it "adds the node to known resource types" do
|
146
|
+
evaluate_in_scope do
|
147
|
+
resource_types = mock
|
148
|
+
resource_types.expects(:add_node).with {|n| n.type == :node }
|
149
|
+
resource_types.stubs(:hostclass).returns nil
|
150
|
+
Puppet::DSL::Parser.stubs(:known_resource_types).returns resource_types
|
151
|
+
|
152
|
+
subject.create_node "foo", {}, 0 do
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
it "sets ruby code for the node" do
|
158
|
+
block = proc {}
|
159
|
+
context = mock "Context"
|
160
|
+
Puppet::DSL::Context.expects(:new).with {|code, _| code == block}.returns context
|
161
|
+
evaluate_in_scope do
|
162
|
+
subject.create_node("foo", {}, 0, &block).ruby_code.should include context
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "#create_hostclass" do
|
168
|
+
it "raises NoMethodError when called from invalid nesting" do
|
169
|
+
lambda do
|
170
|
+
subject.create_hostclass :foo, {}, 1 do
|
171
|
+
end
|
172
|
+
end.should raise_error NoMethodError
|
173
|
+
end
|
174
|
+
|
175
|
+
it "raises ArgumentError when code is nil" do
|
176
|
+
lambda do
|
177
|
+
subject.create_hostclass :foo, {}, nil, 0
|
178
|
+
end.should raise_error ArgumentError
|
179
|
+
end
|
180
|
+
|
181
|
+
it "creates a new puppet hostclass" do
|
182
|
+
evaluate_in_scope do
|
183
|
+
subject.create_hostclass(:foo, {}, 0) {}.tap do |r|
|
184
|
+
r.type.should == :hostclass
|
185
|
+
r.name.should == "foo"
|
186
|
+
end.should be_a Puppet::Resource::Type
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
it "sets options for puppet hostclass" do
|
191
|
+
evaluate_in_scope do
|
192
|
+
subject.create_hostclass(:foo, {:inherits => :bar, :arguments => {:myparam => 3}}, 0) {}.tap do |r|
|
193
|
+
r.parent.should == "bar"
|
194
|
+
r.arguments.should == {"myparam" => 3}
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
it "adds the hostclass to resource type collection" do
|
200
|
+
evaluate_in_scope do
|
201
|
+
resource_types = mock
|
202
|
+
resource_types.expects(:add_hostclass).with {|n| n.type == :hostclass }
|
203
|
+
Puppet::DSL::Parser.stubs(:known_resource_types).returns resource_types
|
204
|
+
|
205
|
+
subject.create_hostclass :foo, {}, 0 do
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
it "sets ruby code for hostclass" do
|
211
|
+
block = proc {}
|
212
|
+
context = mock "Context"
|
213
|
+
Puppet::DSL::Context.expects(:new).with {|code, _| code == block}.returns context
|
214
|
+
evaluate_in_scope do
|
215
|
+
subject.create_hostclass(:foo, {}, 0, &block).ruby_code.should include context
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe "#create_definition" do
|
221
|
+
it "raises NoMethodError when called from invalid nesting" do
|
222
|
+
lambda do
|
223
|
+
subject.create_definition :foo, {}, 1 do
|
224
|
+
end
|
225
|
+
end.should raise_error NoMethodError
|
226
|
+
end
|
227
|
+
|
228
|
+
it "raises ArgumentError when code is nil" do
|
229
|
+
lambda do
|
230
|
+
subject.create_definition :foo, {}, nil, 0
|
231
|
+
end.should raise_error ArgumentError
|
232
|
+
end
|
233
|
+
|
234
|
+
it "creates new definition" do
|
235
|
+
evaluate_in_scope do
|
236
|
+
subject.create_definition(:foo, {}, 0) {}.tap do |r|
|
237
|
+
r.should be_a Puppet::Resource::Type
|
238
|
+
r.type.should == :definition
|
239
|
+
r.name.should == "foo"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
it "set options for the definition" do
|
246
|
+
evaluate_in_scope do
|
247
|
+
subject.create_definition(:foo, {:arguments => {:param => 42}}, 0) {}.arguments.should == {"param" => 42}
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
it "adds definition to known resource types" do
|
252
|
+
evaluate_in_scope do
|
253
|
+
resource_types = mock
|
254
|
+
resource_types.expects(:add_definition).with {|n| n.type == :definition }
|
255
|
+
Puppet::DSL::Parser.stubs(:known_resource_types).returns resource_types
|
256
|
+
|
257
|
+
subject.create_definition :foo, {}, 0 do
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
it "sets ruby code for definition" do
|
264
|
+
block = proc {}
|
265
|
+
context = mock "Context"
|
266
|
+
Puppet::DSL::Context.expects(:new).with {|code, _| code == block}.returns context
|
267
|
+
evaluate_in_scope do
|
268
|
+
subject.create_definition(:foo, {}, 0, &block).ruby_code.should include context
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
describe "#create_resource" do
|
274
|
+
it "raises NoMethodError when importing" do
|
275
|
+
scope = mock
|
276
|
+
scope.stubs(:nil?).returns true
|
277
|
+
scope.stubs(:known_resource_types).returns nil
|
278
|
+
evaluate_in_scope :scope => scope do
|
279
|
+
lambda { subject.create_resource :notify, "message", {}, nil }.should raise_error NoMethodError
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
it "creates the resource when the type exists" do
|
284
|
+
scope.compiler.expects(:add_resource).with { |s, r| s == scope and r.is_a? Puppet::Parser::Resource }
|
285
|
+
|
286
|
+
evaluate_in_scope do
|
287
|
+
subject.create_resource :notify, "foo", {}, nil
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
it "returns an array of created resources" do
|
292
|
+
evaluate_in_scope do
|
293
|
+
subject.create_resource(:notify, ["foo", "bar"], {}, nil).map(&:title).should == ["foo", "bar"]
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
it "sets the passed options to it" do
|
298
|
+
evaluate_in_scope do
|
299
|
+
resource = subject.create_resource(:file, "/tmp/test", {:ensure => :present, :mode => "0666"}, nil).first
|
300
|
+
resource[:ensure].should == "present"
|
301
|
+
resource[:mode].should == "0666"
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
it "evaluates options passed in block" do
|
306
|
+
evaluate_in_scope do
|
307
|
+
block = proc do |resource|
|
308
|
+
resource.ensure = :present
|
309
|
+
resource.mode = "0666"
|
310
|
+
end
|
311
|
+
|
312
|
+
resource = subject.create_resource(:file, "/tmp/foo", {}, block).first
|
313
|
+
resource[:ensure].should == "present"
|
314
|
+
resource[:mode].should == "0666"
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
context "when virtualizing" do
|
319
|
+
it "creates virtual resource when called from virtual scope" do
|
320
|
+
evaluate_in_scope do
|
321
|
+
subject.virtualizing = true
|
322
|
+
|
323
|
+
subject.create_resource(:notify, "foo", {}, nil).first.virtual.should be true
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
it "creates virtual resource when passed virtual option" do
|
328
|
+
evaluate_in_scope do
|
329
|
+
subject.create_resource(:notify, "foo", {:virtual => true}, nil).first.virtual.should be true
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
context "when exporting" do
|
335
|
+
it "creates exported resource when called from exporting scope" do
|
336
|
+
evaluate_in_scope do
|
337
|
+
subject.exporting = true
|
338
|
+
|
339
|
+
subject.create_resource(:notify, "foo", {}, nil).first.exported.should be true
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
it "creates exported resource when passed export option" do
|
344
|
+
evaluate_in_scope do
|
345
|
+
subject.create_resource(:notify, "foo", {:export => true}, nil).first.exported.should be true
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
describe "#call_function" do
|
352
|
+
it "raises NoMethodError when importing" do
|
353
|
+
scope = mock
|
354
|
+
scope.stubs(:nil?).returns true
|
355
|
+
scope.stubs(:known_resource_types).returns nil
|
356
|
+
evaluate_in_scope :scope => scope do
|
357
|
+
lambda { subject.call_function "notice", [] }.should raise_error NoMethodError
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
it "calls the function and passes the array of arguments when it exists" do
|
362
|
+
scope.expects(:notice).with(["foo", "bar"])
|
363
|
+
evaluate_in_scope do
|
364
|
+
subject.call_function "notice", ["foo", "bar"]
|
365
|
+
end
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe "#validate_options" do
|
370
|
+
let(:attributes) { {:foo => "bar"} }
|
371
|
+
|
372
|
+
it "raises ArgumentError when invalid options are passed" do
|
373
|
+
lambda do
|
374
|
+
subject.validate_options [:asdf], attributes
|
375
|
+
end.should raise_error ArgumentError
|
376
|
+
end
|
377
|
+
|
378
|
+
it "does nothing when all attributes are valid" do
|
379
|
+
lambda do
|
380
|
+
subject.validate_options [:foo], attributes
|
381
|
+
end.should_not raise_error ArgumentError
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
it "allows to read and set exporting setting" do
|
386
|
+
subject.exporting?.should be false
|
387
|
+
subject.exporting = true
|
388
|
+
subject.exporting?.should be true
|
389
|
+
subject.exporting = false
|
390
|
+
subject.exporting?.should be false
|
391
|
+
end
|
392
|
+
|
393
|
+
it "allows to read and set virtualizing setting" do
|
394
|
+
subject.virtualizing?.should be false
|
395
|
+
subject.virtualizing = true
|
396
|
+
subject.virtualizing?.should be true
|
397
|
+
subject.virtualizing = false
|
398
|
+
subject.virtualizing?.should be false
|
399
|
+
end
|
400
|
+
|
401
|
+
end
|
402
|
+
|