puppet 3.7.5-x86-mingw32 → 3.8.1-x86-mingw32

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 (108) hide show
  1. checksums.yaml +4 -4
  2. data/ext/build_defaults.yaml +5 -5
  3. data/lib/hiera/puppet_function.rb +15 -4
  4. data/lib/puppet.rb +5 -2
  5. data/lib/puppet/application/agent.rb +5 -0
  6. data/lib/puppet/application/apply.rb +5 -0
  7. data/lib/puppet/application/device.rb +8 -3
  8. data/lib/puppet/application/master.rb +5 -0
  9. data/lib/puppet/defaults.rb +8 -0
  10. data/lib/puppet/error.rb +27 -1
  11. data/lib/puppet/file_system.rb +13 -0
  12. data/lib/puppet/file_system/file19windows.rb +8 -0
  13. data/lib/puppet/file_system/file_impl.rb +4 -0
  14. data/lib/puppet/file_system/memory_impl.rb +4 -0
  15. data/lib/puppet/functions.rb +25 -3
  16. data/lib/puppet/functions/defined.rb +130 -0
  17. data/lib/puppet/functions/hiera_include.rb +1 -1
  18. data/lib/puppet/node/environment.rb +4 -0
  19. data/lib/puppet/parser/compiler.rb +5 -2
  20. data/lib/puppet/parser/functions/defined.rb +26 -1
  21. data/lib/puppet/parser/functions/file.rb +3 -1
  22. data/lib/puppet/parser/templatewrapper.rb +2 -1
  23. data/lib/puppet/pops.rb +5 -0
  24. data/lib/puppet/pops/evaluator/access_operator.rb +25 -5
  25. data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -11
  26. data/lib/puppet/pops/evaluator/compare_operator.rb +43 -0
  27. data/lib/puppet/pops/evaluator/evaluator_impl.rb +43 -28
  28. data/lib/puppet/pops/evaluator/runtime3_support.rb +9 -5
  29. data/lib/puppet/pops/functions/dispatch.rb +6 -1
  30. data/lib/puppet/pops/issue_reporter.rb +42 -16
  31. data/lib/puppet/pops/issues.rb +96 -0
  32. data/lib/puppet/pops/loader/module_loaders.rb +3 -1
  33. data/lib/puppet/pops/loaders.rb +6 -4
  34. data/lib/puppet/pops/migration/migration_checker.rb +45 -0
  35. data/lib/puppet/pops/model/factory.rb +1 -1
  36. data/lib/puppet/pops/model/model_meta.rb +1 -1
  37. data/lib/puppet/pops/parser/egrammar.ra +1 -1
  38. data/lib/puppet/pops/parser/eparser.rb +1 -1
  39. data/lib/puppet/pops/parser/epp_support.rb +18 -9
  40. data/lib/puppet/pops/parser/evaluating_parser.rb +7 -1
  41. data/lib/puppet/pops/parser/heredoc_support.rb +12 -11
  42. data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
  43. data/lib/puppet/pops/parser/lexer2.rb +8 -8
  44. data/lib/puppet/pops/parser/lexer_support.rb +46 -20
  45. data/lib/puppet/pops/parser/parser_support.rb +11 -14
  46. data/lib/puppet/pops/parser/slurp_support.rb +22 -6
  47. data/lib/puppet/pops/types/type_calculator.rb +156 -55
  48. data/lib/puppet/pops/types/type_factory.rb +67 -14
  49. data/lib/puppet/pops/types/type_parser.rb +22 -13
  50. data/lib/puppet/pops/types/types.rb +21 -3
  51. data/lib/puppet/pops/types/types_meta.rb +13 -2
  52. data/lib/puppet/pops/validation.rb +25 -2
  53. data/lib/puppet/pops/validation/checker4_0.rb +25 -5
  54. data/lib/puppet/provider/group/windows_adsi.rb +18 -6
  55. data/lib/puppet/provider/mount/parsed.rb +145 -2
  56. data/lib/puppet/provider/package/pip.rb +4 -5
  57. data/lib/puppet/provider/package/zypper.rb +17 -7
  58. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +35 -10
  59. data/lib/puppet/provider/service/init.rb +7 -0
  60. data/lib/puppet/provider/user/windows_adsi.rb +8 -1
  61. data/lib/puppet/provider/zpool/zpool.rb +7 -2
  62. data/lib/puppet/resource.rb +1 -1
  63. data/lib/puppet/type/group.rb +1 -1
  64. data/lib/puppet/type/mount.rb +14 -3
  65. data/lib/puppet/type/scheduled_task.rb +21 -6
  66. data/lib/puppet/util/log.rb +50 -8
  67. data/lib/puppet/util/log/destinations.rb +23 -2
  68. data/lib/puppet/util/logging.rb +37 -1
  69. data/lib/puppet/util/windows/adsi.rb +36 -11
  70. data/lib/puppet/version.rb +1 -1
  71. data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
  72. data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
  73. data/spec/integration/parser/collector_spec.rb +7 -0
  74. data/spec/integration/parser/future_compiler_spec.rb +9 -0
  75. data/spec/integration/parser/resource_expressions_spec.rb +3 -0
  76. data/spec/unit/file_system_spec.rb +38 -0
  77. data/spec/unit/functions/defined_spec.rb +291 -0
  78. data/spec/unit/functions/hiera_spec.rb +8 -6
  79. data/spec/unit/functions4_spec.rb +97 -2
  80. data/spec/unit/parser/functions/file_spec.rb +8 -2
  81. data/spec/unit/parser/functions/template_spec.rb +1 -1
  82. data/spec/unit/parser/templatewrapper_spec.rb +1 -1
  83. data/spec/unit/pops/evaluator/access_ops_spec.rb +19 -0
  84. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +61 -8
  85. data/spec/unit/pops/issues_spec.rb +16 -16
  86. data/spec/unit/pops/loaders/module_loaders_spec.rb +5 -0
  87. data/spec/unit/pops/migration_spec.rb +180 -0
  88. data/spec/unit/pops/parser/lexer2_spec.rb +152 -1
  89. data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
  90. data/spec/unit/pops/transformer/transform_calls_spec.rb +1 -1
  91. data/spec/unit/pops/types/type_calculator_spec.rb +204 -11
  92. data/spec/unit/pops/validation_spec.rb +66 -0
  93. data/spec/unit/provider/group/windows_adsi_spec.rb +65 -1
  94. data/spec/unit/provider/mount/parsed_spec.rb +31 -5
  95. data/spec/unit/provider/package/pip_spec.rb +19 -7
  96. data/spec/unit/provider/package/zypper_spec.rb +25 -14
  97. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +312 -70
  98. data/spec/unit/provider/service/base_spec.rb +42 -31
  99. data/spec/unit/provider/service/freebsd_spec.rb +1 -0
  100. data/spec/unit/provider/service/gentoo_spec.rb +1 -0
  101. data/spec/unit/provider/service/init_spec.rb +18 -0
  102. data/spec/unit/provider/service/openbsd_spec.rb +1 -0
  103. data/spec/unit/provider/service/redhat_spec.rb +1 -0
  104. data/spec/unit/provider/user/windows_adsi_spec.rb +21 -0
  105. data/spec/unit/provider/zpool/zpool_spec.rb +47 -10
  106. data/spec/unit/util/log_spec.rb +113 -0
  107. data/spec/unit/util/windows/adsi_spec.rb +106 -26
  108. metadata +10 -2
