puppet 4.0.0 → 4.1.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 (219) hide show
  1. checksums.yaml +4 -4
  2. data/ext/build_defaults.yaml +8 -35
  3. data/ext/debian/puppet.default +0 -5
  4. data/ext/debian/puppet.init +1 -15
  5. data/lib/hiera/puppet_function.rb +15 -4
  6. data/lib/puppet/application/agent.rb +5 -0
  7. data/lib/puppet/application/apply.rb +23 -2
  8. data/lib/puppet/application/device.rb +8 -3
  9. data/lib/puppet/application/master.rb +16 -5
  10. data/lib/puppet/configurer.rb +7 -5
  11. data/lib/puppet/defaults.rb +18 -0
  12. data/lib/puppet/environments.rb +1 -1
  13. data/lib/puppet/error.rb +27 -1
  14. data/lib/puppet/file_serving/metadata.rb +13 -8
  15. data/lib/puppet/file_serving/terminus_helper.rb +7 -8
  16. data/lib/puppet/file_system.rb +13 -0
  17. data/lib/puppet/file_system/file_impl.rb +4 -0
  18. data/lib/puppet/file_system/memory_impl.rb +4 -0
  19. data/lib/puppet/file_system/windows.rb +8 -0
  20. data/lib/puppet/functions.rb +33 -3
  21. data/lib/puppet/functions/defined.rb +130 -0
  22. data/lib/puppet/functions/regsubst.rb +1 -1
  23. data/lib/puppet/functions/split.rb +1 -1
  24. data/lib/puppet/indirector/catalog/compiler.rb +1 -1
  25. data/lib/puppet/indirector/facts/facter.rb +11 -0
  26. data/lib/puppet/loaders.rb +1 -0
  27. data/lib/puppet/node.rb +17 -1
  28. data/lib/puppet/node/environment.rb +4 -0
  29. data/lib/puppet/parser/ast/pops_bridge.rb +4 -0
  30. data/lib/puppet/parser/compiler.rb +9 -0
  31. data/lib/puppet/parser/functions/defined.rb +25 -1
  32. data/lib/puppet/parser/functions/file.rb +3 -1
  33. data/lib/puppet/parser/scope.rb +11 -2
  34. data/lib/puppet/parser/templatewrapper.rb +2 -1
  35. data/lib/puppet/pops.rb +4 -0
  36. data/lib/puppet/pops/evaluator/access_operator.rb +25 -5
  37. data/lib/puppet/pops/evaluator/closure.rb +28 -2
  38. data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -11
  39. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +4 -0
  40. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +4 -0
  41. data/lib/puppet/pops/evaluator/compare_operator.rb +43 -0
  42. data/lib/puppet/pops/evaluator/epp_evaluator.rb +7 -2
  43. data/lib/puppet/pops/evaluator/evaluator_impl.rb +48 -14
  44. data/lib/puppet/pops/evaluator/runtime3_support.rb +10 -5
  45. data/lib/puppet/pops/functions/dispatch.rb +6 -1
  46. data/lib/puppet/pops/functions/dispatcher.rb +7 -1
  47. data/lib/puppet/pops/issue_reporter.rb +42 -16
  48. data/lib/puppet/pops/issues.rb +116 -2
  49. data/lib/puppet/pops/loader/loader.rb +11 -0
  50. data/lib/puppet/pops/loader/loader_paths.rb +67 -6
  51. data/lib/puppet/pops/loader/module_loaders.rb +19 -8
  52. data/lib/puppet/pops/loader/puppet_function_instantiator.rb +78 -0
  53. data/lib/puppet/pops/loaders.rb +6 -4
  54. data/lib/puppet/pops/migration/migration_checker.rb +54 -0
  55. data/lib/puppet/pops/model/factory.rb +5 -1
  56. data/lib/puppet/pops/model/model_label_provider.rb +2 -0
  57. data/lib/puppet/pops/model/model_meta.rb +5 -1
  58. data/lib/puppet/pops/parser/egrammar.ra +9 -10
  59. data/lib/puppet/pops/parser/eparser.rb +1061 -1047
  60. data/lib/puppet/pops/parser/epp_support.rb +18 -9
  61. data/lib/puppet/pops/parser/evaluating_parser.rb +7 -1
  62. data/lib/puppet/pops/parser/heredoc_support.rb +12 -11
  63. data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
  64. data/lib/puppet/pops/parser/lexer2.rb +29 -12
  65. data/lib/puppet/pops/parser/lexer_support.rb +52 -23
  66. data/lib/puppet/pops/parser/parser_support.rb +11 -14
  67. data/lib/puppet/pops/parser/slurp_support.rb +22 -6
  68. data/lib/puppet/pops/types/type_calculator.rb +156 -55
  69. data/lib/puppet/pops/types/type_factory.rb +66 -13
  70. data/lib/puppet/pops/types/type_parser.rb +22 -13
  71. data/lib/puppet/pops/types/types.rb +23 -4
  72. data/lib/puppet/pops/types/types_meta.rb +13 -2
  73. data/lib/puppet/pops/validation.rb +25 -2
  74. data/lib/puppet/pops/validation/checker4_0.rb +63 -31
  75. data/lib/puppet/provider/group/windows_adsi.rb +8 -4
  76. data/lib/puppet/provider/mount/parsed.rb +145 -2
  77. data/lib/puppet/provider/package/apt.rb +1 -1
  78. data/lib/puppet/provider/package/pip.rb +11 -2
  79. data/lib/puppet/provider/package/pkgng.rb +134 -0
  80. data/lib/puppet/provider/package/portage.rb +1 -1
  81. data/lib/puppet/provider/package/ports.rb +0 -3
  82. data/lib/puppet/provider/package/windows/exe_package.rb +0 -1
  83. data/lib/puppet/provider/package/windows/msi_package.rb +0 -1
  84. data/lib/puppet/provider/package/zypper.rb +50 -15
  85. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +32 -7
  86. data/lib/puppet/provider/service/debian.rb +1 -1
  87. data/lib/puppet/provider/service/init.rb +7 -0
  88. data/lib/puppet/provider/user/openbsd.rb +1 -0
  89. data/lib/puppet/provider/user/windows_adsi.rb +45 -2
  90. data/lib/puppet/reference/indirection.rb +1 -1
  91. data/lib/puppet/resource.rb +1 -1
  92. data/lib/puppet/resource/catalog.rb +0 -4
  93. data/lib/puppet/settings.rb +19 -0
  94. data/lib/puppet/type/file.rb +1 -0
  95. data/lib/puppet/type/file/ensure.rb +1 -1
  96. data/lib/puppet/type/mount.rb +9 -1
  97. data/lib/puppet/type/scheduled_task.rb +13 -0
  98. data/lib/puppet/type/tidy.rb +3 -1
  99. data/lib/puppet/type/user.rb +32 -0
  100. data/lib/puppet/type/yumrepo.rb +5 -5
  101. data/lib/puppet/util/log.rb +50 -8
  102. data/lib/puppet/util/log/destinations.rb +23 -2
  103. data/lib/puppet/util/logging.rb +37 -1
  104. data/lib/puppet/util/run_mode.rb +1 -14
  105. data/lib/puppet/util/windows/adsi.rb +130 -58
  106. data/lib/puppet/version.rb +1 -1
  107. data/man/man5/puppet.conf.5 +48 -6
  108. data/man/man8/extlookup2hiera.8 +1 -1
  109. data/man/man8/puppet-agent.8 +4 -1
  110. data/man/man8/puppet-apply.8 +4 -1
  111. data/man/man8/puppet-ca.8 +1 -1
  112. data/man/man8/puppet-catalog.8 +1 -1
  113. data/man/man8/puppet-cert.8 +1 -1
  114. data/man/man8/puppet-certificate.8 +1 -1
  115. data/man/man8/puppet-certificate_request.8 +1 -1
  116. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  117. data/man/man8/puppet-config.8 +1 -1
  118. data/man/man8/puppet-describe.8 +1 -1
  119. data/man/man8/puppet-device.8 +6 -3
  120. data/man/man8/puppet-doc.8 +1 -1
  121. data/man/man8/puppet-epp.8 +1 -1
  122. data/man/man8/puppet-facts.8 +1 -1
  123. data/man/man8/puppet-file.8 +1 -1
  124. data/man/man8/puppet-filebucket.8 +1 -1
  125. data/man/man8/puppet-help.8 +1 -1
  126. data/man/man8/puppet-inspect.8 +1 -1
  127. data/man/man8/puppet-key.8 +1 -1
  128. data/man/man8/puppet-man.8 +1 -1
  129. data/man/man8/puppet-master.8 +4 -1
  130. data/man/man8/puppet-module.8 +1 -1
  131. data/man/man8/puppet-node.8 +1 -1
  132. data/man/man8/puppet-parser.8 +1 -1
  133. data/man/man8/puppet-plugin.8 +1 -1
  134. data/man/man8/puppet-report.8 +1 -1
  135. data/man/man8/puppet-resource.8 +1 -1
  136. data/man/man8/puppet-resource_type.8 +1 -1
  137. data/man/man8/puppet-status.8 +1 -1
  138. data/man/man8/puppet.8 +1 -1
  139. data/spec/fixtures/unit/data_providers/environments/production/lib/puppet/functions/environment/data.rb +3 -1
  140. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/functions/data.pp +6 -0
  141. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb +9 -0
  142. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp +9 -0
  143. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcalled.pp +3 -0
  144. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp +3 -0
  145. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp +3 -0
  146. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb +5 -0
  147. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp +3 -0
  148. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp +3 -0
  149. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json +10 -0
  150. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp +3 -0
  151. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp +3 -0
  152. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +1 -10
  153. data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
  154. data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
  155. data/spec/fixtures/unit/provider/package/pkgng/pkg.info +8 -0
  156. data/spec/fixtures/unit/provider/package/pkgng/pkg.query +1 -0
  157. data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +1 -0
  158. data/spec/fixtures/unit/provider/package/pkgng/pkg.version +3 -0
  159. data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-empty.out +3 -0
  160. data/spec/integration/application/apply_spec.rb +49 -0
  161. data/spec/integration/faces/plugin_spec.rb +0 -4
  162. data/spec/integration/indirector/facts/facter_spec.rb +59 -0
  163. data/spec/integration/parser/compiler_spec.rb +850 -0
  164. data/spec/integration/parser/resource_expressions_spec.rb +3 -0
  165. data/spec/integration/parser/scope_spec.rb +26 -5
  166. data/spec/integration/transaction_spec.rb +1 -1
  167. data/spec/integration/type/file_spec.rb +318 -41
  168. data/spec/integration/util/windows/security_spec.rb +14 -5
  169. data/spec/lib/matchers/resource.rb +22 -1
  170. data/spec/lib/puppet_spec/matchers.rb +6 -4
  171. data/spec/unit/application/master_spec.rb +33 -7
  172. data/spec/unit/data_providers/function_data_provider_spec.rb +10 -1
  173. data/spec/unit/file_serving/metadata_spec.rb +1 -1
  174. data/spec/unit/file_serving/terminus_helper_spec.rb +2 -3
  175. data/spec/unit/file_system_spec.rb +38 -0
  176. data/spec/unit/functions/defined_spec.rb +289 -0
  177. data/spec/unit/functions/hiera_spec.rb +8 -6
  178. data/spec/unit/functions/regsubst_spec.rb +4 -0
  179. data/spec/unit/functions/split_spec.rb +8 -0
  180. data/spec/unit/functions4_spec.rb +97 -2
  181. data/spec/unit/indirector/facts/facter_spec.rb +7 -0
  182. data/spec/unit/node_spec.rb +6 -0
  183. data/spec/unit/parser/functions/file_spec.rb +7 -1
  184. data/spec/unit/parser/functions/template_spec.rb +1 -1
  185. data/spec/unit/parser/scope_spec.rb +2 -2
  186. data/spec/unit/parser/templatewrapper_spec.rb +1 -1
  187. data/spec/unit/pops/evaluator/access_ops_spec.rb +19 -0
  188. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +84 -18
  189. data/spec/unit/pops/evaluator/variables_spec.rb +1 -1
  190. data/spec/unit/pops/issues_spec.rb +16 -16
  191. data/spec/unit/pops/loaders/loaders_spec.rb +106 -48
  192. data/spec/unit/pops/migration_spec.rb +53 -0
  193. data/spec/unit/pops/parser/lexer2_spec.rb +142 -1
  194. data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
  195. data/spec/unit/pops/types/type_calculator_spec.rb +205 -12
  196. data/spec/unit/pops/validation_spec.rb +66 -0
  197. data/spec/unit/pops/validator/validator_spec.rb +1 -1
  198. data/spec/unit/provider/group/windows_adsi_spec.rb +57 -9
  199. data/spec/unit/provider/mount/parsed_spec.rb +31 -5
  200. data/spec/unit/provider/package/apt_spec.rb +5 -0
  201. data/spec/unit/provider/package/pip_spec.rb +9 -0
  202. data/spec/unit/provider/package/pkgng_spec.rb +172 -0
  203. data/spec/unit/provider/package/windows/exe_package_spec.rb +0 -1
  204. data/spec/unit/provider/package/windows/msi_package_spec.rb +0 -1
  205. data/spec/unit/provider/package/zypper_spec.rb +50 -19
  206. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +312 -70
  207. data/spec/unit/provider/service/base_spec.rb +38 -27
  208. data/spec/unit/provider/service/debian_spec.rb +8 -0
  209. data/spec/unit/provider/service/freebsd_spec.rb +1 -0
  210. data/spec/unit/provider/service/gentoo_spec.rb +1 -0
  211. data/spec/unit/provider/service/init_spec.rb +18 -0
  212. data/spec/unit/provider/service/openbsd_spec.rb +1 -0
  213. data/spec/unit/provider/service/redhat_spec.rb +1 -0
  214. data/spec/unit/provider/user/windows_adsi_spec.rb +134 -5
  215. data/spec/unit/settings_spec.rb +11 -0
  216. data/spec/unit/util/log_spec.rb +113 -0
  217. data/spec/unit/util/windows/adsi_spec.rb +135 -41
  218. data/spec/unit/util/windows/sid_spec.rb +0 -10
  219. metadata +48 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2614a19183e40a97b6d09455aca68f9dec13beba
