bolt 0.21.7 → 0.21.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bolt might be problematic. Click here for more details.

Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bolt/transport/ssh/connection.rb +4 -5
  3. data/lib/bolt/transport/ssh.rb +4 -1
  4. data/lib/bolt/transport/winrm/connection.rb +3 -4
  5. data/lib/bolt/transport/winrm.rb +4 -1
  6. data/lib/bolt/version.rb +1 -1
  7. data/libexec/apply_catalog.rb +10 -2
  8. data/vendored/puppet/lib/puppet/application/apply.rb +20 -9
  9. data/vendored/puppet/lib/puppet/application/cert.rb +3 -1
  10. data/vendored/puppet/lib/puppet/application/device.rb +22 -5
  11. data/vendored/puppet/lib/puppet/configurer/fact_handler.rb +5 -1
  12. data/vendored/puppet/lib/puppet/configurer.rb +15 -2
  13. data/vendored/puppet/lib/puppet/defaults.rb +36 -25
  14. data/vendored/puppet/lib/puppet/face/certificate.rb +2 -0
  15. data/vendored/puppet/lib/puppet/feature/base.rb +0 -3
  16. data/vendored/puppet/lib/puppet/functions/call.rb +37 -0
  17. data/vendored/puppet/lib/puppet/functions.rb +5 -0
  18. data/vendored/puppet/lib/puppet/indirector/ldap.rb +6 -0
  19. data/vendored/puppet/lib/puppet/node/environment.rb +4 -2
  20. data/vendored/puppet/lib/puppet/parser/scope.rb +2 -2
  21. data/vendored/puppet/lib/puppet/pops/adapters.rb +14 -0
  22. data/vendored/puppet/lib/puppet/pops/evaluator/deferred_resolver.rb +128 -0
  23. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +4 -1
  24. data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +2 -0
  25. data/vendored/puppet/lib/puppet/pops/issues.rb +9 -1
  26. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +0 -16
  27. data/vendored/puppet/lib/puppet/pops/loaders.rb +1 -3
  28. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +6 -6
  29. data/vendored/puppet/lib/puppet/pops/pcore.rb +11 -0
  30. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +17 -0
  31. data/vendored/puppet/lib/puppet/pops/validation/tasks_checker.rb +13 -5
  32. data/vendored/puppet/lib/puppet/pops.rb +1 -0
  33. data/vendored/puppet/lib/puppet/provider/service/debian.rb +1 -0
  34. data/vendored/puppet/lib/puppet/provider/service/smf.rb +2 -3
  35. data/vendored/puppet/lib/puppet/provider/service/upstart.rb +10 -2
  36. data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +6 -84
  37. data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +11 -3
  38. data/vendored/puppet/lib/puppet/type/file.rb +3 -0
  39. data/vendored/puppet/lib/puppet/type/user.rb +17 -3
  40. data/vendored/puppet/lib/puppet/util/autoload.rb +36 -31
  41. data/vendored/puppet/lib/puppet/util.rb +2 -0
  42. metadata +3 -43
  43. data/vendored/puppet/lib/puppet/indirector/node/write_only_yaml.rb +0 -39
  44. data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +0 -573
  45. data/vendored/puppet/lib/puppet/provider/cisco.rb +0 -9
  46. data/vendored/puppet/lib/puppet/provider/computer/computer.rb +0 -20
  47. data/vendored/puppet/lib/puppet/provider/host/parsed.rb +0 -46
  48. data/vendored/puppet/lib/puppet/provider/interface/cisco.rb +0 -27
  49. data/vendored/puppet/lib/puppet/provider/macauthorization/macauthorization.rb +0 -298
  50. data/vendored/puppet/lib/puppet/provider/mcx/mcxcontent.rb +0 -173
  51. data/vendored/puppet/lib/puppet/provider/mount/parsed.rb +0 -282
  52. data/vendored/puppet/lib/puppet/provider/mount.rb +0 -76
  53. data/vendored/puppet/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +0 -590
  54. data/vendored/puppet/lib/puppet/provider/selboolean/getsetsebool.rb +0 -47
  55. data/vendored/puppet/lib/puppet/provider/selmodule/semodule.rb +0 -140
  56. data/vendored/puppet/lib/puppet/provider/ssh_authorized_key/parsed.rb +0 -105
  57. data/vendored/puppet/lib/puppet/provider/sshkey/parsed.rb +0 -50
  58. data/vendored/puppet/lib/puppet/provider/vlan/cisco.rb +0 -28
  59. data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +0 -315
  60. data/vendored/puppet/lib/puppet/type/augeas.rb +0 -211
  61. data/vendored/puppet/lib/puppet/type/computer.rb +0 -66
  62. data/vendored/puppet/lib/puppet/type/host.rb +0 -95
  63. data/vendored/puppet/lib/puppet/type/interface.rb +0 -121
  64. data/vendored/puppet/lib/puppet/type/k5login.rb +0 -165
  65. data/vendored/puppet/lib/puppet/type/macauthorization.rb +0 -167
  66. data/vendored/puppet/lib/puppet/type/mcx.rb +0 -98
  67. data/vendored/puppet/lib/puppet/type/mount.rb +0 -314
  68. data/vendored/puppet/lib/puppet/type/router.rb +0 -17
  69. data/vendored/puppet/lib/puppet/type/scheduled_task.rb +0 -183
  70. data/vendored/puppet/lib/puppet/type/selboolean.rb +0 -26
  71. data/vendored/puppet/lib/puppet/type/selmodule.rb +0 -59
  72. data/vendored/puppet/lib/puppet/type/ssh_authorized_key.rb +0 -143
  73. data/vendored/puppet/lib/puppet/type/sshkey.rb +0 -83
  74. data/vendored/puppet/lib/puppet/type/vlan.rb +0 -26
  75. data/vendored/puppet/lib/puppet/type/yumrepo.rb +0 -430
  76. data/vendored/puppet/lib/puppet/util/network_device/cisco/device.rb +0 -285
  77. data/vendored/puppet/lib/puppet/util/network_device/cisco/facts.rb +0 -72
  78. data/vendored/puppet/lib/puppet/util/network_device/cisco/interface.rb +0 -94
  79. data/vendored/puppet/lib/puppet/util/network_device/cisco.rb +0 -4
  80. data/vendored/puppet/lib/puppet/util/network_device/ipcalc.rb +0 -68
  81. data/vendored/puppet/lib/puppet/util/network_device/transport/ssh.rb +0 -126
  82. data/vendored/puppet/lib/puppet/util/network_device/transport/telnet.rb +0 -47
  83. data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +0 -1267