@@ -24,8 +24,44 @@ module Puppet::Util::Logging
24
24
  # wish to log a message at all; in this case it is likely that you are only calling this method in order
25
25
  # to take advantage of the backtrace logging.
26
26
  def log_exception(exception, message = :default, options = {})
27
- err(format_exception(exception, message, Puppet[:trace] || options[:trace]))
27
+ trace = Puppet[:trace] || options[:trace]
28
+ if message == :default && exception.is_a?(Puppet::ParseErrorWithIssue)
29
+ # Retain all detailed info and keep plain message and stacktrace separate
30
+ backtrace = []
31
+ build_exception_trace(backtrace, exception, trace)
32
+ Puppet::Util::Log.create({
33
+ :level => :err,
34
+ :source => log_source,
35
+ :message => exception.basic_message,
36
+ :issue_code => exception.issue_code,
37
+ :backtrace => backtrace.empty? ? nil : backtrace,
38
+ :file => exception.file,
39
+ :line => exception.line,
40
+ :pos => exception.pos,
41
+ :environment => exception.environment,
42
+ :node => exception.node
43
+ }.merge(log_metadata))
44
+ else
45
+ err(format_exception(exception, message, trace))
46
+ end
47
+ end
48
+
49
+ def build_exception_trace(arr, exception, trace = true)
50
+ if trace and exception.backtrace
51
+ exception.backtrace.each do |line|
52
+ arr << line =~ /^(.+):(\d+.*)$/ ? ("#{Pathname($1).realpath}:#{$2}" rescue line) : line
53
+ end
54
+ end
55
+ if exception.respond_to?(:original)
56
+ original = exception.original
57
+ unless original.nil?
58
+ arr << 'Wrapped exception:'
59
+ arr << original.message
60
+ build_exception_trace(arr, original, trace)
61
+ end
62
+ end
28
63
  end