4
- data.tar.gz: f292f207f71e578d5ccd44a90f647f3dff2d7426
3
+ metadata.gz: 5697f12fa3914a8f6711cfafe0b62a799f2332d1
4
+ data.tar.gz: f2e3e77a13e52a34c5926d5df601a3de203fe87e
5
5
  SHA512:
6
- metadata.gz: 278d422f4353ca36a117fed46f75979baf1e06ab2284eac44454170112b9326042d136e1e2a5502c66fafe37cd58b2aac357d47a3773d1682ab217cc0bc9618a
7
- data.tar.gz: 391ec1deb1fd7d9566b34ae69f1aa70ebee7d4a3ca514a1ad73cc49a033420b1fea32542446a2c2ac802bafd40fc7aee721cdeea82836d77fa0d471e76974d25
6
+ metadata.gz: 3782d9be1c7e84fd7bb0b5f247c16cc0c25fb8302be4a99c095f493233f94d7a8f7f2d747e5c3c0c60218f3dd0ad6d608d019bfdf82147122353528597c2018e
7
+ data.tar.gz: d53ca51aadada05f519ec4748fdc95a611ff32367bd9e9da15560449a38ba27c2989fd78d25dc552053df9ea736b2eaf9ae01b94ad958075d4bf9cc1eca05a8f
@@ -1,47 +1,20 @@
1
1
  ---