@@ -1,573 +0,0 @@
1
- #
2
- # Copyright 2011 Bryan Kearney <bkearney@redhat.com>
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # https://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- require 'augeas' if Puppet.features.augeas?
17
- require 'strscan'
18
- require 'puppet/util'
19
- require 'puppet/util/diff'
20
- require 'puppet/util/package'
21
-
22
- Puppet::Type.type(:augeas).provide(:augeas) do
23
- include Puppet::Util
24
- include Puppet::Util::Diff
25
- include Puppet::Util::Package
26
-
27
- confine :feature => :augeas
28
-
29
- has_features :parse_commands, :need_to_run?,:execute_changes
30
-
31
- SAVE_NOOP = "noop"
32
- SAVE_OVERWRITE = "overwrite"
33
- SAVE_NEWFILE = "newfile"
34
- SAVE_BACKUP = "backup"
35
-
36
- COMMANDS = {
37
- "set" => [ :path, :string ],
38
- "setm" => [ :path, :string, :string ],
39
- "rm" => [ :path ],
40
- "clear" => [ :path ],
41
- "clearm" => [ :path, :string ],
42
- "touch" => [ :path ],
43
- "mv" => [ :path, :path ],
44
- "rename" => [ :path, :string ],
45
- "insert" => [ :string, :string, :path ],
46
- "get" => [ :path, :comparator, :string ],
47
- "values" => [ :path, :glob ],
48
- "defvar" => [ :string, :path ],
49
- "defnode" => [ :string, :path, :string ],
50
- "match" => [ :path, :glob ],
51
- "size" => [:comparator, :int],
52
- "include" => [:string],
53
- "not_include" => [:string],
54
- "==" => [:glob],
55
- "!=" => [:glob]
56
- }
57
-
58
- COMMANDS["ins"] = COMMANDS["insert"]
59
- COMMANDS["remove"] = COMMANDS["rm"]
60
- COMMANDS["move"] = COMMANDS["mv"]
61
-
62
- attr_accessor :aug
63
-
64
- # Extracts an 2 dimensional array of commands which are in the
65
- # form of command path value.
66
- # The input can be
67
- # - A string with one command
68
- # - A string with many commands per line
69
- # - An array of strings.
70
- def parse_commands(data)
71
- context = resource[:context]
72
- # Add a trailing / if it is not there
73
- if (context.length > 0)
74
- context << "/" if context[-1, 1] != "/"
75
- end
76
-
77
- data = data.split($/) if data.is_a?(String)
78
- data = data.flatten
79
- args = []
80
- data.each do |line|
81
- line.strip!
82
- next if line.nil? || line.empty?
83
- argline = []
84
- sc = StringScanner.new(line)
85
- cmd = sc.scan(/\w+|==|!=/)
86
- formals = COMMANDS[cmd]
87
- fail(_("Unknown command %{cmd}") % { cmd: cmd }) unless formals
88
- argline << cmd
89
- narg = 0
90
- formals.each do |f|
91
- sc.skip(/\s+/)
92
- narg += 1
93
- if f == :path
94
- start = sc.pos
95
- nbracket = 0
96
- inSingleTick = false
97
- inDoubleTick = false
98
- begin
99
- sc.skip(/([^\]\[\s\\'"]|\\.)+/)
100
- ch = sc.getch
101
- nbracket += 1 if ch == "["
102
- nbracket -= 1 if ch == "]"
103
- inSingleTick = !inSingleTick if ch == "'"
104
- inDoubleTick = !inDoubleTick if ch == "\""
105
- fail(_("unmatched [")) if nbracket < 0
106
- end until ((nbracket == 0 && !inSingleTick && !inDoubleTick && (ch =~ /\s/)) || sc.eos?)
107
- len = sc.pos - start
108
- len -= 1 unless sc.eos?
109
- unless p = sc.string[start, len]
110
- fail(_("missing path argument %{narg} for %{cmd}") % { narg: narg, cmd: cmd })
111
- end
112
- # Rip off any ticks if they are there.
113
- p = p[1, (p.size - 2)] if p[0,1] == "'" || p[0,1] == "\""
114
- p.chomp!("/")
115
- if p[0,1] != '$' && p[0,1] != "/"
116
- argline << context + p
117
- else
118
- argline << p
119
- end
120
- elsif f == :string
121
- delim = sc.peek(1)
122
- if delim == "'" || delim == "\""
123
- sc.getch
124
- argline << sc.scan(/([^\\#{delim}]|(\\.))*/)
125
- # Unescape the delimiter so it's actually possible to have a
126
- # literal delim inside the string. We only unescape the
127
- # delimeter and not every backslash-escaped character so that
128
- # things like escaped spaces '\ ' get passed through because
129
- # Augeas needs to see them. If we unescaped them, too, users
130
- # would be forced to double-escape them
131
- argline.last.gsub!(/\\(#{delim})/, '\1')
132
- sc.getch
133
- else
134
- argline << sc.scan(/[^\s]+/)
135
- end
136
- fail(_("missing string argument %{narg} for %{cmd}") % { narg: narg, cmd: cmd }) unless argline[-1]
137
- elsif f == :comparator
138
- argline << sc.scan(/(==|!=|=~|<=|>=|<|>)/)
139
- unless argline[-1]
140
- puts sc.rest
141
- fail(_("invalid comparator for command %{cmd}") % { cmd: cmd })
142
- end
143
- elsif f == :int
144
- argline << sc.scan(/\d+/).to_i
145
- elsif f== :glob
146
- argline << sc.rest
147
- end
148
- end
149
- args << argline
150
- end
151
- args
152
- end
153
-
154
-
155
- def open_augeas
156
- unless @aug
157
- flags = Augeas::NONE
158
- flags = Augeas::TYPE_CHECK if resource[:type_check] == :true
159
-
160
- if resource[:incl]
161
- flags |= Augeas::NO_MODL_AUTOLOAD
162
- else
163
- flags |= Augeas::NO_LOAD
164
- end
165
-
166
- root = resource[:root]
167
- load_path = get_load_path(resource)
168
- debug("Opening augeas with root #{root}, lens path #{load_path}, flags #{flags}")
169
- @aug = Augeas::open(root, load_path,flags)
170
-
171
- debug("Augeas version #{get_augeas_version} is installed") if versioncmp(get_augeas_version, "0.3.6") >= 0
172
-
173
- # Optimize loading if the context is given and it's a simple path,
174
- # requires the glob function from Augeas 0.8.2 or up
175
- glob_avail = !aug.match("/augeas/version/pathx/functions/glob").empty?
176
- opt_ctx = resource[:context].match("^/files/[^'\"\\[\\]]+$") if resource[:context]
177
-
178
- if resource[:incl]
179
- aug.set("/augeas/load/Xfm/lens", resource[:lens])
180
- aug.set("/augeas/load/Xfm/incl", resource[:incl])
181
- restricted_metadata = "/augeas//error"
182
- elsif glob_avail and opt_ctx
183
- # Optimize loading if the context is given, requires the glob function
184
- # from Augeas 0.8.2 or up
185
- ctx_path = resource[:context].sub(/^\/files(.*?)\/?$/, '\1/')
186
- load_path = "/augeas/load/*['%s' !~ glob(incl) + regexp('/.*')]" % ctx_path
187
-
188
- if aug.match(load_path).size < aug.match("/augeas/load/*").size
189
- aug.rm(load_path)
190
- restricted_metadata = "/augeas/files#{ctx_path}/error"
191
- else
192
- # This will occur if the context is less specific than any glob
193
- debug("Unable to optimize files loaded by context path, no glob matches")
194
- end
195
- end
196
- aug.load
197
- print_load_errors(restricted_metadata)
198
- end
199
- @aug
200
- end
201
-
202
- def close_augeas
203
- if @aug
204
- @aug.close
205
- debug("Closed the augeas connection")
206
- @aug = nil
207
- end
208
- end
209
-
210
- def is_numeric?(s)
211
- case s
212
- when Integer
213
- true
214
- when String
215
- s.match(/\A[+-]?\d+?(\.\d+)?\Z/n) == nil ? false : true
216
- else
217
- false
218
- end
219
- end
220
-
221
- # Used by the need_to_run? method to process get filters. Returns
222
- # true if there is a match, false if otherwise
223
- # Assumes a syntax of get /files/path [COMPARATOR] value
224
- def process_get(cmd_array)
225
- return_value = false
226
-
227
- #validate and tear apart the command
228
- fail (_("Invalid command: %{cmd}") % { cmd: cmd_array.join(" ") }) if cmd_array.length < 4
229
- _ = cmd_array.shift
230
- path = cmd_array.shift
231
- comparator = cmd_array.shift
232
- arg = cmd_array.join(" ")
233
-
234
- #check the value in augeas
235
- result = @aug.get(path) || ''
236
-
237
- if ['<', '<=', '>=', '>'].include? comparator and is_numeric?(result) and
238
- is_numeric?(arg)
239
- resultf = result.to_f
240
- argf = arg.to_f
241
- return_value = (resultf.send(comparator, argf))
242
- elsif comparator == "!="
243
- return_value = (result != arg)
244
- elsif comparator == "=~"
245
- regex = Regexp.new(arg)
246
- return_value = (result =~ regex)
247
- else
248
- return_value = (result.send(comparator, arg))
249
- end
250
- !!return_value
251
- end
252
-
253
- # Used by the need_to_run? method to process values filters. Returns
254
- # true if there is a matched value, false if otherwise
255
- def process_values(cmd_array)
256
- return_value = false
257
-
258
- #validate and tear apart the command
259
- fail(_("Invalid command: %{cmd}") % { cmd: cmd_array.join(" ") }) if cmd_array.length < 3
260
- _ = cmd_array.shift
261
- path = cmd_array.shift
262
-
263
- # Need to break apart the clause
264
- clause_array = parse_commands(cmd_array.shift)[0]
265
- verb = clause_array.shift
266
-
267
- #Get the match paths from augeas
268
- result = @aug.match(path) || []
269
- fail(_("Error trying to get path '%{path}'") % { path: path }) if (result == -1)
270
-
271
- #Get the values of the match paths from augeas
272
- values = result.collect{|r| @aug.get(r)}
273
-
274
- case verb
275
- when "include"
276
- arg = clause_array.shift
277
- return_value = values.include?(arg)
278
- when "not_include"
279
- arg = clause_array.shift
280
- return_value = !values.include?(arg)
281
- when "=="
282
- begin
283
- arg = clause_array.shift
284
- new_array = eval arg
285
- return_value = (values == new_array)
286
- rescue
287
- fail(_("Invalid array in command: %{cmd}") % { cmd: cmd_array.join(" ") })
288
- end
289
- when "!="
290
- begin
291
- arg = clause_array.shift
292
- new_array = eval arg
293
- return_value = (values != new_array)
294
- rescue
295
- fail(_("Invalid array in command: %{cmd}") % { cmd: cmd_array.join(" ") })
296
- end
297
- end
298
- !!return_value
299
- end
300
-
301
- # Used by the need_to_run? method to process match filters. Returns
302
- # true if there is a match, false if otherwise
303
- def process_match(cmd_array)
304
- return_value = false
305
-
306
- #validate and tear apart the command
307
- fail(_("Invalid command: %{cmd}") % { cmd: cmd_array.join(" ") }) if cmd_array.length < 3
308
- _ = cmd_array.shift
309
- path = cmd_array.shift
310
-
311
- # Need to break apart the clause
312
- clause_array = parse_commands(cmd_array.shift)[0]
313
- verb = clause_array.shift
314
-
315
- #Get the values from augeas
316
- result = @aug.match(path) || []
317
- fail(_("Error trying to match path '%{path}'") % { path: path }) if (result == -1)
318
-
319
- # Now do the work
320
- case verb
321
- when "size"
322
- fail(_("Invalid command: %{cmd}") % { cmd: cmd_array.join(" ") }) if clause_array.length != 2
323
- comparator = clause_array.shift
324
- arg = clause_array.shift
325
- case comparator
326
- when "!="
327
- return_value = !(result.size.send(:==, arg))
328
- else
329
- return_value = (result.size.send(comparator, arg))
330
- end
331
- when "include"
332
- arg = clause_array.shift
333
- return_value = result.include?(arg)
334
- when "not_include"
335
- arg = clause_array.shift
336
- return_value = !result.include?(arg)
337
- when "=="
338
- begin
339
- arg = clause_array.shift
340
- new_array = eval arg
341
- return_value = (result == new_array)
342
- rescue
343
- fail(_("Invalid array in command: %{cmd}") % { cmd: cmd_array.join(" ") })
344
- end
345
- when "!="
346
- begin
347
- arg = clause_array.shift
348
- new_array = eval arg
349
- return_value = (result != new_array)
350
- rescue
351
- fail(_("Invalid array in command: %{cmd}") % { cmd: cmd_array.join(" ") })
352
- end
353
- end
354
- !!return_value
355
- end
356
-
357
- # Generate lens load paths from user given paths and local pluginsync dir
358
- def get_load_path(resource)
359
- load_path = []
360
-
361
- # Permits colon separated strings or arrays
362
- if resource[:load_path]
363
- load_path = [resource[:load_path]].flatten
364
- load_path.map! { |path| path.split(/:/) }
365
- load_path.flatten!
366
- end
367
-
368
- if Puppet::FileSystem.exist?("#{Puppet[:libdir]}/augeas/lenses")
369
- load_path << "#{Puppet[:libdir]}/augeas/lenses"
370
- end
371
-
372
- load_path.join(":")
373
- end
374
-
375
- def get_augeas_version
376
- @aug.get("/augeas/version") || ""
377
- end
378
-
379
- def set_augeas_save_mode(mode)
380
- @aug.set("/augeas/save", mode)
381
- end
382
-
383
- def print_load_errors(path)
384
- errors = @aug.match("/augeas//error")
385
- unless errors.empty?
386
- if path && !@aug.match(path).empty?
387
- warning(_("Loading failed for one or more files, see debug for /augeas//error output"))
388
- else
389
- debug("Loading failed for one or more files, output from /augeas//error:")
390
- end
391
- end
392
- print_errors(errors)
393
- end
394
-
395
- def print_put_errors
396
- errors = @aug.match("/augeas//error[. = 'put_failed']")
397
- debug("Put failed on one or more files, output from /augeas//error:") unless errors.empty?
398
- print_errors(errors)
399
- end
400
-
401
- def print_errors(errors)
402
- errors.each do |errnode|
403
- error = @aug.get(errnode)
404
- debug("#{errnode} = #{error}") unless error.nil?
405
- @aug.match("#{errnode}/*").each do |subnode|
406
- subvalue = @aug.get(subnode)
407
- debug("#{subnode} = #{subvalue}")
408
- end
409
- end
410
- end
411
-
412
- # Determines if augeas actually needs to run.
413
- def need_to_run?
414
- force = resource[:force]
415
- return_value = true
416
- begin
417
- open_augeas
418
- filter = resource[:onlyif]
419
- unless filter == ""
420
- cmd_array = parse_commands(filter)[0]
421
- command = cmd_array[0];
422
- begin
423
- case command
424
- when "get"; return_value = process_get(cmd_array)
425
- when "values"; return_value = process_values(cmd_array)
426
- when "match"; return_value = process_match(cmd_array)
427
- end
428
- rescue StandardError => e
429
- fail(_("Error sending command '%{command}' with params %{param}/%{message}") % { command: command, param: cmd_array[1..-1].inspect, message: e.message })
430
- end
431
- end
432
-
433
- unless force
434
- # If we have a version of augeas which is at least 0.3.6 then we
435
- # can make the changes now and see if changes were made.
436
- if return_value and versioncmp(get_augeas_version, "0.3.6") >= 0
437
- debug("Will attempt to save and only run if files changed")
438
- # Execute in NEWFILE mode so we can show a diff
439
- set_augeas_save_mode(SAVE_NEWFILE)
440
- do_execute_changes
441
- save_result = @aug.save
442
- unless save_result
443
- print_put_errors
444
- fail(_("Saving failed, see debug"))
445
- end
446
-
447
- saved_files = @aug.match("/augeas/events/saved")
448
- if saved_files.size > 0
449
- root = resource[:root].sub(/^\/$/, "")
450
- saved_files.map! {|key| @aug.get(key).sub(/^\/files/, root) }
451
- saved_files.uniq.each do |saved_file|
452
- if Puppet[:show_diff] && @resource[:show_diff]
453
- self.send(@resource[:loglevel], "\n" + diff(saved_file, saved_file + ".augnew"))
454
- end
455
- File.delete(saved_file + ".augnew")
456
- end
457
- debug("Files changed, should execute")
458
- return_value = true
459
- else
460
- debug("Skipping because no files were changed")
461
- return_value = false
462
- end
463
- end
464
- end
465
- ensure
466
- if not return_value or resource.noop? or not save_result
467
- close_augeas
468
- end
469
- end
470
- return_value
471
- end
472
-
473
- def execute_changes
474
- # Workaround Augeas bug where changing the save mode doesn't trigger a
475
- # reload of the previously saved file(s) when we call Augeas#load
476
- @aug.match("/augeas/events/saved").each do |file|
477
- @aug.rm("/augeas#{@aug.get(file)}/mtime")
478
- end
479
-
480
- # Reload augeas, and execute the changes for real
481
- set_augeas_save_mode(SAVE_OVERWRITE) if versioncmp(get_augeas_version, "0.3.6") >= 0
482
- @aug.load
483
- do_execute_changes
484
- unless @aug.save
485
- print_put_errors
486
- fail(_("Save failed, see debug"))
487
- end
488
-
489
- :executed
490
- ensure
491
- close_augeas
492
- end
493
-
494
- # Actually execute the augeas changes.
495
- def do_execute_changes
496
- commands = parse_commands(resource[:changes])
497
- commands.each do |cmd_array|
498
- fail(_("invalid command %{cmd}") % { value0: cmd_array.join[" "] }) if cmd_array.length < 2
499
- command = cmd_array[0]
500
- cmd_array.shift
501
- begin
502
- case command
503
- when "set"
504
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
505
- rv = aug.set(cmd_array[0], cmd_array[1])
506
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (!rv)
507
- when "setm"
508
- if aug.respond_to?(command)
509
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
510
- rv = aug.setm(cmd_array[0], cmd_array[1], cmd_array[2])
511
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (rv == -1)
512
- else
513
- fail(_("command '%{command}' not supported in installed version of ruby-augeas") % { command: command })
514
- end
515
- when "rm", "remove"
516
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
517
- rv = aug.rm(cmd_array[0])
518
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (rv == -1)
519
- when "clear"
520
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
521
- rv = aug.clear(cmd_array[0])
522
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (!rv)
523
- when "clearm"
524
- # Check command exists ... doesn't currently in ruby-augeas 0.4.1
525
- if aug.respond_to?(command)
526
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
527
- rv = aug.clearm(cmd_array[0], cmd_array[1])
528
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (!rv)
529
- else
530
- fail(_("command '%{command}' not supported in installed version of ruby-augeas") % { command: command })
531
- end
532
- when "touch"
533
- debug("sending command '#{command}' (match, set) with params #{cmd_array.inspect}")
534
- if aug.match(cmd_array[0]).empty?
535
- rv = aug.clear(cmd_array[0])
536
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (!rv)
537
- end
538
- when "insert", "ins"
539
- label = cmd_array[0]
540
- where = cmd_array[1]
541
- path = cmd_array[2]
542
- case where
543
- when "before"; before = true
544
- when "after"; before = false
545
- else fail(_("Invalid value '%{where}' for where param") % { where: where })
546
- end
547
- debug("sending command '#{command}' with params #{[label, where, path].inspect}")
548
- rv = aug.insert(path, label, before)
549
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (rv == -1)
550
- when "defvar"
551
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
552
- rv = aug.defvar(cmd_array[0], cmd_array[1])
553
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (!rv)
554
- when "defnode"
555
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
556
- rv = aug.defnode(cmd_array[0], cmd_array[1], cmd_array[2])
557
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (!rv)
558
- when "mv", "move"
559
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
560
- rv = aug.mv(cmd_array[0], cmd_array[1])
561
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (rv == -1)
562
- when "rename"
563
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
564
- rv = aug.rename(cmd_array[0], cmd_array[1])
565
- fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if (rv == -1)
566
- else fail(_("Command '%{command}' is not supported") % { command: command })
567
- end
568
- rescue StandardError => e
569
- fail(_("Error sending command '%{command}' with params %{params}/%{message}") % { command: command, params: cmd_array.inspect, message: e.message })
570
- end
571
- end
572
- end
573
- end
@@ -1,9 +0,0 @@
1
- require 'puppet/util/network_device/cisco/device'
2
- require 'puppet/provider/network_device'
3
-
4
- # This is the base class of all prefetched cisco device providers
5
- class Puppet::Provider::Cisco < Puppet::Provider::NetworkDevice
6
- def self.device(url)
7
- Puppet::Util::NetworkDevice::Cisco::Device.new(url)
8
- end
9
- end
@@ -1,20 +0,0 @@
1
- require 'puppet/provider/nameservice/directoryservice'
2
-
3
- Puppet::Type.type(:computer).provide :directoryservice, :parent => Puppet::Provider::NameService::DirectoryService do
4
- desc "Computer object management using DirectoryService on OS X.
5
- Note that these are distinctly different kinds of objects to 'hosts',
6
- as they require a MAC address and can have all sorts of policy attached to
7
- them.
8
-
9
- This provider only manages Computer objects in the local directory service
10
- domain, not in remote directories.
11
-
12
- If you wish to manage /etc/hosts on Mac OS X, then simply use the host
13
- type as per other platforms."
14
-
15
- confine :operatingsystem => :darwin
16
- defaultfor :operatingsystem => :darwin
17
-
18
- # hurray for abstraction. The nameservice directoryservice provider can
19
- # handle everything we need. super.
20
- end
@@ -1,46 +0,0 @@
1
- require 'puppet/provider/parsedfile'
2
-
3
- hosts = nil
4
- case Facter.value(:osfamily)
5
- when "Solaris"; hosts = "/etc/inet/hosts"
6
- when "windows"
7
- require 'win32/resolv'
8
- hosts = Win32::Resolv.get_hosts_path
9
- else
10
- hosts = "/etc/hosts"
11
- end
12
-
13
-
14
- Puppet::Type.type(:host).provide(:parsed,:parent => Puppet::Provider::ParsedFile,
15
- :default_target => hosts,:filetype => :flat) do
16
- confine :exists => hosts
17
-
18
- text_line :comment, :match => /^#/
19
- text_line :blank, :match => /^\s*$/
20
- hosts_pattern = '^([0-9a-f:]\S+)\s+([^#\s+]\S+)\s*(.*?)?(?:\s*#\s*(.*))?$'
21
- record_line :parsed, :fields => %w{ip name host_aliases comment},
22
- :optional => %w{host_aliases comment},
23
- :match => /#{hosts_pattern}/,
24
- :post_parse => proc { |hash|
25
- # An absent comment should match "comment => ''"
26
- hash[:comment] = '' if hash[:comment].nil? or hash[:comment] == :absent
27
- unless hash[:host_aliases].nil? or hash[:host_aliases] == :absent
28
- hash[:host_aliases].gsub!(/\s+/,' ') # Change delimiter
29
- end
30
- },
31
- :to_line => proc { |hash|
32
- [:ip, :name].each do |n|
33
- raise ArgumentError, _("%{attr} is a required attribute for hosts") % { attr: n } unless hash[n] and hash[n] != :absent
34
- end
35
- str = "#{hash[:ip]}\t#{hash[:name]}"
36
- if hash.include? :host_aliases and !hash[:host_aliases].nil? and hash[:host_aliases] != :absent
37
- str += "\t#{hash[:host_aliases]}"
38
- end
39
- if hash.include? :comment and !hash[:comment].empty?
40
- str += "\t# #{hash[:comment]}"
41
- end
42
- str
43
- }
44
-
45
- text_line :incomplete, :match => /(?! (#{hosts_pattern}))/
46
- end
@@ -1,27 +0,0 @@
1
- require 'puppet/provider/cisco'
2
-
3
- Puppet::Type.type(:interface).provide :cisco, :parent => Puppet::Provider::Cisco do
4
-
5
- desc "Cisco switch/router provider for interface."
6
-
7
- mk_resource_methods
8
-
9
- def self.lookup(device, name)
10
- interface = nil
11
- device.command do |dev|
12
- interface = dev.interface(name)
13
- end
14
- interface
15
- end
16
-
17
- def initialize(device, *args)
18
- super
19
- end
20
-
21
- def flush
22
- device.command do |dev|
23
- dev.new_interface(name).update(former_properties, properties)
24
- end
25
- super
26
- end
27
- end