64
+ private :build_exception_trace
29
65
 
30
66
  def format_exception(exception, message = :default, trace = true)
31
67
  arr = []
@@ -15,7 +15,7 @@ module Puppet::Util::Windows::ADSI
15
15
  def connect(uri)
16
16
  begin
17
17
  WIN32OLE.connect(uri)
18
- rescue Exception => e
18
+ rescue WIN32OLERuntimeError => e
19
19
  raise Puppet::Error.new( "ADSI connection error: #{e}", e )
20
20
  end
21
21
  end
@@ -161,7 +161,15 @@ module Puppet::Util::Windows::ADSI
161
161
  def commit
162
162
  begin
163
163
  native_user.SetInfo unless native_user.nil?
164
- rescue Exception => e
164
+ rescue WIN32OLERuntimeError => e
165
+ # ERROR_BAD_USERNAME 2202L from winerror.h
166
+ if e.message =~ /8007089A/m
167
+ raise Puppet::Error.new(
168
+ "Puppet is not able to create/delete domain users with the user resource.",
169
+ e
170
+ )
171
+ end
172
+
165
173
  raise Puppet::Error.new( "User update failed: #{e}", e )
166
174
  end
167
175
  self
@@ -285,7 +293,7 @@ module Puppet::Util::Windows::ADSI
285
293
  def self.delete(sid)
286
294
  begin
287
295
  Puppet::Util::Windows::ADSI.wmi_connection.Delete("Win32_UserProfile.SID='#{sid}'")
288
- rescue => e
296
+ rescue WIN32OLERuntimeError => e
289
297
  # http://social.technet.microsoft.com/Forums/en/ITCG/thread/0f190051-ac96-4bf1-a47f-6b864bfacee5
290
298
  # Prior to Vista SP1, there's no builtin way to programmatically
291
299
  # delete user profiles (except for delprof.exe). So try to delete
@@ -328,7 +336,15 @@ module Puppet::Util::Windows::ADSI
328
336
  def commit
329
337
  begin
330
338
  native_group.SetInfo unless native_group.nil?
331
- rescue Exception => e
339
+ rescue WIN32OLERuntimeError => e
340
+ # ERROR_BAD_USERNAME 2202L from winerror.h
341
+ if e.message =~ /8007089A/m
342
+ raise Puppet::Error.new(
343
+ "Puppet is not able to create/delete domain groups with the group resource.",
344
+ e
345
+ )
346
+ end
347
+
332
348
  raise Puppet::Error.new( "Group update failed: #{e}", e )
333
349
  end
334
350
  self
@@ -387,19 +403,28 @@ module Puppet::Util::Windows::ADSI
387
403
  sids
388
404
  end
389
405
 
390
- def set_members(desired_members)
391
- return if desired_members.nil? or desired_members.empty?
406
+ def set_members(desired_members, inclusive = true)
407
+ return if desired_members.nil?
392
408
 
393
409
  current_hash = Hash[ self.member_sids.map { |sid| [sid.to_s, sid] } ]