2
2
  packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master'
3
3
  packaging_repo: 'packaging'
4
- default_cow: 'base-squeeze-i386.cow'
5
- cows: 'base-lucid-i386.cow base-precise-i386.cow base-squeeze-i386.cow base-stable-i386.cow base-testing-i386.cow base-trusty-i386.cow base-wheezy-i386.cow'
6
- pbuild_conf: '/etc/pbuilderrc'
7
4
  packager: 'puppetlabs'
8
- gpg_name: 'info@puppetlabs.com'
9
5
  gpg_key: '4BD6EC30'
6
+
7
+ # These are the build targets used by the packaging repo. Uncomment to allow use.
8
+ #final_mocks: 'pl-el-5-i386 pl-el-6-i386 pl-el-7-x86_64'
9
+ #cows: 'base-lucid-i386.cow base-precise-i386.cow base-squeeze-i386.cow base-trusty-i386.cow base-wheezy-i386.cow'
10
+ pbuild_conf: '/etc/pbuilderrc'
11
+
12
+ build_gem: TRUE
13
+ build_dmg: FALSE
10
14
  sign_tar: FALSE
11
- # a space separated list of mock configs
12
- final_mocks: 'pl-el-5-i386 pl-el-6-i386 pl-el-7-x86_64 pl-fedora-19-i386 pl-fedora-20-i386'
13
15
  yum_host: 'yum.puppetlabs.com'
