puppet 4.0.0.rc1 → 4.0.0

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.

Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +11 -6
  3. data/Gemfile +1 -1
  4. data/conf/environment.conf +4 -2
  5. data/ext/build_defaults.yaml +3 -3
  6. data/ext/debian/control +2 -2
  7. data/ext/project_data.yaml +1 -1
  8. data/ext/rack/config.ru +1 -0
  9. data/ext/redhat/client.sysconfig +1 -1
  10. data/ext/redhat/puppet.spec.erb +2 -2
  11. data/ext/systemd/puppet.service +1 -0
  12. data/install.rb +2 -2
  13. data/lib/puppet/application/device.rb +22 -5
  14. data/lib/puppet/data_providers.rb +7 -4
  15. data/lib/puppet/data_providers/data_adapter.rb +6 -1
  16. data/lib/puppet/data_providers/data_function_support.rb +17 -4
  17. data/lib/puppet/data_providers/function_env_data_provider.rb +1 -1
  18. data/lib/puppet/data_providers/function_module_data_provider.rb +14 -19
  19. data/lib/puppet/defaults.rb +43 -16
  20. data/lib/puppet/error.rb +4 -0
  21. data/lib/puppet/pops/evaluator/evaluator_impl.rb +33 -4
  22. data/lib/puppet/pops/evaluator/runtime3_support.rb +5 -1
  23. data/lib/puppet/pops/parser/egrammar.ra +2 -0
  24. data/lib/puppet/pops/parser/eparser.rb +732 -724
  25. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  26. data/lib/puppet/pops/parser/lexer2.rb +19 -21
  27. data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
  28. data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
  29. data/lib/puppet/provider/package/appdmg.rb +1 -1
  30. data/lib/puppet/provider/package/gem.rb +19 -6
  31. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  32. data/lib/puppet/provider/package/puppet_gem.rb +17 -0
  33. data/lib/puppet/provider/service/launchd.rb +1 -1
  34. data/lib/puppet/provider/user/directoryservice.rb +2 -2
  35. data/lib/puppet/settings.rb +1 -1
  36. data/lib/puppet/util/errors.rb +4 -2
  37. data/lib/puppet/util/network_device/config.rb +5 -0
  38. data/lib/puppet/util/run_mode.rb +28 -11
  39. data/lib/puppet/util/windows/registry.rb +3 -3
  40. data/lib/puppet/vendor/deep_merge/PUPPET_README.md +6 -0
  41. data/lib/puppet/vendor/load_plist.rb +1 -0
  42. data/lib/puppet/vendor/plist/CHANGELOG +82 -0
  43. data/lib/puppet/vendor/plist/MIT-LICENSE +21 -0
  44. data/lib/puppet/vendor/plist/PUPPET_README.md +6 -0
  45. data/lib/puppet/vendor/plist/README +36 -0
  46. data/lib/puppet/vendor/plist/Rakefile +144 -0
  47. data/lib/puppet/vendor/plist/docs/USAGE +104 -0
  48. data/lib/puppet/vendor/plist/docs/jamis-template.rb +591 -0
  49. data/lib/puppet/vendor/plist/lib/plist.rb +22 -0
  50. data/lib/puppet/vendor/plist/lib/plist/generator.rb +224 -0
  51. data/lib/puppet/vendor/plist/lib/plist/parser.rb +225 -0
  52. data/lib/puppet/vendor/plist/test/assets/AlbumData.xml +203 -0
  53. data/lib/puppet/vendor/plist/test/assets/Cookies.plist +104 -0
  54. data/lib/puppet/vendor/plist/test/assets/commented.plist +9 -0
  55. data/lib/puppet/vendor/plist/test/assets/example_data.bin +0 -0
  56. data/lib/puppet/vendor/plist/test/assets/example_data.jpg +0 -0
  57. data/lib/puppet/vendor/plist/test/assets/example_data.plist +259 -0
  58. data/lib/puppet/vendor/plist/test/assets/test_data_elements.plist +24 -0
  59. data/lib/puppet/vendor/plist/test/assets/test_empty_key.plist +13 -0
  60. data/lib/puppet/vendor/plist/test/test_data_elements.rb +115 -0
  61. data/lib/puppet/vendor/plist/test/test_generator.rb +59 -0
  62. data/lib/puppet/vendor/plist/test/test_generator_basic_types.rb +58 -0
  63. data/lib/puppet/vendor/plist/test/test_generator_collections.rb +82 -0
  64. data/lib/puppet/vendor/plist/test/test_parser.rb +90 -0
  65. data/lib/puppet/version.rb +1 -1
  66. data/man/man5/puppet.conf.5 +5 -13
  67. data/man/man8/extlookup2hiera.8 +1 -1
  68. data/man/man8/puppet-agent.8 +1 -1
  69. data/man/man8/puppet-apply.8 +1 -1
  70. data/man/man8/puppet-ca.8 +1 -1
  71. data/man/man8/puppet-catalog.8 +1 -1
  72. data/man/man8/puppet-cert.8 +1 -1
  73. data/man/man8/puppet-certificate.8 +1 -1
  74. data/man/man8/puppet-certificate_request.8 +1 -1
  75. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  76. data/man/man8/puppet-config.8 +1 -1
  77. data/man/man8/puppet-describe.8 +1 -1
  78. data/man/man8/puppet-device.8 +1 -1
  79. data/man/man8/puppet-doc.8 +1 -1
  80. data/man/man8/puppet-epp.8 +1 -1
  81. data/man/man8/puppet-facts.8 +1 -1
  82. data/man/man8/puppet-file.8 +1 -1
  83. data/man/man8/puppet-filebucket.8 +1 -1
  84. data/man/man8/puppet-help.8 +1 -1
  85. data/man/man8/puppet-inspect.8 +1 -1
  86. data/man/man8/puppet-key.8 +1 -1
  87. data/man/man8/puppet-man.8 +1 -1
  88. data/man/man8/puppet-master.8 +1 -1
  89. data/man/man8/puppet-module.8 +1 -1
  90. data/man/man8/puppet-node.8 +1 -1
  91. data/man/man8/puppet-parser.8 +1 -1
  92. data/man/man8/puppet-plugin.8 +1 -1
  93. data/man/man8/puppet-report.8 +1 -1
  94. data/man/man8/puppet-resource.8 +1 -1
  95. data/man/man8/puppet-resource_type.8 +1 -1
  96. data/man/man8/puppet-status.8 +1 -1
  97. data/man/man8/puppet.8 +1 -1
  98. data/spec/fixtures/unit/functions/lookup/environments/production/lib/puppet/functions/environment/data.rb +8 -6
  99. data/spec/fixtures/unit/functions/lookup/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +4 -4
  100. data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/lib/puppet/bindings/bad_data/default.rb +9 -0
  101. data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/lib/puppet/functions/bad_data/data.rb +6 -0
  102. data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/manifests/init.pp +3 -0
  103. data/spec/fixtures/unit/functions/lookup/environments/production/modules/bca/lib/puppet/bindings/bca/default.rb +9 -0
  104. data/spec/fixtures/unit/functions/lookup/environments/production/modules/bca/lib/puppet/functions/bca/data.rb +9 -0
  105. data/spec/fixtures/unit/functions/lookup/environments/production/modules/bca/manifests/init.pp +2 -0
  106. data/spec/fixtures/unit/functions/lookup/environments/production/modules/no_provider/manifests/init.pp +2 -0
  107. data/spec/integration/provider/yumrepo_spec.rb +127 -0
  108. data/spec/unit/application/device_spec.rb +52 -14
  109. data/spec/unit/functions/lookup_spec.rb +95 -55
  110. data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
  111. data/spec/unit/pops/binder/injector_spec.rb +0 -18
  112. data/spec/unit/pops/parser/lexer2_spec.rb +26 -16
  113. data/spec/unit/pops/parser/parse_heredoc_spec.rb +21 -0
  114. data/spec/unit/pops/validator/validator_spec.rb +2 -3
  115. data/spec/unit/provider/macauthorization_spec.rb +1 -1
  116. data/spec/unit/provider/package/gem_spec.rb +201 -139
  117. data/spec/unit/provider/package/puppet_gem_spec.rb +67 -0
  118. data/spec/unit/provider/user/directoryservice_spec.rb +1 -1
  119. data/spec/unit/util/network_device/config_spec.rb +6 -0
  120. data/spec/unit/util/run_mode_spec.rb +26 -26
  121. data/spec/unit/util/windows/registry_spec.rb +4 -3
  122. metadata +3016 -2980
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2614a19183e40a97b6d09455aca68f9dec13beba
4
+ data.tar.gz: f292f207f71e578d5ccd44a90f647f3dff2d7426
5
+ SHA512:
6
+ metadata.gz: 278d422f4353ca36a117fed46f75979baf1e06ab2284eac44454170112b9326042d136e1e2a5502c66fafe37cd58b2aac357d47a3773d1682ab217cc0bc9618a
7
+ data.tar.gz: 391ec1deb1fd7d9566b34ae69f1aa70ebee7d4a3ca514a1ad73cc49a033420b1fea32542446a2c2ac802bafd40fc7aee721cdeea82836d77fa0d471e76974d25
@@ -73,7 +73,7 @@ for advice.
73
73
  For changes of a trivial nature to comments and documentation, it is not