394
410
  desired_hash = self.class.name_sid_hash(desired_members)
395
411
 
396
412
  # First we add all missing members
397
- members_to_add = (desired_hash.keys - current_hash.keys).map { |sid| desired_hash[sid] }
398
- add_member_sids(*members_to_add)
413
+ if !desired_hash.empty?
414
+ members_to_add = (desired_hash.keys - current_hash.keys).map { |sid| desired_hash[sid] }
415
+ add_member_sids(*members_to_add)
416
+ end
417
+
418
+ # Then we remove all extra members if inclusive
419
+ if inclusive
420
+ if desired_hash.empty?
421
+ members_to_remove = current_hash.values
422
+ else
423
+ members_to_remove = (current_hash.keys - desired_hash.keys).map { |sid| current_hash[sid] }
424
+ end
399
425
 
400
- # Then we remove all extra members
401
- members_to_remove = (current_hash.keys - desired_hash.keys).map { |sid| current_hash[sid] }
402
- remove_member_sids(*members_to_remove)
426
+ remove_member_sids(*members_to_remove)
427
+ end
403
428
  end
404
429
 
405
430
  def self.create(name)
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  module Puppet
10
- PUPPETVERSION = '3.7.5'
10
+ PUPPETVERSION = '3.8.1'
11
11
 
12
12
  ##
13
13
  # version is a public API method intended to always provide a fast and
@@ -35,110 +35,118 @@
35
35
  *
36
36
 
37
37
  /:
38
- dev = /dev/hd4
39
- vfs = jfs2
40
- log = /dev/hd8
41
- mount = automatic
42
- check = false
43
- type = bootfs
44
- vol = root
45
- free = true
46
- quota = no
38
+ dev = /dev/hd4
39
+ vfs = jfs2
40
+ check = false
41
+ free = true
42
+ log = NULL
43
+ mount = automatic
44
+ quota = no
45
+ type = bootfs
46
+ vol = root
47
47
 
48
48
  /home:
49
- dev = /dev/hd1
50
- vfs = jfs2
51
- log = /dev/hd8
52
- mount = true
53
- check = true
54
- vol = /home
55
- free = false
56
- quota = no
49
+ dev = /dev/hd1
50
+ vfs = jfs2
51
+ check = true
52
+ free = false
53
+ log = NULL
54
+ mount = true
55
+ quota = no
56
+ vol = /home
57
57
 
58
58
  /usr:
59
- dev = /dev/hd2
60
- vfs = jfs2
61
- log = /dev/hd8
62
- mount = automatic
63
- check = false
64
- type = bootfs
65
- vol = /usr
66
- free = false
67
- quota = no
59
+ dev = /dev/hd2
60
+ vfs = jfs2
61
+ check = false
62
+ free = false
63
+ log = NULL
64
+ mount = automatic
65
+ quota = no
66
+ type = bootfs
67
+ vol = /usr
68
68
 
69
69
  /var:
70
- dev = /dev/hd9var
71
- vfs = jfs2
72
- log = /dev/hd8
73
- mount = automatic
74
- check = false
75
- type = bootfs
76
- vol = /var
77
- free = false
78
- quota = no
70
+ dev = /dev/hd9var
71
+ vfs = jfs2
72
+ check = false
73
+ free = false
74
+ log = NULL
75
+ mount = automatic
76
+ quota = no
77
+ type = bootfs
78
+ vol = /var
79
79
 
80
80
  /tmp:
81
- dev = /dev/hd3
82
- vfs = jfs2
83
- log = /dev/hd8
84
- mount = automatic
85
- check = false
86
- vol = /tmp
87
- free = false
88
- quota = no
81
+ dev = /dev/hd3
82
+ vfs = jfs2
83
+ check = false
84
+ free = false
85
+ log = NULL
86
+ mount = automatic
87
+ quota = no
88
+ vol = /tmp
89
89
 
90
90
  /admin:
91
- dev = /dev/hd11admin
92
- vfs = jfs2
93
- log = /dev/hd8
94
- mount = true
95
- check = false
96
- vol = /admin
97
- free = false
98
- quota = no
91
+ dev = /dev/hd11admin
92
+ vfs = jfs2
93
+ check = false
94
+ free = false
95
+ log = NULL
96
+ mount = true
97
+ quota = no
98
+ vol = /admin
99
99
 