14
16
  yum_repo_path: '/opt/repository/yum/'
15
- build_gem: TRUE
16
- build_dmg: TRUE
17
- msi_name: 'puppet-agent'
18
- build_msi:
19
- puppet_for_the_win:
20
- ref: '52e81967253924428bb0b1e7e1a11e8678d68378'
21
- repo: 'git://github.com/puppetlabs/puppet_for_the_win.git'
22
- facter:
23
- ref: 'refs/tags/2.4.0'
24
- repo: 'git://github.com/puppetlabs/facter.git'
25
- cfacter:
26
- archive:
27
- x86: 'cfacter-0.3.0-x86.zip'
28
- x64: 'cfacter-0.3.0-x64.zip'
29
- path: 'http://builds.puppetlabs.lan/cfacter/0.3.0/artifacts/windows'
30
- hiera:
31
- ref: 'refs/tags/2.0.0'
32
- repo: 'git://github.com/puppetlabs/hiera.git'
33
- mcollective:
34
- ref: 'refs/tags/2.7.0'
35
- repo: 'git://github.com/puppetlabs/marionette-collective.git'
36
- sys:
37
- ref:
38
- x86: '8db9d84da9950760144b5dfcd807213eecee4842'
39
- x64: '12030f11e9bb2f085c68108bff34be6956b25df9'
40
- repo: 'git://github.com/puppetlabs/puppet-win32-ruby.git'
41
17
  apt_host: 'apt.puppetlabs.com'
