puppet 4.10.9 → 4.10.10
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.
- checksums.yaml +4 -4
- data/lib/puppet/agent.rb +22 -2
- data/lib/puppet/application.rb +18 -1
- data/lib/puppet/application/agent.rb +9 -2
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/application/config.rb +1 -0
- data/lib/puppet/application/device.rb +1 -2
- data/lib/puppet/application/filebucket.rb +22 -5
- data/lib/puppet/application/help.rb +1 -0
- data/lib/puppet/application/inspect.rb +2 -0
- data/lib/puppet/application/lookup.rb +1 -3
- data/lib/puppet/application_support.rb +6 -1
- data/lib/puppet/defaults.rb +33 -4
- data/lib/puppet/face/config.rb +13 -0
- data/lib/puppet/functions/each.rb +10 -4
- data/lib/puppet/functions/lookup.rb +2 -2
- data/lib/puppet/functions/map.rb +12 -2
- data/lib/puppet/functions/reduce.rb +45 -2
- data/lib/puppet/interface.rb +1 -0
- data/lib/puppet/module_tool/tar/mini.rb +57 -4
- data/lib/puppet/network/http/factory.rb +9 -0
- data/lib/puppet/network/http/webrick.rb +1 -3
- data/lib/puppet/node.rb +10 -0
- data/lib/puppet/node/facts.rb +9 -0
- data/lib/puppet/parser/functions/sprintf.rb +17 -3
- data/lib/puppet/pops/loader/static_loader.rb +2 -2
- data/lib/puppet/pops/lookup/hiera_config.rb +2 -2
- data/lib/puppet/pops/merge_strategy.rb +16 -1
- data/lib/puppet/pops/types/iterable.rb +2 -0
- data/lib/puppet/pops/types/type_factory.rb +1 -1
- data/lib/puppet/pops/types/type_mismatch_describer.rb +15 -5
- data/lib/puppet/pops/types/types.rb +4 -2
- data/lib/puppet/provider/service/smf.rb +2 -2
- data/lib/puppet/provider/service/systemd.rb +1 -0
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +10 -2
- data/lib/puppet/transaction.rb +3 -0
- data/lib/puppet/transaction/report.rb +8 -1
- data/lib/puppet/type.rb +1 -9
- data/lib/puppet/type/user.rb +9 -3
- data/lib/puppet/util/http_proxy.rb +14 -6
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +29 -13
- data/man/man5/puppet.conf.5 +276 -55
- data/man/man8/extlookup2hiera.8 +2 -2
- data/man/man8/puppet-agent.8 +32 -10
- data/man/man8/puppet-apply.8 +21 -6
- data/man/man8/puppet-ca.8 +48 -34
- data/man/man8/puppet-catalog.8 +4 -4
- data/man/man8/puppet-cert.8 +23 -6
- data/man/man8/puppet-certificate.8 +44 -28
- data/man/man8/puppet-certificate_request.8 +4 -4
- data/man/man8/puppet-certificate_revocation_list.8 +4 -4
- data/man/man8/puppet-config.8 +5 -5
- data/man/man8/puppet-describe.8 +3 -3
- data/man/man8/puppet-device.8 +23 -13
- data/man/man8/puppet-doc.8 +5 -5
- data/man/man8/puppet-epp.8 +16 -10
- data/man/man8/puppet-facts.8 +4 -4
- data/man/man8/puppet-file.8 +4 -4
- data/man/man8/puppet-filebucket.8 +63 -6
- data/man/man8/puppet-generate.8 +84 -0
- data/man/man8/puppet-help.8 +4 -4
- data/man/man8/puppet-inspect.8 +8 -5
- data/man/man8/puppet-key.8 +4 -4
- data/man/man8/puppet-lookup.8 +87 -0
- data/man/man8/puppet-man.8 +5 -5
- data/man/man8/puppet-master.8 +5 -5
- data/man/man8/puppet-module.8 +22 -13
- data/man/man8/puppet-node.8 +4 -4
- data/man/man8/puppet-parser.8 +4 -4
- data/man/man8/puppet-plugin.8 +4 -4
- data/man/man8/puppet-report.8 +4 -4
- data/man/man8/puppet-resource.8 +4 -8
- data/man/man8/puppet-resource_type.8 +4 -4
- data/man/man8/puppet-status.8 +5 -5
- data/man/man8/puppet.8 +12 -3
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +2 -0
- data/spec/integration/agent/logging_spec.rb +2 -0
- data/spec/integration/provider/cron/crontab_spec.rb +1 -0
- data/spec/unit/agent_spec.rb +33 -0
- data/spec/unit/application/config_spec.rb +4 -0
- data/spec/unit/application/inspect_spec.rb +11 -0
- data/spec/unit/application/lookup_spec.rb +30 -0
- data/spec/unit/application_spec.rb +18 -0
- data/spec/unit/environments_spec.rb +15 -0
- data/spec/unit/face/config_spec.rb +1 -2
- data/spec/unit/functions/break_spec.rb +108 -49
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/lookup_spec.rb +88 -3
- data/spec/unit/interface_spec.rb +12 -0
- data/spec/unit/module_tool/tar/mini_spec.rb +34 -5
- data/spec/unit/network/http/factory_spec.rb +22 -0
- data/spec/unit/network/http/webrick_spec.rb +30 -29
- data/spec/unit/parser/functions/sprintf_spec.rb +26 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
- data/spec/unit/pops/types/type_calculator_spec.rb +21 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +9 -0
- data/spec/unit/provider/service/smf_spec.rb +2 -4
- data/spec/unit/provider/service/systemd_spec.rb +14 -0
- data/spec/unit/resource/catalog_spec.rb +10 -0
- data/spec/unit/transaction/report_spec.rb +19 -0
- data/spec/unit/util/http_proxy_spec.rb +37 -0
- metadata +4 -2
data/man/man8/puppet-parser.8
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
|
-
.\"
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "PUPPET\-PARSER" "8" "
|
4
|
+
.TH "PUPPET\-PARSER" "8" "January 2018" "Puppet Labs, LLC" "Puppet manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBpuppet\-parser\fR \- Interact directly with the parser\.
|
@@ -13,7 +13,7 @@ puppet parser \fIaction\fR
|
|
13
13
|
Note that any setting that\'s valid in the configuration file is also a valid long argument, although it may or may not be relevant to the present action\. For example, \fBserver\fR and \fBrun_mode\fR are valid settings, so you can specify \fB\-\-server <servername>\fR, or \fB\-\-run_mode <runmode>\fR as an argument\.
|
14
14
|
.
|
15
15
|
.P
|
16
|
-
See the configuration file documentation at \fIhttps://docs\.puppetlabs\.com/
|
16
|
+
See the configuration file documentation at \fIhttps://docs\.puppetlabs\.com/puppet/latest/reference/configuration\.html\fR for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \fB\-\-genconfig\fR\.
|
17
17
|
.
|
18
18
|
.TP
|
19
19
|
\-\-render\-as FORMAT
|
@@ -104,4 +104,4 @@ Validate from STDIN:
|
|
104
104
|
$ cat init\.pp | puppet parser validate
|
105
105
|
.
|
106
106
|
.SH "COPYRIGHT AND LICENSE"
|
107
|
-
Copyright 2014 by Puppet
|
107
|
+
Copyright 2014 by Puppet Inc\. Apache 2 license; see COPYING
|
data/man/man8/puppet-plugin.8
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
|
-
.\"
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "PUPPET\-PLUGIN" "8" "
|
4
|
+
.TH "PUPPET\-PLUGIN" "8" "January 2018" "Puppet Labs, LLC" "Puppet manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBpuppet\-plugin\fR \- Interact with the Puppet plugin system\.
|
@@ -19,7 +19,7 @@ The puppet master serves Ruby code collected from the \fBlib\fR directories of i
|
|
19
19
|
Note that any setting that\'s valid in the configuration file is also a valid long argument, although it may or may not be relevant to the present action\. For example, \fBserver\fR and \fBrun_mode\fR are valid settings, so you can specify \fB\-\-server <servername>\fR, or \fB\-\-run_mode <runmode>\fR as an argument\.
|
20
20
|
.
|
21
21
|
.P
|
22
|
-
See the configuration file documentation at \fIhttps://docs\.puppetlabs\.com/
|
22
|
+
See the configuration file documentation at \fIhttps://docs\.puppetlabs\.com/puppet/latest/reference/configuration\.html\fR for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \fB\-\-genconfig\fR\.
|
23
23
|
.
|
24
24
|
.TP
|
25
25
|
\-\-render\-as FORMAT
|
@@ -70,4 +70,4 @@ Retrieve plugins from the puppet master (API example):
|
|
70
70
|
$ Puppet::Face[:plugin, \'0\.0\.1\']\.download
|
71
71
|
.
|
72
72
|
.SH "COPYRIGHT AND LICENSE"
|
73
|
-
Copyright 2011 by Puppet
|
73
|
+
Copyright 2011 by Puppet Inc\. Apache 2 license; see COPYING
|
data/man/man8/puppet-report.8
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
|
-
.\"
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "PUPPET\-REPORT" "8" "
|
4
|
+
.TH "PUPPET\-REPORT" "8" "January 2018" "Puppet Labs, LLC" "Puppet manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBpuppet\-report\fR \- Create, display, and submit reports\.
|
@@ -13,7 +13,7 @@ puppet report \fIaction\fR [\-\-terminus TERMINUS] [\-\-extra HASH]
|
|
13
13
|
Note that any setting that\'s valid in the configuration file is also a valid long argument, although it may or may not be relevant to the present action\. For example, \fBserver\fR and \fBrun_mode\fR are valid settings, so you can specify \fB\-\-server <servername>\fR, or \fB\-\-run_mode <runmode>\fR as an argument\.
|
14
14
|
.
|
15
15
|
.P
|
16
|
-
See the configuration file documentation at \fIhttps://docs\.puppetlabs\.com/
|
16
|
+
See the configuration file documentation at \fIhttps://docs\.puppetlabs\.com/puppet/latest/reference/configuration\.html\fR for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \fB\-\-genconfig\fR\.
|
17
17
|
.
|
18
18
|
.TP
|
19
19
|
\-\-render\-as FORMAT
|
@@ -121,4 +121,4 @@ This subcommand is an indirector face, which exposes \fBfind\fR, \fBsearch\fR, \
|
|
121
121
|
.IP "" 0
|
122
122
|
.
|
123
123
|
.SH "COPYRIGHT AND LICENSE"
|
124
|
-
Copyright 2011 by Puppet
|
124
|
+
Copyright 2011 by Puppet Inc\. Apache 2 license; see COPYING
|
data/man/man8/puppet-resource.8
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
|
-
.\"
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "PUPPET\-RESOURCE" "8" "
|
4
|
+
.TH "PUPPET\-RESOURCE" "8" "January 2018" "Puppet Labs, LLC" "Puppet manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBpuppet\-resource\fR \- The resource abstraction layer shell
|
@@ -25,7 +25,7 @@ If given a type, a name, and a series of \fIattribute\fR=\fIvalue\fR pairs, pupp
|
|
25
25
|
Note that any setting that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid setting, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\.
|
26
26
|
.
|
27
27
|
.P
|
28
|
-
See the configuration file documentation at https://docs\.puppetlabs\.com/
|
28
|
+
See the configuration file documentation at https://docs\.puppetlabs\.com/puppet/latest/reference/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \'\-\-genconfig\'\.
|
29
29
|
.
|
30
30
|
.TP
|
31
31
|
\-\-debug
|
@@ -36,10 +36,6 @@ Enable full debugging\.
|
|
36
36
|
Write the results of the query to a file, open the file in an editor, and read the file back in as an executable Puppet manifest\.
|
37
37
|
.
|
38
38
|
.TP
|
39
|
-
\-\-host
|
40
|
-
When specified, connect to the resource server on the named host and retrieve the list of resouces of the type specified\.
|
41
|
-
.
|
42
|
-
.TP
|
43
39
|
\-\-help
|
44
40
|
Print this help message\.
|
45
41
|
.
|
@@ -85,4 +81,4 @@ user { \'luke\':
|
|
85
81
|
Luke Kanies
|
86
82
|
.
|
87
83
|
.SH "COPYRIGHT"
|
88
|
-
Copyright (c) 2011 Puppet
|
84
|
+
Copyright (c) 2011 Puppet Inc\., LLC Licensed under the Apache 2\.0 License
|
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
|
-
.\"
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "PUPPET\-RESOURCE_TYPE" "8" "
|
4
|
+
.TH "PUPPET\-RESOURCE_TYPE" "8" "January 2018" "Puppet Labs, LLC" "Puppet manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBpuppet\-resource_type\fR \- View classes, defined resource types, and nodes from all manifests\.
|
@@ -19,7 +19,7 @@ It will eventually be extended to examine native resource types\.
|
|
19
19
|
Note that any setting that\'s valid in the configuration file is also a valid long argument, although it may or may not be relevant to the present action\. For example, \fBserver\fR and \fBrun_mode\fR are valid settings, so you can specify \fB\-\-server <servername>\fR, or \fB\-\-run_mode <runmode>\fR as an argument\.
|
20
20
|
.
|
21
21
|
.P
|
22
|
-
See the configuration file documentation at \fIhttps://docs\.puppetlabs\.com/
|
22
|
+
See the configuration file documentation at \fIhttps://docs\.puppetlabs\.com/puppet/latest/reference/configuration\.html\fR for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \fB\-\-genconfig\fR\.
|
23
23
|
.
|
24
24
|
.TP
|
25
25
|
\-\-render\-as FORMAT
|
@@ -185,4 +185,4 @@ This subcommand is an indirector face, which exposes \fBfind\fR, \fBsearch\fR, \
|
|
185
185
|
.IP "" 0
|
186
186
|
.
|
187
187
|
.SH "COPYRIGHT AND LICENSE"
|
188
|
-
Copyright 2011 by Puppet
|
188
|
+
Copyright 2011 by Puppet Inc\. Apache 2 license; see COPYING
|
data/man/man8/puppet-status.8
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
|
-
.\"
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "PUPPET\-STATUS" "8" "
|
4
|
+
.TH "PUPPET\-STATUS" "8" "January 2018" "Puppet Labs, LLC" "Puppet manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBpuppet\-status\fR \- View puppet server status\.
|
@@ -13,7 +13,7 @@ puppet status \fIaction\fR [\-\-terminus TERMINUS] [\-\-extra HASH]
|
|
13
13
|
Note that any setting that\'s valid in the configuration file is also a valid long argument, although it may or may not be relevant to the present action\. For example, \fBserver\fR and \fBrun_mode\fR are valid settings, so you can specify \fB\-\-server <servername>\fR, or \fB\-\-run_mode <runmode>\fR as an argument\.
|
14
14
|
.
|
15
15
|
.P
|
16
|
-
See the configuration file documentation at \fIhttps://docs\.puppetlabs\.com/
|
16
|
+
See the configuration file documentation at \fIhttps://docs\.puppetlabs\.com/puppet/latest/reference/configuration\.html\fR for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \fB\-\-genconfig\fR\.
|
17
17
|
.
|
18
18
|
.TP
|
19
19
|
\-\-render\-as FORMAT
|
@@ -69,7 +69,7 @@ A "true" response or a low\-level connection error\. When used from the Ruby API
|
|
69
69
|
\fBNOTES\fR
|
70
70
|
.
|
71
71
|
.IP
|
72
|
-
This action requires that the server\'s \fBauth\.conf\fR file allow find access to the \fBstatus\fR REST terminus\. Puppet agent does not use this facility, and it is turned off by default\. See \fIhttps://docs\.puppetlabs\.com/
|
72
|
+
This action requires that the server\'s \fBauth\.conf\fR file allow find access to the \fBstatus\fR REST terminus\. Puppet agent does not use this facility, and it is turned off by default\. See \fIhttps://docs\.puppetlabs\.com/puppet/latest/reference/config_file_auth\.html\fR for more details\.
|
73
73
|
.
|
74
74
|
.TP
|
75
75
|
\fBinfo\fR \- Print the default terminus class for this face\.
|
@@ -105,4 +105,4 @@ This subcommand is an indirector face, which exposes \fBfind\fR, \fBsearch\fR, \
|
|
105
105
|
.IP "" 0
|
106
106
|
.
|
107
107
|
.SH "COPYRIGHT AND LICENSE"
|
108
|
-
Copyright 2011 by Puppet
|
108
|
+
Copyright 2011 by Puppet Inc\. Apache 2 license; see COPYING
|
data/man/man8/puppet.8
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
|
-
.\"
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "PUPPET" "8" "
|
4
|
+
.TH "PUPPET" "8" "January 2018" "Puppet Labs, LLC" "Puppet manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBpuppet\fR
|
8
8
|
.
|
9
9
|
.P
|
10
|
-
|
10
|
+
Usage: puppet \fIsubcommand\fR [options] \fIaction\fR [options]
|
11
|
+
.
|
12
|
+
.P
|
13
|
+
Available subcommands:
|
14
|
+
.
|
15
|
+
.P
|
16
|
+
agent The puppet agent daemon apply Apply Puppet manifests locally ca Local Puppet Certificate Authority management\. (Deprecated) catalog Compile, save, view, and convert catalogs\. cert Manage certificates and requests certificate Provide access to the CA for certificate management\. certificate_request Manage certificate requests\. (Deprecated) certificate_revocation_list Manage the list of revoked certificates\. (Deprecated) config Interact with Puppet\'s settings\. describe Display help about resource types device Manage remote network devices doc Generate Puppet references epp Interact directly with the EPP template parser/renderer\. facts Retrieve and store facts\. file Retrieve and store files in a filebucket (Deprecated) filebucket Store and retrieve files in a filebucket generate Generates Puppet code from Ruby definitions\. help Display Puppet help\. inspect Send an inspection report key Create, save, and remove certificate keys\. (Deprecated) lookup Data in modules lookup function man Display Puppet manual pages\. master The puppet master daemon module Creates, installs and searches for modules on the Puppet Forge\. node View and manage node definitions\. parser Interact directly with the parser\. plugin Interact with the Puppet plugin system\. report Create, display, and submit reports\. resource The resource abstraction layer shell resource_type View classes, defined resource types, and nodes from all manifests\. status View puppet server status\. (Deprecated)
|
17
|
+
.
|
18
|
+
.P
|
19
|
+
See \'puppet help \fIsubcommand\fR \fIaction\fR\' for help on a specific subcommand action\. See \'puppet help \fIsubcommand\fR\' for help on a specific subcommand\. Puppet v4\.10\.9
|
@@ -71,6 +71,8 @@ describe 'agent logging' do
|
|
71
71
|
before(:each) do
|
72
72
|
# Don't actually run the agent, bypassing cert checks, forking and the puppet run itself
|
73
73
|
Puppet::Application::Agent.any_instance.stubs(:run_command)
|
74
|
+
# Let exceptions be raised instead of exiting
|
75
|
+
Puppet::Application::Agent.any_instance.stubs(:exit_on_fail).yields
|
74
76
|
end
|
75
77
|
|
76
78
|
def double_of_bin_puppet_agent_call(argv)
|
@@ -10,6 +10,7 @@ describe Puppet::Type.type(:cron).provider(:crontab), '(integration)', :unless =
|
|
10
10
|
|
11
11
|
before :each do
|
12
12
|
Puppet::Type.type(:cron).stubs(:defaultprovider).returns described_class
|
13
|
+
described_class.stubs(:suitable?).returns true
|
13
14
|
Puppet::FileBucket::Dipper.any_instance.stubs(:backup) # Don't backup to filebucket
|
14
15
|
|
15
16
|
# I don't want to execute anything
|
data/spec/unit/agent_spec.rb
CHANGED
@@ -236,6 +236,39 @@ describe Puppet::Agent do
|
|
236
236
|
expect(agent.should_fork).to be_falsey
|
237
237
|
end
|
238
238
|
end
|
239
|
+
|
240
|
+
describe 'when runtimeout is set' do
|
241
|
+
before(:each) do
|
242
|
+
Puppet[:runtimeout] = 1
|
243
|
+
end
|
244
|
+
|
245
|
+
it 'times out when a run exceeds the set limit' do
|
246
|
+
client = AgentTestClient.new
|
247
|
+
client.instance_eval do
|
248
|
+
# Stub methods used to set test expectations.
|
249
|
+
def processing; end
|
250
|
+
def handling; end
|
251
|
+
|
252
|
+
def run(client_options = {})
|
253
|
+
# Simulate a hanging agent operation that also traps errors.
|
254
|
+
begin
|
255
|
+
::Kernel.sleep(5)
|
256
|
+
processing()
|
257
|
+
rescue
|
258
|
+
handling()
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
AgentTestClient.expects(:new).returns client
|
264
|
+
|
265
|
+
client.expects(:processing).never
|
266
|
+
client.expects(:handling).never
|
267
|
+
Puppet.expects(:log_exception).with(instance_of(Puppet::Agent::RunTimeoutError), anything)
|
268
|
+
|
269
|
+
expect(@agent.run).to eq(1)
|
270
|
+
end
|
271
|
+
end
|
239
272
|
end
|
240
273
|
|
241
274
|
describe "when checking execution state" do
|
@@ -6,4 +6,8 @@ describe Puppet::Application::Config do
|
|
6
6
|
it "should be a subclass of Puppet::Application::FaceBase" do
|
7
7
|
expect(Puppet::Application::Config.superclass).to equal(Puppet::Application::FaceBase)
|
8
8
|
end
|
9
|
+
|
10
|
+
it "should set `environment_mode` to :not_required" do
|
11
|
+
expect(Puppet::Application::Config.get_environment_mode).to equal(:not_required)
|
12
|
+
end
|
9
13
|
end
|
@@ -70,6 +70,17 @@ describe Puppet::Application::Inspect do
|
|
70
70
|
@inspect.run_command
|
71
71
|
end
|
72
72
|
|
73
|
+
it "should not fail if no resource failed" do
|
74
|
+
Puppet::Resource::Catalog::Json.any_instance.stubs(:find).returns(Puppet::Resource::Catalog.new)
|
75
|
+
Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request|
|
76
|
+
@report = request.instance
|
77
|
+
end
|
78
|
+
|
79
|
+
@inspect.run_command
|
80
|
+
|
81
|
+
expect(@report.status).to eq("unchanged")
|
82
|
+
end
|
83
|
+
|
73
84
|
with_digest_algorithms do
|
74
85
|
it "should audit the specified properties" do
|
75
86
|
catalog = Puppet::Resource::Catalog.new
|
@@ -498,6 +498,8 @@ Searching for "a"
|
|
498
498
|
end
|
499
499
|
|
500
500
|
context 'the global scope' do
|
501
|
+
include PuppetSpec::Files
|
502
|
+
|
501
503
|
it "is unaffected by global variables unless '--compile' is used" do
|
502
504
|
lookup.options[:node] = node
|
503
505
|
lookup.command_line.stubs(:args).returns(['c'])
|
@@ -510,6 +512,34 @@ Searching for "a"
|
|
510
512
|
lookup.command_line.stubs(:args).returns(['c'])
|
511
513
|
expect(run_lookup(lookup)).to eql("--- This is C from site.pp\n...")
|
512
514
|
end
|
515
|
+
|
516
|
+
it 'receives extra facts in top scope' do
|
517
|
+
file_path = tmpdir('lookup_spec')
|
518
|
+
filename = File.join(file_path, "facts.yaml")
|
519
|
+
File.open(filename, "w+") { |f| f.write(<<-YAML.unindent) }
|
520
|
+
---
|
521
|
+
cx: ' C from facts'
|
522
|
+
YAML
|
523
|
+
|
524
|
+
lookup.options[:node] = node
|
525
|
+
lookup.options[:fact_file] = filename
|
526
|
+
lookup.command_line.stubs(:args).returns(['c'])
|
527
|
+
expect(run_lookup(lookup)).to eql("--- This is C from facts\n...")
|
528
|
+
end
|
529
|
+
|
530
|
+
it 'receives extra facts in the facts hash' do
|
531
|
+
file_path = tmpdir('lookup_spec')
|
532
|
+
filename = File.join(file_path, "facts.yaml")
|
533
|
+
File.open(filename, "w+") { |f| f.write(<<-YAML.unindent) }
|
534
|
+
---
|
535
|
+
cx: ' G from facts'
|
536
|
+
YAML
|
537
|
+
|
538
|
+
lookup.options[:node] = node
|
539
|
+
lookup.options[:fact_file] = filename
|
540
|
+
lookup.command_line.stubs(:args).returns(['g'])
|
541
|
+
expect(run_lookup(lookup)).to eql("--- This is G from facts in facts hash\n...")
|
542
|
+
end
|
513
543
|
end
|
514
544
|
|
515
545
|
context 'using a puppet function as data provider' do
|
@@ -105,6 +105,24 @@ describe Puppet::Application do
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
+
describe ".environment_mode" do
|
109
|
+
it "should default to :local" do
|
110
|
+
expect(@appclass.get_environment_mode).to eq(:local)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should set and get a value" do
|
114
|
+
@appclass.environment_mode :remote
|
115
|
+
expect(@appclass.get_environment_mode).to eq(:remote)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should error if given a random symbol" do
|
119
|
+
expect{@appclass.environment_mode :foo}.to raise_error(/Invalid environment mode/)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should error if given a string" do
|
123
|
+
expect{@appclass.environment_mode 'local'}.to raise_error(/Invalid environment mode/)
|
124
|
+
end
|
125
|
+
end
|
108
126
|
|
109
127
|
|
110
128
|
# These tests may look a little weird and repetative in its current state;
|
@@ -209,6 +209,20 @@ static_catalogs=false
|
|
209
209
|
end
|
210
210
|
|
211
211
|
it "logs a warning, but processes the main settings if there are any extraneous settings" do
|
212
|
+
content << "dog=arf\n"
|
213
|
+
content << "cat=mew\n"
|
214
|
+
loader_from(:filesystem => [envdir, manifestdir, modulepath].flatten,
|
215
|
+
:directory => envdir) do |loader|
|
216
|
+
expect(loader.get("env1")).to environment(:env1).
|
217
|
+
with_manifest(manifestdir.path).
|
218
|
+
with_modulepath(modulepath.map(&:path)).
|
219
|
+
with_config_version(File.expand_path('/some/script'))
|
220
|
+
end
|
221
|
+
|
222
|
+
expect(@logs.map(&:to_s).join).to match(/Invalid.*at.*\/env1.*unknown setting.*dog, cat/)
|
223
|
+
end
|
224
|
+
|
225
|
+
it "logs a warning, but processes the main settings if there are any ignored sections" do
|
212
226
|
content << "dog=arf\n"
|
213
227
|
content << "cat=mew\n"
|
214
228
|
content << "[ignored]\n"
|
@@ -221,6 +235,7 @@ static_catalogs=false
|
|
221
235
|
with_config_version(File.expand_path('/some/script'))
|
222
236
|
end
|
223
237
|
|
238
|
+
expect(@logs.map(&:to_s).join).to match(/Invalid.*at.*\/env1.*The following sections are being ignored: 'ignored'/)
|
224
239
|
expect(@logs.map(&:to_s).join).to match(/Invalid.*at.*\/env1.*unknown setting.*dog, cat/)
|
225
240
|
end
|
226
241
|
|
@@ -139,7 +139,6 @@ basemodulepath = #{File.expand_path("/some/base")}
|
|
139
139
|
end
|
140
140
|
|
141
141
|
it "prints the default configured env settings for an env that does not exist" do
|
142
|
-
pending "This case no longer exists because Application will through an error before we even get here because of the non-existent environment"
|
143
142
|
Puppet[:environment] = 'doesnotexist'
|
144
143
|
|
145
144
|
FS.overlay(
|
@@ -150,7 +149,7 @@ basemodulepath = #{File.expand_path("/some/base")}
|
|
150
149
|
args = "environmentpath","manifest","modulepath","environment","basemodulepath"
|
151
150
|
expect { subject.print(*add_section_option(args, section)) }.to have_printed(<<-OUTPUT)
|
152
151
|
environmentpath = #{File.expand_path("/dev/null/environments")}
|
153
|
-
manifest =
|
152
|
+
manifest =
|
154
153
|
modulepath =
|
155
154
|
environment = doesnotexist
|
156
155
|
basemodulepath = #{File.expand_path("/some/base")}
|
@@ -8,7 +8,7 @@ describe 'the break function' do
|
|
8
8
|
include Matchers::Resource
|
9
9
|
|
10
10
|
context do
|
11
|
-
it 'breaks iteration as if at end of input' do
|
11
|
+
it 'breaks iteration as if at end of input in a map for an array' do
|
12
12
|
expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[[1, 2]]')
|
13
13
|
function please_break() {
|
14
14
|
[1,2,3].map |$x| { if $x == 3 { break() } $x }
|
@@ -16,24 +16,82 @@ describe 'the break function' do
|
|
16
16
|
notify { String(please_break()): }
|
17
17
|
CODE
|
18
18
|
end
|
19
|
-
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
20
|
+
it 'breaks iteration as if at end of input in a map for a hash' do
|
21
|
+
expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[[1, 2]]')
|
22
|
+
function please_break() {
|
23
|
+
{'a' => 1, 'b' => 2, 'c' => 3}.map |$x, $y| { if $y == 3 { break() } $y }
|
24
|
+
}
|
25
|
+
notify { String(please_break()): }
|
26
|
+
CODE
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'breaks iteration as if at end of input in a reduce for an array' do
|
30
|
+
expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[6]')
|
31
|
+
function please_break() {
|
32
|
+
[1,2,3,4].reduce |$memo, $x| { if $x == 4 { break() } $memo + $x }
|
33
|
+
}
|
34
|
+
notify { String(please_break()): }
|
35
|
+
CODE
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'breaks iteration as if at end of input in a reduce for a hash' do
|
39
|
+
expect(compile_to_catalog(<<-CODE)).to have_resource("Notify[['abc', 6]]")
|
40
|
+
function please_break() {
|
41
|
+
{'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4}.reduce |$memo, $x| {
|
42
|
+
if $x[1] == 4 { break() }
|
43
|
+
$string = "${memo[0]}${x[0]}"
|
44
|
+
$number = $memo[1] + $x[1]
|
45
|
+
[$string, $number]
|
46
|
+
}
|
47
|
+
}
|
48
|
+
notify { String(please_break()): }
|
49
|
+
CODE
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'breaks iteration as if at end of input in an each for an array' do
|
53
|
+
expect(compile_to_catalog(<<-CODE)).to_not have_resource('Notify[3]')
|
54
|
+
function please_break() {
|
55
|
+
[1,2,3].each |$x| { if $x == 3 { break() } notify { "$x": } }
|
56
|
+
}
|
57
|
+
please_break()
|
58
|
+
CODE
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'breaks iteration as if at end of input in an each for a hash' do
|
62
|
+
expect(compile_to_catalog(<<-CODE)).to_not have_resource('Notify[3]')
|
63
|
+
function please_break() {
|
64
|
+
{'a' => 1, 'b' => 2, 'c' => 3}.each |$x, $y| { if $y == 3 { break() } notify { "$y": } }
|
65
|
+
}
|
66
|
+
please_break()
|
67
|
+
CODE
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'breaks iteration as if at end of input in a reverse_each' do
|
71
|
+
expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[2]')
|
72
|
+
function please_break() {
|
73
|
+
[1,2,3].reverse_each |$x| { if $x == 1 { break() } notify { "$x": } }
|
74
|
+
}
|
75
|
+
please_break()
|
76
|
+
CODE
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'does not provide early exit from a class' do
|
80
|
+
# A break would semantically mean that the class should not be included - as if the
|
81
|
+
# iteration over class names should stop. That is too magic and should
|
82
|
+
# be done differently by the user.
|
83
|
+
#
|
84
|
+
expect do
|
85
|
+
compile_to_catalog(<<-CODE)
|
86
|
+
class does_break {
|
87
|
+
notice 'a'
|
88
|
+
if 1 == 1 { break() } # avoid making next line statically unreachable
|
89
|
+
notice 'b'
|
90
|
+
}
|
91
|
+
include(does_break)
|
92
|
+
CODE
|
93
|
+
end.to raise_error(/break\(\) from context where this is illegal at unknown:3 on node.*/)
|
94
|
+
end
|
37
95
|
|
38
96
|
it 'does not provide early exit from a define' do
|
39
97
|
# A break would semantically mean that the resource should not be created - as if the
|
@@ -52,38 +110,39 @@ describe 'the break function' do
|
|
52
110
|
end.to raise_error(/break\(\) from context where this is illegal at unknown:3 on node.*/)
|
53
111
|
end
|
54
112
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
113
|
+
it 'can be called when nested in a function to make that function behave as a break' do
|
114
|
+
# This allows functions like break_when(...) to be implemented by calling break() conditionally
|
115
|
+
#
|
116
|
+
expect(eval_and_collect_notices(<<-CODE)).to eql(['[100]'])
|
117
|
+
function nested_break($x) {
|
118
|
+
if $x == 2 { break() } else { $x * 100 }
|
119
|
+
}
|
120
|
+
function example() {
|
121
|
+
[1,2,3].map |$x| { nested_break($x) }
|
122
|
+
}
|
123
|
+
notice example()
|
124
|
+
CODE
|
125
|
+
end
|
68
126
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
127
|
+
it 'can not be called nested from top scope' do
|
128
|
+
expect do
|
129
|
+
compile_to_catalog(<<-CODE)
|
130
|
+
# line 1
|
131
|
+
# line 2
|
132
|
+
$result = with(1) |$x| { with($x) |$x| {break() }}
|
133
|
+
notice $result
|
134
|
+
CODE
|
135
|
+
end.to raise_error(/break\(\) from context where this is illegal at unknown:3 on node.*/)
|
136
|
+
end
|
79
137
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
138
|
+
it 'can not be called from top scope' do
|
139
|
+
expect do
|
140
|
+
compile_to_catalog(<<-CODE)
|
141
|
+
# line 1
|
142
|
+
# line 2
|
143
|
+
break()
|
144
|
+
CODE
|
145
|
+
end.to raise_error(/break\(\) from context where this is illegal at unknown:3 on node.*/)
|
146
|
+
end
|
88
147
|
end
|
89
148
|
end
|