100
100
  /proc:
101
- dev = /proc
102
- vol = "/proc"
103
- mount = true
104
- check = false
105
- free = false
106
- vfs = procfs
101
+ dev = /proc
102
+ vol = "/proc"
103
+ mount = true
104
+ check = false
105
+ free = false
106
+ vfs = procfs
107
107
 
108
108
  /opt:
109
- dev = /dev/hd10opt
110
- vfs = jfs2
111
- log = /dev/hd8
112
- mount = true
113
- check = true
114
- vol = /opt
115
- free = false
116
- quota = no
109
+ dev = /dev/hd10opt
110
+ vfs = jfs2
111
+ log = /dev/hd8
112
+ mount = true
113
+ check = true
114
+ vol = /opt
115
+ free = false
116
+ quota = no
117
117
 
118
118
  /var/adm/ras/livedump:
119
- dev = /dev/livedump
120
- vfs = jfs2
121
- log = /dev/hd8
122
- mount = true
123
- account = false
124
- quota = no
119
+ dev = /dev/livedump
120
+ vfs = jfs2
121
+ log = /dev/hd8
122
+ mount = true
123
+ account = false
124
+ quota = no
125
125
 
126
126
 
127
127
  /stage/middleware:
128
- dev = "/stage/middleware"
129
- vfs = nfs
130
- nodename = 192.168.1.11
131
- mount = true
132
- type = nfs
133
- options = ro,bg,hard,intr,sec=sys
134
- account = false
128
+ dev = "/stage/middleware"
129
+ vfs = nfs
130
+ nodename = 192.168.1.11
131
+ mount = true
132
+ type = nfs
133
+ options = ro,bg,hard,intr,sec=sys
134
+ account = false
135
135
 
136
136
  /home/u0010689:
137
- dev = "/userdata/20010689"
138
- vfs = nfs
139
- nodename = 192.168.1.11
140
- mount = true
141
- type = nfs
142
- options = bg,hard,intr
143
- account = false
137
+ dev = "/userdata/20010689"
138
+ vfs = nfs
139
+ nodename = 192.168.1.11
140
+ mount = true
141
+ type = nfs
142
+ options = bg,hard,intr
143
+ account = false
144
144
 
145
+ /srv/aix:
146
+ dev = /srv/aix
147
+ nodename = mynode
148
+ vfs = nfs
149
+ account = false
150
+ log = NULL
151
+ mount = true
152
+ options = vers=2
@@ -1,7 +1,11 @@
1
- node mounted mounted over vfs date options
2
- ---- ------- ------------ --- ------------ -------------------
3
- /dev/hd0 / jfs Dec 17 08:04 rw, log =/dev/hd8
4
- /dev/hd3 /tmp jfs Dec 17 08:04 rw, log =/dev/hd8
5
- /dev/hd1 /home jfs Dec 17 08:06 rw, log =/dev/hd8
6
- /dev/hd2 /usr jfs Dec 17 08:06 rw, log =/dev/hd8
7
- sue /home/local/src /usr/code nfs Dec 17 08:06 ro, log =/dev/hd8
1
+ node mounted mounted over vfs date options
2
+ -------- --------------- --------------- ------ ------------ ---------------
3
+ /dev/hd4 / jfs2 Feb 05 10:27 rw,log=NULL
4
+ /dev/hd2 /usr jfs2 Feb 05 10:28 rw,log=NULL
5
+ /dev/hd9var /var jfs2 Feb 05 10:28 rw,log=NULL
6
+ /dev/hd3 /tmp jfs2 Feb 05 10:28 rw,log=NULL
7
+ /dev/hd1 /home jfs2 Feb 05 10:28 rw,log=NULL
8
+ /dev/hd11admin /admin jfs2 Feb 05 10:28 rw,log=NULL
9
+ /proc /proc procfs Feb 05 10:28 rw
10
+ /dev/hd10opt /opt jfs2 Feb 05 10:28 rw,log=NULL
11
+ mynode /srv/aix /srv/aix nfs Mar 19 14:33 vers=2,rw
@@ -313,5 +313,12 @@ describe Puppet::Parser::Collector do
313
313
  end