42
18
  apt_repo_url: 'http://apt.puppetlabs.com'
43
19
  apt_repo_path: '/opt/repository/incoming'
44
- ips_repo: '/var/pkgrepo'
45
- ips_store: '/opt/repository'
46
- ips_host: 'solaris-11-ips-repo.acctest.dc1.puppetlabs.net'
47
20
  tar_host: 'downloads.puppetlabs.com'
@@ -1,9 +1,4 @@
1
1
  # Defaults for puppet - sourced by /etc/init.d/puppet
2
2
 
3
- # Enable puppet agent service?
4
- # Setting this to "yes" allows the puppet agent service to run.
5
- # Setting this to "no" keeps the puppet agent service from running.
6
- START=no
7
-
8
3
  # Startup options
9
4
  DAEMON_OPTS=""
@@ -22,26 +22,12 @@ test -x $DAEMON || exit 0
22
22
 
23
23
  . /lib/lsb/init-functions
24
24
 
25
- is_true() {
26
- if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ] ; then
27
- return 0
28
- else
29
- return 1
30
- fi
31
- }
32
-
33
25
  reload_puppet_agent() {
34
26
  start-stop-daemon --stop --quiet --signal HUP --pidfile $PIDFILE --name $PROCNAME
35
27
  }
36
28
 
37
29
  start_puppet_agent() {
38
- if is_true "$START" ; then
39
- start-stop-daemon --start --quiet --pidfile $PIDFILE \
40
- --startas $DAEMON -- $NAME $DAEMON_OPTS
41
- else
42
- echo ""
43
- echo "puppet not configured to start, please edit /etc/default/puppet to enable"
44
- fi
30
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON -- $NAME $DAEMON_OPTS
45
31
  }
46
32
 
47
33
  stop_puppet_agent() {
@@ -12,10 +12,15 @@ class Hiera::PuppetFunction < Puppet::Functions::InternalFunction
12
12
  param 'Tuple[String, Any, Any, 1, 3]', :args
13
13
  end
14
14
 
15
- dispatch :hiera do
15
+ dispatch :hiera_no_default do
16
16
  scope_param
17
17
  param 'String',:key
18
- optional_param 'Any', :default
18
+ end
19
+
20
+ dispatch :hiera_with_default do
21
+ scope_param
22
+ param 'String',:key
23
+ param 'Any', :default
19
24
  optional_param 'Any', :override
20
25
  end
21
26
 
@@ -37,8 +42,14 @@ class Hiera::PuppetFunction < Puppet::Functions::InternalFunction
37
42
  hiera(scope, *args)
38
43
  end
39
44
 
40
- def hiera(scope, key, default = nil, override = nil)
41
- post_lookup(key, lookup(scope, key, default, override))
45
+ def hiera_no_default(scope, key)
46
+ post_lookup(key, lookup(scope, key, nil, nil))
47
+ end
48
+
49
+ def hiera_with_default(scope, key, default, override = nil)
50
+ undefined = (@@undefined_value ||= Object.new)
51
+ result = lookup(scope, key, undefined, override)
52
+ post_lookup(key, result.equal?(undefined) ? default : result)
42
53
  end
43
54
 
44
55
  def hiera_block1(scope, key, &default_block)
@@ -228,6 +228,11 @@ generated by running puppet agent with '--genconfig'.
228
228
  file. If debugging or verbosity is enabled, this defaults to 'console'.
229
229
  Otherwise, it defaults to 'syslog' on POSIX systems and 'eventlog' on Windows.
230
230
 
231
+ A path ending with '.json' will receive structured output in JSON format. The
232
+ log file will not have an ending ']' automatically written to it due to the
233
+ appending nature of logging. It must be appended manually to make the content
234
+ valid JSON.
235
+
231
236
  * --masterport:
232
237
  The port on which to contact the puppet master.
233
238
  (This is a Puppet setting, and can go in puppet.conf.)
@@ -99,6 +99,11 @@ configuration options can also be generated by running puppet with
99
99
  service), 'eventlog' (the Windows Event Log), 'console', or the path to a log