74
74
  always necessary to create a new ticket in Jira. In this case, it is
75
75
  appropriate to start the first line of a commit with '(doc)' instead of
76
- a ticket number.
76
+ a ticket number.
77
77
 
78
78
  ````
79
79
  (doc) Add documentation commit example to CONTRIBUTING
@@ -83,7 +83,7 @@ a ticket number.
83
83
  is left to assume how a commit of this nature may appear.
84
84
 
85
85
  The first line is a real life imperative statement with '(doc)' in
86
- place of what would have been the ticket number in a
86
+ place of what would have been the ticket number in a
87
87
  non-documentation related commit. The body describes the nature of
88
88
  the new documentation or comments added.
89
89
  ````
@@ -97,15 +97,20 @@ a ticket number.
97
97
  * Include a link to the pull request in the ticket.
98
98
  * The core team looks at Pull Requests on a regular basis in a weekly triage
99
99
  meeting that we hold in a public Google Hangout. The hangout is announced in
100
- the weekly status updates that are sent to the puppet-dev list.
100
+ the weekly status updates that are sent to the puppet-dev list. Notes are
101
+ posted to the [Puppet Community community-triage
102
+ repo](https://github.com/puppet-community/community-triage/tree/master/core/notes)
103
+ and include a link to a YouTube recording of the hangout.
101
104
  * After feedback has been given we expect responses within two weeks. After two
102
- weeks will may close the pull request if it isn't showing any activity.
105
+ weeks we may close the pull request if it isn't showing any activity.
103
106
 
104
107
  # Additional Resources
105
108
 
106
- * [More information on contributing](http://links.puppetlabs.com/contribute-to-puppet)
109
+ * [Puppet Labs community guildelines](http://docs.puppetlabs.com/community/community_guidelines.html)
107
110
  * [Bug tracker (Jira)](http://tickets.puppetlabs.com)
108
111
  * [Contributor License Agreement](http://links.puppetlabs.com/cla)
109
112
  * [General GitHub documentation](http://help.github.com/)
110
113
  * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
111
- * #puppet-dev IRC channel on freenode.org
114
+ * #puppet-dev IRC channel on freenode.org ([Archive](https://botbot.me/freenode/puppet-dev/))
115
+ * [puppet-dev mailing list](https://groups.google.com/forum/#!forum/puppet-dev)
116
+ * [Community PR Triage notes](https://github.com/puppet-community/community-triage/tree/master/core/notes)
data/Gemfile CHANGED
@@ -25,7 +25,7 @@ end
25
25
 
26
26
  gem "puppet", :path => File.dirname(__FILE__), :require => false
27
27
  gem "facter", *location_for(ENV['FACTER_LOCATION'] || ['> 2.0', '< 4'])
28
- gem "hiera", *location_for(ENV['HIERA_LOCATION'] || ['> 1.0', '< 3'])
28
+ gem "hiera", *location_for(ENV['HIERA_LOCATION'] || ['>= 2.0', '< 3'])
29
29
  gem "rake", "10.1.1", :require => false
30
30
 
31
31
  group(:development, :test) do
@@ -11,6 +11,8 @@
11
11
  # Allowed settings and default values:
12
12
 
13
13
  # modulepath = ./modules:$basemodulepath
14
- # manifest = (default_manifest from puppet.conf; defaults to ./manifests)
14
+ # manifest = (default_manifest from puppet.conf, which defaults to ./manifests)
15
15
  # config_version = (no script; Puppet will use the time the catalog was compiled)
16
- # environment_timeout = (environment_timeout from puppet.conf; defaults to unlimited)
16
+ # environment_timeout = (environment_timeout from puppet.conf, which defaults to 0)
17
+ # Note: unless you have a specific reason, we recommend only setting
18
+ # environment_timeout in puppet.conf.
@@ -28,15 +28,15 @@ build_msi:
28
28
  x64: 'cfacter-0.3.0-x64.zip'
29
29
  path: 'http://builds.puppetlabs.lan/cfacter/0.3.0/artifacts/windows'
30
30
  hiera:
31
- ref: 'refs/tags/1.3.4'
31
+ ref: 'refs/tags/2.0.0'
32
32
  repo: 'git://github.com/puppetlabs/hiera.git'
33
33
  mcollective:
34
34
  ref: 'refs/tags/2.7.0'
35
35
  repo: 'git://github.com/puppetlabs/marionette-collective.git'
36
36
  sys:
37
37
  ref:
38
- x86: 'aac9e790c9c3e59175e9d528f8aa517bb6caed76'
39
- x64: '9e70b6ac8474678487f4330fecc2179158ae62f3'
38
+ x86: '8db9d84da9950760144b5dfcd807213eecee4842'
39
+ x64: '12030f11e9bb2f085c68108bff34be6956b25df9'
40
40
  repo: 'git://github.com/puppetlabs/puppet-win32-ruby.git'
41
41
  apt_host: 'apt.puppetlabs.com'
42
42
  apt_repo_url: 'http://apt.puppetlabs.com'
@@ -3,7 +3,7 @@ Section: admin
3
3
  Priority: optional
4
4
  Maintainer: Puppet Labs <info@puppetlabs.com>
5
5
  Uploaders: Micah Anderson <micah@debian.org>, Andrew Pollock <apollock@debian.org>, Nigel Kersten <nigel@explanatorygap.net>, Stig Sandbeck Mathisen <ssm@debian.org>
6
- Build-Depends-Indep: ruby | ruby-interpreter, libopenssl-ruby | libopenssl-ruby1.9.1 | libruby (>= 1:1.9.3.4), facter (>= 1.7.0), hiera (>= 1.0.0)
6
+ Build-Depends-Indep: ruby | ruby-interpreter, libopenssl-ruby | libopenssl-ruby1.9.1 | libruby (>= 1:1.9.3.4), facter (>= 1.7.0), hiera (>= 2.0.0)
7
7
  Build-Depends: debhelper (>= 7.0.0), openssl
8
8
  Standards-Version: 3.9.1
9
9
  Vcs-Git: git://github.com/puppetlabs/puppet
@@ -11,7 +11,7 @@ Homepage: http://projects.puppetlabs.com/projects/puppet
11
11
 
12
12
  Package: puppet-common
13
13
  Architecture: all
14
- Depends: ${misc:Depends}, ruby | ruby-interpreter, libopenssl-ruby | libopenssl-ruby1.9.1 | libruby (>= 1:1.9.3.4), ruby-shadow | libshadow-ruby1.8, libaugeas-ruby | libaugeas-ruby1.9.1 | libaugeas-ruby1.8, lsb-base, sysv-rc (>= 2.86) | file-rc, hiera (>= 1.0.0), facter (>= 1.7.0), libjson-ruby | ruby-json
14
+ Depends: ${misc:Depends}, ruby | ruby-interpreter, libopenssl-ruby | libopenssl-ruby1.9.1 | libruby (>= 1:1.9.3.4), ruby-shadow | libshadow-ruby1.8, libaugeas-ruby | libaugeas-ruby1.9.1 | libaugeas-ruby1.8, lsb-base, sysv-rc (>= 2.86) | file-rc, hiera (>= 2.0.0), facter (>= 1.7.0), libjson-ruby | ruby-json
15
15
  Recommends: lsb-release, debconf-utils
16
16
  Suggests: ruby-selinux | libselinux-ruby1.8
17
17
  Breaks: puppet (<< 2.6.0~rc2-1), puppetmaster (<< 0.25.4-1)
@@ -16,7 +16,7 @@ gem_default_executables: 'puppet'
16
16
  gem_forge_project: 'puppet'
17
17
  gem_runtime_dependencies:
18
18
  facter: ['> 2.0', '< 4']
19
- hiera: ['> 1.0', '< 3']
19
+ hiera: ['>= 2.0', '< 3']
20
20
  json_pure:
21
21
  gem_rdoc_options:
22
22
  - --title
@@ -18,6 +18,7 @@ ARGV << "--confdir" << "/etc/puppetlabs/puppet"
18
18
  ARGV << "--vardir" << "/opt/puppetlabs/server/data/puppetmaster"
19
19
  ARGV << "--logdir" << "/var/log/puppetlabs/puppetmaster"
20
20
  ARGV << "--rundir" << "/var/run/puppetlabs/puppetmaster"
21
+ ARGV << "--codedir" << "/etc/puppetlabs/code"
21
22
 
22
23
  # always_cache_features is a performance improvement and safe for a master to
23
24
  # apply. This is intended to allow agents to recognize new features that may be
@@ -5,7 +5,7 @@
5
5
  #PUPPET_PORT=8140
6
6
 
7
7
  # Where to log to. Specify syslog to send log messages to the system log.
8
- #PUPPET_LOG=/var/log/puppet/puppet.log
8
+ #PUPPET_LOG=/var/log/puppetlabs/puppet/puppet.log
9
9
 
10
10
  # You may specify other parameters to the puppet client here
11
11
  #PUPPET_EXTRA_OPTS=--waitforcert=500
@@ -39,7 +39,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
39
39
  BuildRequires: facter >= 1:1.7.0
40
40
  # Puppet 3.x drops ruby 1.8.5 support and adds ruby 1.9 support
41
41
  BuildRequires: ruby >= 1.8.7
42
- BuildRequires: hiera >= 1.0.0
42
+ BuildRequires: hiera >= 2.0.0
43
43
  BuildArch: noarch
44
44
  Requires: ruby >= 1.8
45
45
  Requires: ruby-shadow
@@ -58,7 +58,7 @@ Requires: facter >= 1:1.7.0
58
58
  # Puppet 3.x drops ruby 1.8.5 support and adds ruby 1.9 support
59
59
  # Ruby 1.8.7 available for el5 at: yum.puppetlabs.com/el/5/devel/$ARCH
60
60
  Requires: ruby >= 1.8.7
61
- Requires: hiera >= 1.0.0
61
+ Requires: hiera >= 2.0.0
62
62
  Obsoletes: hiera-puppet < 1.0.0
63
63
  Provides: hiera-puppet >= 1.0.0
64
64
  %{!?_without_augeas:Requires: ruby-augeas}
@@ -7,6 +7,7 @@ After=basic.target network.target puppetmaster.service
7
7
  EnvironmentFile=-/etc/sysconfig/puppetagent
8
8
  EnvironmentFile=-/etc/sysconfig/puppet
9
9
  ExecStart=/opt/puppetlabs/puppet/bin/puppet agent $PUPPET_EXTRA_OPTS --no-daemonize
10
+ KillMode=process
10
11
 
11
12
  [Install]
12
13
  WantedBy=multi-user.target
data/install.rb CHANGED
@@ -211,7 +211,7 @@ def prepare_installation
211
211
  opts.on('--rundir[=OPTIONAL]', 'Installation directory for state files', 'Default /var/run/puppetlabs') do |rundir|
212
212
  InstallOptions.rundir = rundir
213
213
  end
214
- opts.on('--logdir[=OPTIONAL]', 'Installation directory for log files', 'Default /var/log/puppetlabs') do |logdir|
214
+ opts.on('--logdir[=OPTIONAL]', 'Installation directory for log files', 'Default /var/log/puppetlabs/puppet') do |logdir|
215
215
  InstallOptions.logdir = logdir
216
216
  end
217
217
  opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides RbConfig::CONFIG["bindir"]') do |bindir|
@@ -299,7 +299,7 @@ def prepare_installation
299
299
  elsif $operatingsystem == "windows"
300
300
  logdir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var", "log")
301
301
  else
302
- logdir = "/var/log/puppetlabs"
302
+ logdir = "/var/log/puppetlabs/puppet"
303
303
  end
304
304
 
305
305
  if not InstallOptions.bindir.nil?
@@ -115,9 +115,10 @@ parameter, so you can specify '--server <servername>' as an argument.
115
115
 
116
116
  * --detailed-exitcodes:
117
117
  Provide transaction information via exit codes. If this is enabled, an exit
118
- code of '2' means there were changes, an exit code of '4' means there were
119
- failures during the transaction, and an exit code of '6' means there were both
120
- changes and failures.
118
+ code of '1' means at least one device had a compile failure, an exit code of
119
+ '2' means at least one device had resource changes, and an exit code of '4'
120
+ means at least one device had resource failures. Exit codes of '3', '5', '6',
121
+ or '7' means that a bitwise combination of the preceeding exit codes happened.
121
122
 
122
123
  * --help:
123
124
  Print this help message
@@ -167,9 +168,13 @@ Licensed under the Apache 2.0 License
167
168
  Puppet.err "No device found in #{Puppet[:deviceconfig]}"
168
169
  exit(1)
169
170
  end
170
- devices.each_value do |device|
171
+ returns = devices.collect do |devicename,device|
171
172
  begin
172
- Puppet.info "starting applying configuration to #{device.name} at #{device.url}"
173
+ device_url = URI.parse(device.url)
174
+ # Handle nil scheme & port
175
+ scheme = "#{device_url.scheme}://" if device_url.scheme
176
+ port = ":#{device_url.port}" if device_url.port
177
+ Puppet.info "starting applying configuration to #{device.name} at #{scheme}#{device_url.host}#{port}#{device_url.path}"
173
178
 
174
179
  # override local $vardir and $certname
175
180
  Puppet[:confdir] = ::File.join(Puppet[:devicedir], device.name)
@@ -192,6 +197,8 @@ Licensed under the Apache 2.0 License
192
197
  configurer.run(:network_device => true, :pluginsync => Puppet[:pluginsync])
193
198
  rescue => detail
194
199
  Puppet.log_exception(detail)
200
+ # If we rescued an error, then we return 1 as the exit code
201
+ 1
195
202
  ensure
196
203
  Puppet[:vardir] = vardir
197
204
  Puppet[:confdir] = confdir
@@ -199,6 +206,16 @@ Licensed under the Apache 2.0 License
199
206
  Puppet::SSL::Host.reset
200
207
  end
201
208
  end
209
+ if ! returns or returns.compact.empty?
210
+ exit(1)
211
+ elsif options[:detailed_exitcodes]
212
+ # Bitwise OR the return codes together, puppet style
213
+ exit(returns.compact.reduce(:|))
214
+ elsif returns.include? 1
215
+ exit(1)
216
+ else
217
+ exit(0)
218
+ end
202
219
  end
203
220
 
204
221
  def setup_host
@@ -17,12 +17,15 @@ module Puppet::DataProviders
17
17
  MODULE_NAME = 'module_name'.freeze
18
18
 
19
19
  def self.lookup_in_module(name, scope, merge)
20
- # Do not attempt to do a lookup in a module if evaluated code is not in a module
21
- # which is detected by checking if "MODULE_NAME" exists in scope
22
- return nil unless scope.exist?(MODULE_NAME)
20
+ # Do not attempt to do a lookup in a module unless the name is qualified.
21
+ qual_index = name.index('::')
22
+ throw :no_such_key if qual_index.nil?
23
+ module_name = name[0..qual_index-1]
23
24
 
24
25
  assert_loaded()
25
26
  adapter = Puppet::DataProviders::DataAdapter.adapt(Puppet.lookup(:current_environment))
26
- adapter.module_provider(scope[MODULE_NAME]).lookup(name, scope, merge)
27
+ data_provider = adapter.module_provider(module_name)
28
+ throw :no_such_key if data_provider.nil?
29
+ data_provider.lookup(name, scope, merge)
27
30
  end
28
31
  end
@@ -29,7 +29,12 @@ class Puppet::DataProviders::DataAdapter < Puppet::Pops::Adaptable::Adapter
29
29
  end
30
30
 
31
31
  def module_provider(module_name)
32
- @data[module_name] ||= initialize_module_provider(module_name)
32
+ # Test if the key is present for the given module_name. It might be there even if the
33
+ # value is nil (which indicates that no module provider is configured for the given name)
34
+ unless @data.include?(module_name)
35
+ @data[module_name] = initialize_module_provider(module_name)
36
+ end
37
+ @data[module_name]
33
38
  end
34
39
 
35
40
  def self.create_adapter(environment)
@@ -5,15 +5,26 @@ module Puppet::DataProviders::DataFunctionSupport
5
5
  # This makes it possible to return data that is tailored for the request.
6
6
  # The class including this module must implement `loader(scope)` to return the apropriate loader.
7
7
  #
8
- def data(key, scope)
8
+ # If a block is given, it will be called to validate the data hash when it is retrieved from a function call. The
9
+ # block must return the validated data or raise a {Puppet::Error} to indicate that the data is invalid.
10
+ # The block is not called when the data is found in the compiler or in the cache.
11
+ #
12
+ # @param key [String] The data key such as the name of a module or the constant 'environment'
13
+ # @param scope [Parser::Scope] The scope
14
+ # @return [Hash] The data hash for the given _key_
15
+ # @yield An optional block that can be used for validation of the data returned from the function
16
+ # @yieldparam [Hash] data The data to validate
17
+ # @yieldreturn [Hash] The validated data
18
+ #
19
+ def data(key, scope, &block)
9
20
  compiler = scope.compiler
10
21
  adapter = Puppet::DataProviders::DataAdapter.get(compiler) || Puppet::DataProviders::DataAdapter.adapt(compiler)
11
- adapter.data[key] ||= initialize_data_from_function("#{key}::data", scope)
22
+ adapter.data[key] ||= initialize_data_from_function("#{key}::data", key, scope, &block)
12
23
  end
13
24
 
14
- def initialize_data_from_function(name, scope)
25
+ def initialize_data_from_function(name, key, scope)
15
26
  Puppet::Util::Profiler.profile("Called #{name}", [ :functions, name ]) do
16
- loader = loader(scope)
27
+ loader = loader(key, scope)
17
28
  if loader && func = loader.load(:function, name)
18
29
  # function found, call without arguments, must return a Hash
19
30
  # TODO: Validate the function - to ensure it does not contain unwanted side effects
@@ -23,6 +34,8 @@ module Puppet::DataProviders::DataFunctionSupport
23
34
  unless result.is_a?(Hash)
24
35
  raise Puppet::Error.new("Expected '#{name}' function to return a Hash, got #{result.class}")
25
36
  end
37
+ # validate result if block given
38
+ result = yield(result) if block_given?
26
39
  else
27
40
  raise Puppet::Error.new("Data from 'function' cannot find the required '#{name}' function")
28
41
  end
@@ -21,7 +21,7 @@ class Puppet::DataProviders::FunctionEnvDataProvider < Puppet::Plugins::DataProv
21
21
  end
22
22
  end
23
23
 
24
- def loader(scope)
24
+ def loader(key, scope)
25
25
  # This loader allows the data function to be private or public in the environment
26
26
  scope.compiler.loaders.private_environment_loader
27
27
  end
@@ -13,17 +13,19 @@ class Puppet::DataProviders::FunctionModuleDataProvider < Puppet::Plugins::DataP
13
13
  include Puppet::DataProviders::DataFunctionSupport
14
14
 
15
15
  def lookup(name, scope, merge)
16
- # If the module name does not exist, this call is not from within a module, and should be ignored.
17
- unless scope.exist?(MODULE_NAME)
18
- return nil
19
- end
20
- # Get the module name. Calls to the lookup method should only be performed for modules that have opted in
21
- # by specifying that they use the 'function' implementation as the module_data provider. Thus, this will error
22
- # out if a module specified 'function' but did not provide a function called <module-name>::data
23
- #
24
- module_name = scope[MODULE_NAME]
16
+ # Do not attempt to do a lookup in a module unless the name is qualified.
17
+ qual_index = name.index('::')
18
+ throw :no_such_key if qual_index.nil?
19
+ module_name = name[0..qual_index-1]
25
20
  begin
26
- hash = data(module_name, scope)
21
+ hash = data(module_name, scope) do | data |
22
+ module_prefix = "#{module_name}::"
23
+ data.each_pair do |k,v|
24
+ unless k.is_a?(String) && k.start_with?(module_prefix)
25
+ raise Puppet::Error, "Module data for module '#{module_name}' must use keys qualified with the name of the module"
26
+ end
27
+ end
28
+ end
27
29
  throw :no_such_key unless hash.include?(name)
28
30
  hash[name]
29
31
  rescue *Puppet::Error => detail
@@ -31,14 +33,7 @@ class Puppet::DataProviders::FunctionModuleDataProvider < Puppet::Plugins::DataP
31
33
  end
32
34
  end
33
35
 
34
- def loader(scope)
35
- loaders = scope.compiler.loaders
36
- if scope.exist?(MODULE_NAME)
37
- loaders.private_loader_for_module(scope[MODULE_NAME])
38
- else
39
- # Produce the environment's loader when not in a module
40
- # This loader allows the data function to be private or public in the environment
41
- loaders.private_environment_loader
42
- end
36
+ def loader(key, scope)
37
+ scope.compiler.loaders.private_loader_for_module(key)
43
38
  end
44
39
  end
@@ -452,10 +452,33 @@ module Puppet
452
452
  :environment_timeout => {
453
453
  :default => "0",
454
454
  :type => :ttl,
455
- :desc => "The time to live for a cached environment.
455
+ :desc => "How long the Puppet master should cache data it loads from an
456
+ environment.
456
457
  #{AS_DURATION}
457
- This setting can also be set to `unlimited`, which causes the environment to
458
- be cached until the master is restarted."
458
+ A value of `0` will disable caching. This setting can also be set to
459
+ `unlimited`, which will cache environments until the master is restarted
460
+ or told to refresh the cache.
461
+
462
+ You should change this setting once your Puppet deployment is doing
463
+ non-trivial work. We chose the default value of `0` because it lets new
464
+ users update their code without any extra steps, but it lowers the
465
+ performance of your Puppet master.
466
+
467
+ We recommend setting this to `unlimited` and explicitly refreshing your
468
+ Puppet master as part of your code deployment process.
469
+
470
+ * With Puppet Server, you should refresh environments by calling the
471
+ `environment-cache` API endpoint. See the docs for the Puppet Server
472
+ administrative API.
473
+ * With a Rack Puppet master, you should restart the web server or the
474
+ application server. Passenger lets you touch a `restart.txt` file to
475
+ refresh an application without restarting Apache; see the Passenger docs
476
+ for details.
477
+
478
+ We don't recommend using any value other than `0` or `unlimited`, since
479
+ most Puppet masters use a pool of Ruby interpreters which all have their
480
+ own cache timers. When these timers drift out of sync, agents can be served
481
+ inconsistent catalogs."
459
482
  },
460
483
  :environment_data_provider => {
461
484
  :default => "none",
@@ -1010,15 +1033,6 @@ EOT
1010
1033
  this is the port to listen on; for puppet agent, this is the port
1011
1034
  to make requests on. Both applications use this setting to get the port.",
1012
1035
  },
1013
- :master_url_prefix => {
1014
- :default => "/puppet",
1015
- :desc => "The prefix at which the puppet master API is mounted.",
1016
- :hook => proc do |value|
1017
- if !value.start_with?("/")
1018
- Puppet[:master_url_prefix] = "/#{value}"
1019
- end
1020
- end
1021
- },
1022
1036
  :node_name => {
1023
1037
  :default => "cert",
1024
1038
  :desc => "How the puppet master determines the client's identity
@@ -1418,14 +1432,27 @@ EOT
1418
1432
  :graph => {
1419
1433
  :default => false,
1420
1434
  :type => :boolean,
1421
- :desc => "Whether to create dot graph files for the different
1422
- configuration graphs. These dot files can be interpreted by tools
1423
- like OmniGraffle or dot (which is part of ImageMagick).",
1435
+ :desc => "Whether to create .dot graph files, which let you visualize the
1436
+ dependency and containment relationships in Puppet's catalog. You
1437
+ can load and view these files with tools like
1438
+ [OmniGraffle](http://www.omnigroup.com/applications/omnigraffle/) (OS X)
1439
+ or [graphviz](http://www.graphviz.org/) (multi-platform).
1440
+
1441
+ Graph files are created when _applying_ a catalog, so this setting
1442
+ should be used on nodes running `puppet agent` or `puppet apply`.
1443
+
1444
+ The `graphdir` setting determines where Puppet will save graphs. Note
1445
+ that we don't save graphs for historical runs; Puppet will replace the
1446
+ previous .dot files with new ones every time it applies a catalog.
1447
+
1448
+ See your graphing software's documentation for details on opening .dot
1449
+ files. If you're using GraphViz's `dot` command, you can do a quick PNG
1450
+ render with `dot -Tpng <DOT FILE> -o <OUTPUT FILE>`.",
1424
1451
  },
1425
1452
  :graphdir => {
1426
1453
  :default => "$statedir/graphs",
1427
1454
  :type => :directory,
1428
- :desc => "Where to store dot-outputted graphs.",
1455
+ :desc => "Where to save .dot-format graphs (when the `graph` setting is enabled).",
1429
1456
  },
1430
1457
  :waitforcert => {
1431
1458
  :default => "2m",