314
314
 
315
315
  it_behaves_like "virtual resource collection"
316
+
317
+ it "collects and overrides attributes specified with a * => hash" do
318
+ expect_the_message_to_be(["overridden1"], <<-MANIFEST)
319
+ notify { "testing": message => "original" }
320
+ Notify <| |> { * => { message => 'overridden1' }}
321
+ MANIFEST
322
+ end
316
323
  end
317
324
  end
@@ -506,6 +506,15 @@ describe "Puppet::Parser::Compiler" do
506
506
  MANIFEST
507
507
  expect(catalog).to have_resource("Notify[test]").with_parameter(:message, 'knock knock')
508
508
  end
509
+
510
+ it 'uses infer_set when reporting type mismatch' do
511
+ expect do
512
+ catalog = compile_to_catalog(<<-MANIFEST)
513
+ define foo(Struct[{b => Integer, d=>String}] $a) { }
514
+ foo{ bar: a => {b => 5, c => 'stuff'}}
515
+ MANIFEST
516
+ end.to raise_error(/got Struct\[\{'b'=>Integer, 'c'=>String\}\]/)
517
+ end
509
518
  end
510
519
 
511
520
  context 'when using typed parameters in class' do
@@ -170,6 +170,9 @@ describe "Puppet resource expressions" do
170
170
  path => '/somewhere',
171
171
  * => $y }" => "File[$t][mode] == '0666' and File[$t][owner] == 'the_x' and File[$t][path] == '/somewhere'")
172
172
 
173
+ produces("notify{title:}; Notify[title] { * => { message => set}}" => "Notify[title][message] == 'set'")
174
+ produces("Notify { * => { message => set}}; notify{title:}" => "Notify[title][message] == 'set'")
175
+
173
176
  fails("notify { title: unknown => value }" => /Invalid parameter unknown/)
174
177
 
175
178
  # this really needs to be a better error message.
@@ -5,6 +5,18 @@ require 'puppet/util/platform'
5
5
  describe "Puppet::FileSystem" do
6
6
  include PuppetSpec::Files
7
7
 
8
+ def with_file_content(content)
9
+ path = tmpfile('file-system')
10
+ file = File.new(path, 'wb')
11
+ file.sync = true
12
+ file.print content
13
+
14
+ yield path
15
+
16
+ ensure
17
+ file.close
18
+ end
19
+
8
20
  context "#exclusive_open" do
9
21
  it "opens ands allows updating of an existing file" do
10
22
  file = file_containing("file_to_update", "the contents")
@@ -96,6 +108,32 @@ describe "Puppet::FileSystem" do
96
108
  end
97
109
  end
98
110
 
111
+ context "read_preserve_line_endings" do
112
+ it "should read a file with line feed" do
113
+ with_file_content("file content \n") do |file|
114
+ expect(Puppet::FileSystem.read_preserve_line_endings(file)).to eq("file content \n")
115
+ end
116
+ end
117
+
118
+ it "should read a file with carriage return line feed" do
119
+ with_file_content("file content \r\n") do |file|
120
+ expect(Puppet::FileSystem.read_preserve_line_endings(file)).to eq("file content \r\n")
121
+ end
122
+ end
123
+
124
+ it "should read a mixed file using only the first line newline when lf" do
125
+ with_file_content("file content \nsecond line \r\n") do |file|
126
+ expect(Puppet::FileSystem.read_preserve_line_endings(file)).to eq("file content \nsecond line \r\n")
127
+ end
128
+ end
129
+
130
+ it "should read a mixed file using only the first line newline when crlf" do
131
+ with_file_content("file content \r\nsecond line \n") do |file|
132
+ expect(Puppet::FileSystem.read_preserve_line_endings(file)).to eq("file content \r\nsecond line \n")
133
+ end
134
+ end
135
+ end
136
+
99
137
  describe "symlink",
100
138
  :if => ! Puppet.features.manages_symlinks? &&
101
139
  Puppet.features.microsoft_windows? do