100
100
  file. Defaults to 'console'.
101
101
 
102
+ A path ending with '.json' will receive structured output in JSON format. The
103
+ log file will not have an ending ']' automatically written to it due to the
104
+ appending nature of logging. It must be appended manually to make the content
105
+ valid JSON.
106
+
102
107
  * --noop:
103
108
  Use 'noop' mode where Puppet runs in a no-op or dry-run mode. This
104
109
  is useful for seeing what changes Puppet will make without actually
@@ -199,6 +204,11 @@ Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License
199
204
  # Merge in the facts.
200
205
  node.merge(facts.values) if facts
201
206
 
207
+ # Add server facts so $server_facts[environment] exists when doing a puppet apply
208
+ if Puppet[:trusted_server_facts]
209
+ node.add_server_facts({})
210
+ end
211
+
202
212
  # Allow users to load the classes that puppet agent creates.
203
213
  if options[:loadclasses]
204
214
  file = Puppet[:classfile]
@@ -212,9 +222,20 @@ Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License
212
222
  end
213
223
 
214
224
  begin
215
- # Compile our catalog
225
+ # Compile the catalog
216
226
  starttime = Time.now
217
- catalog = Puppet::Resource::Catalog.indirection.find(node.name, :use_node => node)
227
+
228
+ # When compiling, the compiler traps and logs certain errors
229
+ # Those that do not lead to an immediate exit are caught by the general
230
+ # rule and gets logged.
231
+ #
232
+ catalog =
233
+ begin
234
+ Puppet::Resource::Catalog.indirection.find(node.name, :use_node => node)
235
+ rescue Puppet::ParseErrorWithIssue, Puppet::Error
236
+ # already logged and handled by the compiler for these two cases
237
+ exit(1)
238
+ end
218
239
 
219
240
  # Translate it to a RAL catalog
220
241
  catalog = catalog.to_ral
@@ -124,9 +124,14 @@ parameter, so you can specify '--server <servername>' as an argument.
124
124
  Print this help message
125
125
 
126
126
  * --logdest:
127
- Where to send messages. Choose between syslog, the console, and a log file.
128
- Defaults to sending messages to syslog, or the console if debugging or
129
- verbosity is enabled.
127
+ Where to send log messages. Choose between 'syslog' (the POSIX syslog
128
+ service), 'console', or the path to a log file. If debugging or verbosity is
129
+ enabled, this defaults to 'console'. Otherwise, it defaults to 'syslog'.
130
+
131
+ A path ending with '.json' will receive structured output in JSON format. The
132
+ log file will not have an ending ']' automatically written to it due to the
133
+ appending nature of logging. It must be appended manually to make the content
134
+ valid JSON.
130
135
 
131
136
  * --verbose:
132
137
  Turn on verbose reporting.
@@ -86,6 +86,11 @@ generated by running puppet master with '--genconfig'.
86
86
  service), 'console', or the path to a log file. If debugging or verbosity is
87
87
  enabled, this defaults to 'console'. Otherwise, it defaults to 'syslog'.
88
88
 
89
+ A path ending with '.json' will receive structured output in JSON format. The
90
+ log file will not have an ending ']' automatically written to it due to the
91
+ appending nature of logging. It must be appended manually to make the content
92
+ valid JSON.
93
+
89
94
  * --masterport:
90
95
  The port on which to listen for traffic.
91
96
  (This is a Puppet setting, and can go in puppet.conf.)
@@ -185,17 +190,23 @@ Copyright (c) 2012 Puppet Labs, LLC Licensed under the Apache 2.0 License
185
190
  Puppet::SSL::Host.ca_location = :only if Puppet::SSL::CertificateAuthority.ca?
186
191
 
187
192
  if Puppet.features.root?
188
- begin
189
- Puppet::Util.chuser
190
- rescue => detail
191
- Puppet.log_exception(detail, "Could not change user to #{Puppet[:user]}: #{detail}")
192
- exit(39)
193
+ if Puppet::Type.type(:user).new(:name => Puppet[:user]).exists?
194
+ begin
195
+ Puppet::Util.chuser
196
+ rescue => detail
197
+ Puppet.log_exception(detail, "Could not change user to #{Puppet[:user]}: #{detail}")
198
+ exit(39)
199
+ end
200
+ else
201
+ raise Puppet::Error.new("Could not change user to #{Puppet[:user]}. User does not exist and is required to continue.")
193
202
  end
194
203
  end
195
204
 
196
205
  if options[:rack]
206
+ Puppet.deprecation_warning("The Rack Puppet master server is deprecated and will be removed in a future release. Please use Puppet Server instead. See http://links.puppetlabs.com/deprecate-rack-webrick-servers for more information.")
197
207
  start_rack_master
198
208
  else
209
+ Puppet.deprecation_warning("The WEBrick Puppet master server is deprecated and will be removed in a future release. Please use Puppet Server instead. See http://links.puppetlabs.com/deprecate-rack-webrick-servers for more information.")
199
210
  start_webrick_master
200
211
  end
201
212
  end
@@ -114,13 +114,15 @@ class Puppet::Configurer
114
114
  # the options, then apply that one, otherwise retrieve it.
115
115
  def apply_catalog(catalog, options)
116
116
  report = options[:report]
117
- report.configuration_version = catalog.version
117
+ begin
118
+ report.configuration_version = catalog.version
118
119
 
119
- benchmark(:notice, "Applied catalog") do
120
- catalog.apply(options)
120
+ benchmark(:notice, "Applied catalog") do
121
+ catalog.apply(options)
122
+ end
123
+ ensure
124
+ report.finalize_report
121
125
  end
122
-
123
- report.finalize_report
124
126
  report
125
127
  end
126
128
 
@@ -505,6 +505,24 @@ module Puppet
505
505
  :desc => "Freezes the 'main' class, disallowing any code to be added to it. This
506
506
  essentially means that you can't have any code outside of a node,
507
507
  class, or definition other than in the site manifest.",
508
+ },
509
+ :trusted_server_facts => {
510
+ :default => false,
511
+ :type => :boolean,
512
+ :desc => "When enabled, Puppet creates a protected top-scope variable called $server_facts.
513
+ This variable name can't be re-used in any local scope, and can't be overridden
514
+ by agent-provided facts.
515
+
516
+ The $server_facts variable is a hash, containing server-provided information
517
+ like the current node's environment and the version of Puppet running on the server.",
518
+ },
519
+ :preview_outputdir => {
520
+ :default => '$vardir/preview',
521
+ :type => :directory,
522
+ :mode => "0750",
523
+ :owner => "service",
524
+ :group => "service",
525
+ :desc => "The directory where catalog previews per node are generated."
508
526
  }
509
527
  )
510
528
  Puppet.define_settings(:module_tool,
@@ -190,7 +190,7 @@ module Puppet::Environments
190
190
 
191
191
  private
192
192
 
193
- def create_environment(name, setting_values = nil)
193
+ def create_environment(name)
194
194
  env_symbol = name.intern
195
195
  setting_values = Puppet.settings.values(env_symbol, Puppet.settings.preferred_run_mode)
196
196
  Puppet::Node::Environment.create(
@@ -54,8 +54,34 @@ module Puppet
54
54
  include ExternalFileError
55
55
  end
56
56
 
57
+ # Contains an issue code and can be annotated with an environment and a node
58
+ class ParseErrorWithIssue < Puppet::ParseError
59
+ attr_reader :issue_code, :basic_message
60
+ attr_accessor :environment, :node
61
+
62
+ # @param message [String] The error message
63
+ # @param file [String] The path to the file where the error was found
64
+ # @param line [Integer] The line in the file
65
+ # @param pos [Integer] The position on the line
66
+ # @param original [Exception] Original exception
67
+ # @param issue_code [Symbol] The issue code
68
+ #
69
+ def initialize(message, file=nil, line=nil, pos=nil, original=nil, issue_code= nil)
70
+ super(message, file, line, pos, original)
71
+ @issue_code = issue_code
72
+ @basic_message = message
73
+ end
74
+
75
+ def to_s
76
+ msg = super
77
+ msg = "Could not parse for environment #{environment}: #{msg}" if environment
78
+ msg = "#{msg} on node #{node}" if node
79
+ msg
80
+ end
81
+ end
82
+
57
83
  # An error that already contains location information in the message text
58
- class PreformattedError < Puppet::ParseError
84
+ class PreformattedError < Puppet::ParseErrorWithIssue
59
85
  end
60
86
 
61
87
  # An error class for when I don't know what happened. Automatically
@@ -12,7 +12,7 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
12
12
  extend Puppet::Indirector
13
13
  indirects :file_metadata, :terminus_class => :selector
14
14
 
15
- attr_reader :path, :owner, :group, :mode, :checksum_type, :checksum, :ftype, :destination
15
+ attr_reader :path, :owner, :group, :mode, :checksum_type, :checksum, :ftype, :destination, :source_permissions
16
16
 
17
17
  PARAM_ORDER = [:mode, :ftype, :owner, :group]
18
18
 
@@ -22,10 +22,16 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
22
22
  @checksum_type = type
23
23
  end
24
24
 
25
+ def source_permissions=(source_permissions)
26
+ raise(ArgumentError, "Unsupported source_permission #{source_permissions}") unless [:use, :use_when_creating, :ignore].include?(source_permissions.intern)
27
+
28
+ @source_permissions = source_permissions.intern
29
+ end
30
+
25
31
  class MetaStat
26
32
  extend Forwardable
27
33
 
28
- def initialize(stat, source_permissions = nil)
34
+ def initialize(stat, source_permissions)
29
35
  @stat = stat
30
36
  @source_permissions_ignore = (!source_permissions || source_permissions == :ignore)
31
37
  end
@@ -50,7 +56,7 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
50
56
  require 'puppet/util/windows/security'
51
57
  end
52
58
 
53
- def initialize(stat, path, source_permissions = nil)
59
+ def initialize(stat, path, source_permissions)
54
60
  super(stat, source_permissions)
55
61
  @path = path
56
62
  raise(ArgumentError, "Unsupported Windows source permissions option #{source_permissions}") unless @source_permissions_ignore
@@ -66,13 +72,13 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
66
72
  end
67
73
  end
68
74
 
69
- def collect_stat(path, source_permissions)
75
+ def collect_stat(path)
70
76
  stat = stat()
71
77
 
72
78
  if Puppet.features.microsoft_windows?
73
- WindowsStat.new(stat, path, source_permissions)
79
+ WindowsStat.new(stat, path, @source_permissions)
74
80
  else
75
- MetaStat.new(stat, source_permissions)
81
+ MetaStat.new(stat, @source_permissions)
76
82
  end
77
83
  end
78
84
 
@@ -82,7 +88,7 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
82
88
  def collect(source_permissions = nil)
83
89
  real_path = full_path
84
90
 
85
- stat = collect_stat(real_path, source_permissions)
91
+ stat = collect_stat(real_path)
86
92
  @owner = stat.owner
87
93
  @group = stat.group
88
94
  @ftype = stat.ftype
@@ -130,7 +136,6 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
130
136
  },
131
137
  'type' => ftype,
132
138
  'destination' => destination,
133
-
134
139
  }
135
140
  )
136
141
  end
@@ -2,19 +2,18 @@ require 'puppet/file_serving'
2
2
  require 'puppet/file_serving/fileset'
3
3
 
4
4
  # Define some common methods for FileServing termini.
5
+
5
6
  module Puppet::FileServing::TerminusHelper
6
7
  # Create model instance for a file in a file server.
7
8
  def path2instance(request, path, options = {})
8
9
  result = model.new(path, :relative_path => options[:relative_path])
9
- result.checksum_type = request.options[:checksum_type] if request.options[:checksum_type]
10
10
  result.links = request.options[:links] if request.options[:links]
11
11
 
12
- # :ignore_source_permissions is here pending investigation in PUP-3906.
13
- if options[:ignore_source_permissions]
14
- result.collect
15
- else
16
- result.collect(request.options[:source_permissions])
17
- end
12
+ result.checksum_type = request.options[:checksum_type] if request.options[:checksum_type]
13
+ result.source_permissions = request.options[:source_permissions] if request.options[:source_permissions]
14
+
15
+ result.collect
16
+
18
17
  result
19
18
  end
20
19
 
@@ -26,7 +25,7 @@ module Puppet::FileServing::TerminusHelper
26
25
  end
27
26
 
28
27
  Puppet::FileServing::Fileset.merge(*filesets).collect do |file, base_path|
29
- path2instance(request, base_path, :ignore_source_permissions => true, :relative_path => file)
28
+ path2instance(request, base_path, :relative_path => file)
30
29
  end
31
30
  end
32
31
  end