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
@@ -0,0 +1,128 @@
1
+ require 'puppet/parser/script_compiler'
2
+
3
+ module Puppet::Pops
4
+ module Evaluator
5
+
6
+ # Utility class to help resolve instances of Puppet::Pops::Types::PDeferredType::Deferred
7
+ #
8
+ class DeferredResolver
9
+ DOLLAR = '$'.freeze
10
+ DIG = 'dig'.freeze
11
+
12
+ # Resolves and replaces all Deferred values in a catalog's resource attributes
13
+ # found as direct values or nested inside Array, Hash or Sensitive values.
14
+ # Deferred values inside of custom Object instances are not resolved as this
15
+ # is expected to be done by such objects.
16
+ #
17
+ # @param node [Puppet::Node] the node for the catalog
18
+ # @param facts [Puppet::Node::Facts] the facts object for the node
19
+ # @param catalog [Puppet::Resource::Catalog] the catalog where all deferred values should be replaced
20
+ # @return [nil] does not return anything - the catalog is modified as a side effect
21
+ #
22
+ def self.resolve_and_replace(node, facts, catalog)
23
+ compiler = Puppet::Parser::ScriptCompiler.new(node.environment, node.name)
24
+ resolver = new(compiler)
25
+ resolver.set_facts_variable(facts)
26
+ # TODO:
27
+ # # When scripting the trusted data are always local, but set them anyway
28
+ # @scope.set_trusted(node.trusted_data)
29
+ #
30
+ # # Server facts are always about the local node's version etc.
31
+ # @scope.set_server_facts(node.server_facts)
32
+
33
+ resolver.resolve_futures(catalog)
34
+ nil
35
+ end
36
+
37
+ # Resolves a value such that a direct Deferred, or any nested Deferred values
38
+ # are resolved and used instead of the deferred value.
39
+ # A direct Deferred value, or nested deferred values inside of Array, Hash or
40
+ # Sensitive values are resolved and replaced inside of freshly created
41
+ # containers.
42
+ #
43
+ # The resolution takes place in the topscope of the given compiler.
44
+ # Variable values are supposed to already have been set.
45
+ #
46
+ # @param value [Object] the (possibly nested) value to resolve
47
+ # @param compiler [Puppet::Parser::ScriptCompiler, Puppet::Parser::Compiler] the compiler in effect
48
+ # @return [Object] the resolved value (a new Array, Hash, or Sensitive if needed), with all deferred values resolved
49
+ #
50
+ def self.resolve(value, compiler)
51
+ resolver = new(compiler)
52
+ resolver.resolve(value)
53
+ end
54
+
55
+ def initialize(compiler)
56
+ @compiler = compiler
57
+ # Always resolve in top scope
58
+ @scope = @compiler.topscope
59
+ @deferred_class = Puppet::Pops::Types::TypeFactory.deferred.implementation_class
60
+ end
61
+
62
+ # @param facts [Puppet::Node::Facts] the facts to set in $facts in the compiler's topscope
63
+ #
64
+ def set_facts_variable(facts)
65
+ @scope.set_facts(facts.nil? ? {} : facts.values)
66
+ end
67
+
68
+ def resolve_futures(catalog)
69
+ catalog.resources.each do |r|
70
+ overrides = {}
71
+ r.parameters.each_pair do |k, v|
72
+ resolved = resolve(v)
73
+ # If the value is instance of Sensitive - assign the unwrapped value
74
+ # and mark it as sensitive if not already marked
75
+ #
76
+ if resolved.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)
77
+ resolved = resolved.unwrap
78
+ unless r.sensitive_parameters.include?(k.to_sym)
79
+ r.sensitive_parameters = (r.sensitive_parameters + [k.to_sym]).freeze
80
+ end
81
+ end
82
+ overrides[ k ] = resolved
83
+ end
84
+ r.parameters.merge!(overrides) unless overrides.empty?
85
+ end
86
+ end
87
+
88
+ def resolve(x)
89
+ if x.class == @deferred_class
90
+ resolve_future(x)
91
+ elsif x.is_a?(Array)
92
+ x.map {|v| resolve(v) }
93
+ elsif x.is_a?(Hash)
94
+ result = {}
95
+ x.each_pair {|k,v| result[k] = resolve(v) }
96
+ result
97
+ elsif x.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)
98
+ # rewrap in a new Sensitive after resolving any nested deferred values
99
+ Puppet::Pops::Types::PSensitiveType::Sensitive.new(resolve(x.unwrap))
100
+ else
101
+ x
102
+ end
103
+ end
104
+
105
+ def resolve_future(f)
106
+ # If any of the arguments to a future is a future it needs to be resolved first
107
+ func_name = f.name
108
+ mapped_arguments = map_arguments(f.arguments)
109
+ # if name starts with $ then this is a call to dig
110
+ if func_name[0] == DOLLAR
111
+ var_name = func_name[1..-1]
112
+ func_name = DIG
113
+ mapped_arguments.insert(0, @scope[var_name])
114
+ end
115
+
116
+ # call the function (name in deferred, or 'dig' for a variable)
117
+ @scope.call_function(func_name, mapped_arguments)
118
+ end
119
+
120
+ def map_arguments(args)
121
+ return [] if args.nil?
122
+ args.map {|v| resolve(v) }
123
+ end
124
+ private :map_arguments
125
+
126
+ end
127
+ end
128
+ end
@@ -404,7 +404,7 @@ class EvaluatorImpl
404
404
  end
405
405
 
406
406
  left_o = bin_expr.left_expr
407
- if left.is_a?(URI) && operator == '+'
407
+ if (left.is_a?(URI) || left.is_a?(Types::PBinaryType::Binary)) && operator == '+'
408
408
  concatenate(left, right)
409
409
  elsif (left.is_a?(Array) || left.is_a?(Hash)) && COLLECTION_OPERATORS.include?(operator)
410
410
  # Handle operation on collections
@@ -1221,6 +1221,9 @@ class EvaluatorImpl
1221
1221
  when URI
1222
1222
  raise ArgumentError.new(_('An URI can only be merged with an URI or String')) unless y.is_a?(String) || y.is_a?(URI)
1223
1223
  x + y
1224
+ when Types::PBinaryType::Binary
1225
+ raise ArgumentError.new(_('Can only append Binary to a Binary')) unless y.is_a?(Types::PBinaryType::Binary)
1226
+ Types::PBinaryType::Binary.from_binary_string(x.binary_buffer + y.binary_buffer)
1224
1227
  else
1225
1228
  concatenate([x], y)
1226
1229
  end
@@ -79,6 +79,8 @@ class Dispatch < Evaluator::CallableSignature
79
79
  scope
80
80
  when :pal_script_compiler
81
81
  Puppet.lookup(:pal_script_compiler)
82
+ when :cache
83
+ Puppet::Pops::Adapters::ObjectIdCacheAdapter.adapt(scope.compiler)
82
84
  else
83
85
  raise ArgumentError, _("Unknown injection %{injection_name}") % { injection_name: injection_name }
84
86
  end
@@ -286,7 +286,7 @@ module Issues
286
286
  end
287
287
 
288
288
  ILLEGAL_NAME = hard_issue :ILLEGAL_NAME, :name do
289
- _("Illegal name. The given name '%{name}' does not conform to the naming rule /^((::)?[a-z_]\w*)(::[a-z]\\w*)*$/") % { name: name }
289
+ _("Illegal name. The given name '%{name}' does not conform to the naming rule /^((::)?[a-z_]\\w*)(::[a-z]\\w*)*$/") % { name: name }
290
290
  end
291
291
 
292
292
  ILLEGAL_SINGLE_TYPE_MAPPING = hard_issue :ILLEGAL_TYPE_MAPPING, :expression do
@@ -886,10 +886,18 @@ module Issues
886
886
  _("The catalog operation '%{operation}' is only available when compiling a catalog") % { operation: operation }
887
887
  end
888
888
 
889
+ EXPRESSION_NOT_SUPPORTED_WHEN_SCRIPTING = issue :EXPRESSION_NOT_SUPPORTED_WHEN_SCRIPTING, :klass do
890
+ _("%{expr} is only available when compiling a catalog") % { expr: label.a_an_uc(klass) }
891
+ end
892
+
889
893
  TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING = issue :TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, :operation do
890
894
  _("The task operation '%{operation}' is not available when compiling a catalog") % { operation: operation }
891
895
  end
892
896
 
897
+ EXPRESSION_NOT_SUPPORTED_WHEN_COMPILING = issue :EXPRESSION_NOT_SUPPORTED_WHEN_COMPILING, :klass do
898
+ _("%{expr} is not available when compiling a catalog") % { expr: label.a_an_uc(klass) }
899
+ end
900
+
893
901
  TASK_MISSING_BOLT = issue :TASK_MISSING_BOLT, :action do
894
902
  _("The 'bolt' library is required to %{action}") % { action: action }
895
903
  end
@@ -6,38 +6,22 @@ module Loader
6
6
  class StaticLoader < Loader
7
7
 
8
8
  BUILTIN_TYPE_NAMES = %w{
9
- Augeas
10
9
  Component
11
- Computer
12
10
  Cron
13
11
  Exec
14
12
  File
15
13
  Filebucket
16
14
  Group
17
- Host
18
- Interface
19
- K5login
20
- Macauthorization
21
- Mcx
22
- Mount
23
15
  Node
24
16
  Notify
25
17
  Package
26
18
  Resources
27
- Router
28
19
  Schedule
29
- Scheduled_task
30
- Selboolean
31
- Selmodule
32
20
  Service
33
- Ssh_authorized_key
34
- Sshkey
35
21
  Stage
36
22
  Tidy
37
23
  User
38
- Vlan
39
24
  Whit
40
- Yumrepo
41
25
  }.freeze
42
26
 
43
27
  BUILTIN_TYPE_NAMES_LC = Set.new(BUILTIN_TYPE_NAMES.map { |n| n.downcase }).freeze
@@ -63,15 +63,13 @@ class Loaders
63
63
  # be pre-loaded with a fully configured loader system
64
64
  def pre_load
65
65
  @puppet_system_loader.load(:type, 'error')
66
-
67
- # Will move to Bolt
68
- @puppet_system_loader.load(:type, 'executionresult')
69
66
  end
70
67
 
71
68
  # Clears the cached static and puppet_system loaders (to enable testing)
72
69
  #
73
70
  def self.clear
74
71
  @@static_loader = nil
72
+ Puppet::Pops::Types::TypeFactory.clear
75
73
  Model.class_variable_set(:@@pcore_ast_initialized, false)
76
74
  Model.register_pcore_types
77
75
  end
@@ -38,8 +38,8 @@ clist = [
38
38
  '116,74,72,154,118,154,121,471,403,470,117,131,271,414,118,128,121,429',
39
39
  '21,20,117,-280,154,404,413,54,157,57,157,69,12,120,63,46,49,475,56,47',
40
40
  '10,11,116,120,66,19,476,157,48,130,304,17,18,127,330,97,118,331,121',
41
- '84,131,129,117,459,128,55,-280,131,458,45,80,128,82,83,471,399,470,64',
42
- '51,70,71,58,-235,120,62,60,61,67,79,72,116,65,73,434,74,400,130,526',
41
+ '84,131,129,117,526,128,55,-280,131,458,45,80,128,82,83,471,399,470,64',
42
+ '51,70,71,58,-235,120,62,60,61,67,79,72,116,65,73,434,74,400,130,459',
43
43
  '98,99,127,436,458,130,118,97,121,127,129,131,117,21,20,128,399,129,124',
44
44
  '307,54,396,57,394,69,136,116,63,46,49,390,56,47,120,443,181,79,66,19',
45
45
  '182,118,48,121,444,17,18,117,130,98,99,131,127,84,131,128,97,388,128',
@@ -363,9 +363,9 @@ clist = [
363
363
  '246,146,246,468,308,468,246,230,118,314,137,230,137,329,336,336,137',
364
364
  '230,51,308,313,336,221,336,146,336,336,246,336,336,336,410,336,336,336',
365
365
  '336,249,137,336,336,410,51,336,230,305,336,336,230,192,246,249,192,249',
366
- '336,147,230,249,392,147,336,230,149,392,336,336,149,336,336,406,341',
366
+ '336,147,230,249,504,147,336,230,149,504,336,336,149,336,336,406,341',
367
367
  '406,336,336,336,336,336,346,249,336,336,336,18,18,336,251,18,18,347',
368
- '18,304,147,504,249,249,147,349,504,149,251,249,251,149,147,12,251,18',
368
+ '18,304,147,392,249,249,147,349,392,149,251,249,251,149,147,12,251,18',
369
369
  '18,12,298,149,12,295,18,294,18,293,18,18,244,18,18,18,288,18,18,251',
370
370
  '355,200,200,18,18,200,244,18,244,357,18,18,244,12,251,251,168,12,18',
371
371
  '58,168,251,284,58,18,12,60,359,18,18,60,18,18,244,197,197,18,18,18,18',
@@ -750,7 +750,7 @@ racc_action_pointer = [
750
750
  nil, 269, nil, nil, nil, nil, nil, nil, nil, nil,
751
751
  nil, nil, nil, nil, nil, nil, nil, nil, 290, 7642,
752
752
  10571, 305, nil, 332, nil, 310, nil, 314, 10397, nil,
753
- 273, nil, 150, 366, 369, nil, 7460, 380, 319, 381,
753
+ 273, nil, 184, 366, 369, nil, 7460, 380, 319, 381,
754
754
  7005, nil, nil, 6914, nil, 395, 135, 404, 396, 9114,
755
755
  119, 6550, nil, 6459, 6368, 10455, 6186, 441, nil, 461,
756
756
  nil, 9037, nil, nil, 464, nil, 5640, nil, nil, nil,
@@ -761,7 +761,7 @@ racc_action_pointer = [
761
761
  2091, 517, 496, nil, 524, 1909, 540, nil, nil, 542,
762
762
  nil, nil, 544, 542, 546, 548, 1818, nil, 1363, 547,
763
763
  nil, nil, 551, 519, nil, nil, nil, nil, 553, nil,
764
- nil, 554, 555, nil, 184, nil, nil, 1181, nil, 726,
764
+ nil, 554, 555, nil, 150, nil, nil, 1181, nil, 726,
765
765
  10248, 1272, nil, nil, 563, nil, 1090, 565, nil, 566,
766
766
  570, nil, 5913, nil, nil, nil, nil, 573, nil, 582,
767
767
  nil, 583, nil, nil, nil, 586, nil, nil, nil, nil,
@@ -95,6 +95,17 @@ module Pcore
95
95
  Resource.register_ptypes(loader, ir)
96
96
  Lookup::Context.register_ptype(loader, ir);
97
97
  Lookup::DataProvider.register_types(loader)
98
+
99
+ add_object_type('Deferred', <<-PUPPET, loader)
100
+ {
101
+ attributes => {
102
+ # Fully qualified name of the function
103
+ name => { type => Pattern[/\\A[$]?[a-z][a-z0-9_]*(?:::[a-z][a-z0-9_]*)*\\z/] },
104
+ arguments => { type => Optional[Array[Any]], value => undef},
105
+ }
106
+ }
107
+ PUPPET
108
+
98
109
  end
99
110
 
100
111
  # Create and register a new `Object` type in the Puppet Type System and map it to an implementation class
@@ -6,6 +6,19 @@ module Types
6
6
  module TypeFactory
7
7
  @type_calculator = TypeCalculator.singleton
8
8
 
9
+ # Clears caches - used when testing
10
+ def self.clear
11
+ # these types are cached and needs to be nulled as the representation may change if loaders are cleared
12
+ @data_t = nil
13
+ @rich_data_t = nil
14
+ @rich_data_key_t = nil
15
+ @array_of_data_t = nil
16
+ @hash_of_data_t = nil
17
+ @error_t = nil
18
+ @task_t = nil
19
+ @deferred_t = nil
20
+ end
21
+
9
22
  # Produces the Integer type
10
23
  # @api public
11
24
  #
@@ -526,6 +539,10 @@ module TypeFactory
526
539
  @task_t ||= TypeParser.singleton.parse('Task')
527
540
  end
528
541
 
542
+ def self.deferred
543
+ @deferred_t ||= TypeParser.singleton.parse('Deferred')
544
+ end
545
+
529
546
  # Produces a type for URI[String or Hash]
530
547
  # @api public
531
548
  #
@@ -24,8 +24,12 @@ class TasksChecker < Checker4_0
24
24
  def check_CollectExpression(o)
25
25
  # Only virtual resource queries are allowed in apply blocks, not exported
26
26
  # resource queries
27
- if in_ApplyExpression? && o.query.is_a?(Puppet::Pops::Model::VirtualQuery)
28
- super(o)
27
+ if in_ApplyExpression?
28
+ if o.query.is_a?(Puppet::Pops::Model::VirtualQuery)
29
+ super(o)
30
+ else
31
+ acceptor.accept(Issues::EXPRESSION_NOT_SUPPORTED_WHEN_COMPILING, o, {:klass => o})
32
+ end
29
33
  else
30
34
  illegalTasksExpression(o)
31
35
  end
@@ -64,7 +68,11 @@ class TasksChecker < Checker4_0
64
68
  end
65
69
 
66
70
  def check_ResourceOverrideExpression(o)
67
- illegalTasksExpression(o)
71
+ if in_ApplyExpression?
72
+ super(o)
73
+ else
74
+ illegalTasksExpression(o)
75
+ end
68
76
  end
69
77
 
70
78
  def check_ResourceTypeDefinition(o)
@@ -77,12 +85,12 @@ class TasksChecker < Checker4_0
77
85
 
78
86
  def check_ApplyExpression(o)
79
87
  if in_ApplyExpression?
80
- acceptor.accept(Issues::TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, o, {:operation => o.class.to_s})
88
+ acceptor.accept(Issues::EXPRESSION_NOT_SUPPORTED_WHEN_COMPILING, o, {:klass => o})
81
89
  end
82
90
  end
83
91
 
84
92
  def illegalTasksExpression(o)
85
- acceptor.accept(Issues::CATALOG_OPERATION_NOT_SUPPORTED_WHEN_SCRIPTING, o, {:operation => o.class.to_s})
93
+ acceptor.accept(Issues::EXPRESSION_NOT_SUPPORTED_WHEN_SCRIPTING, o, {:klass => o})
86
94
  end
87
95
 
88
96
  def resource_without_title?(o)
@@ -70,6 +70,7 @@ module Puppet
70
70
  require 'puppet/pops/evaluator/epp_evaluator'
71
71
  require 'puppet/pops/evaluator/collector_transformer'
72
72
  require 'puppet/pops/evaluator/puppet_proc'
73
+ require 'puppet/pops/evaluator/deferred_resolver'
73
74
  module Collectors
74
75
  require 'puppet/pops/evaluator/collectors/abstract_collector'
75
76
  require 'puppet/pops/evaluator/collectors/fixed_set_collector'
@@ -19,6 +19,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
19
19
 
20
20
  defaultfor :operatingsystem => :cumuluslinux, :operatingsystemmajrelease => ['1','2']
21
21
  defaultfor :operatingsystem => :debian, :operatingsystemmajrelease => ['5','6','7']
22
+ defaultfor :operatingsystem => :devuan
22
23
 
23
24
  # Remove the symlinks
24
25
  def disable
@@ -108,8 +108,6 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
108
108
  end
109
109
 
110
110
  def stop
111
- # Don't try to stop non-existing services (PUP-8167)
112
- return if self.status == :absent
113
111
  # Wait for the service to actually stop before returning.
114
112
  super
115
113
  self.wait('offline', 'disabled', 'uninitialized')
@@ -138,8 +136,9 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
138
136
  states = service_states
139
137
  state = states[1] == "-" ? states[0] : states[1]
140
138
  rescue Puppet::ExecutionFailure
139
+ # TODO (PUP-8957): Should this be set back to INFO ?
141
140
  debug "Could not get status on service #{self.name} #{$!}"
142
- return :absent
141
+ return :stopped
143
142
  end
144
143
 
145
144
  case state
@@ -16,8 +16,6 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
16
16
  Facter.value(:operatingsystem) == 'LinuxMint',
17
17
  ]
18
18
 
19
- confine :exists => "/var/run/upstart-socket-bridge.pid"
20
-
21
19
  defaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => ["10.04", "12.04", "14.04", "14.10"]
22
20
 
23
21
  commands :start => "/sbin/start",
@@ -26,6 +24,16 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
26
24
  :status_exec => "/sbin/status",
27
25
  :initctl => "/sbin/initctl"
28
26
 
27
+ # We only want to use upstart as our provider if the upstart daemon is running.
28
+ # This can be checked by running `initctl version --quiet` on a machine that has
29
+ # upstart installed.
30
+ confine :true => begin
31
+ initctl('version', '--quiet')
32
+ true
33
+ rescue
34
+ false
35
+ end
36
+
29
37
  # upstart developer haven't implemented initctl enable/disable yet:
30
38
  # http://www.linuxplanet.com/linuxplanet/tutorials/7033/2/
31
39
  has_feature :enableable
@@ -193,26 +193,6 @@ class Puppet::SSL::CertificateAuthority
193
193
  Puppet::SSL::Certificate.indirection.search(name).collect { |c| c.name }
194
194
  end
195
195
 
196
- # Return all the certificate objects as found by the indirector
197
- # API for PE license checking.
198
- #
199
- # Created to prevent the case of reading all certs from disk, getting
200
- # just their names and verifying the cert for each name, which then
201
- # causes the cert to again be read from disk.
202
- #
203
- # @author Jeff Weiss <jeff.weiss@puppetlabs.com>
204
- # @api Puppet Enterprise Licensing
205
- #
206
- # @param name [Array<string>] filter to cerificate names
207
- #
208
- # @return [Array<Puppet::SSL::Certificate>]
209
- #
210
- # @deprecated Use Puppet::SSL::CertificateAuthority#list or Puppet Server Certificate status API
211
- def list_certificates(name='*')
212
- Puppet.deprecation_warning(_("Puppet::SSL::CertificateAuthority#list_certificates is deprecated. Please use Puppet::SSL::CertificateAuthority#list or the certificate status API to query certificate information. See https://puppet.com/docs/puppet/latest/http_api/http_certificate_status.html"))
213
- Puppet::SSL::Certificate.indirection.search(name)
214
- end
215
-
216
196
  # Read the next serial from the serial file, and increment the
217
197
  # file so this one is considered used.
218
198
  def next_serial
@@ -406,46 +386,15 @@ class Puppet::SSL::CertificateAuthority
406
386
  return true # good enough for us!
407
387
  end
408
388
 
409
- # Utility method for optionally caching the X509 Store for verifying a
410
- # large number of certificates in a short amount of time--exactly the
411
- # case we have during PE license checking.
412
- #
413
- # @example Use the cached X509 store
414
- # x509store(:cache => true)
415
- #
416
- # @example Use a freshly create X509 store
417
- # x509store
418
- # x509store(:cache => false)
419
- #
420
- # @param [Hash] options the options used for retrieving the X509 Store
421
- # @option options [Boolean] :cache whether or not to use a cached version
422
- # of the X509 Store
423
- #
424
- # @return [OpenSSL::X509::Store]
425
- #
426
- # @deprecated Strictly speaking, #x509_store is marked API private, so we
427
- # don't need to publicly deprecate it. But it marked as deprecated here to
428
- # avoid the exceedingly small chance that someone comes in and uses it from
429
- # within this class before it is removed.
430
- def x509_store(options = {})
431
- if (options[:cache])
432
- return @x509store unless @x509store.nil?
433
- @x509store = create_x509_store
434
- else
435
- create_x509_store
436
- end
437
- end
438
- private :x509_store
439
-
440
389
  # Creates a brand new OpenSSL::X509::Store with the appropriate
441
390
  # Certificate Revocation List and flags
442
391
  #
443
392
  # @return [OpenSSL::X509::Store]
444
- def create_x509_store
445
- store = OpenSSL::X509::Store.new()
393
+ def create_x509_store(purpose)
394
+ store = OpenSSL::X509::Store.new
446
395
  store.add_file(Puppet[:cacert])
447
396
  store.add_crl(crl.content) if self.crl
448
- store.purpose = OpenSSL::X509::PURPOSE_SSL_CLIENT
397
+ store.purpose = purpose
449
398
  if Puppet.settings[:certificate_revocation]
450
399
  store.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL | OpenSSL::X509::V_FLAG_CRL_CHECK
451
400
  end
@@ -453,50 +402,23 @@ class Puppet::SSL::CertificateAuthority
453
402
  end
454
403
  private :create_x509_store
455
404
 
456
- # Utility method which is API for PE license checking.
457
- # This is used rather than `verify` because
458
- # 1) We have already read the certificate from disk into memory.
459
- # To read the certificate from disk again is just wasteful.
460
- # 2) Because we're checking a large number of certificates against
461
- # a transient CertificateAuthority, we can relatively safely cache
462
- # the X509 Store that actually does the verification.
463
- #
464
- # Long running instances of CertificateAuthority will certainly
465
- # want to use `verify` because it will recreate the X509 Store with
466
- # the absolutely latest CRL.
467
- #
468
- # Additionally, this method explicitly returns a boolean whereas
469
- # `verify` will raise an error if the certificate has been revoked.
470
- #
471
- # @author Jeff Weiss <jeff.weiss@puppetlabs.com>
472
- # @api Puppet Enterprise Licensing
473
- #
474
- # @param cert [Puppet::SSL::Certificate] the certificate to check validity of
475
- #
476
- # @return [Boolean] true if signed, false if unsigned or revoked
477
- #
478
- # @deprecated use Puppet::SSL::CertificateAuthority#verify or Puppet Server certificate status API
479
- def certificate_is_alive?(cert)
480
- Puppet.deprecation_warning(_("Puppet::SSL::CertificateAuthority#certificate_is_alive? is deprecated. Please use Puppet::SSL::CertificateAuthority#verify or the certificate status API to query certificate information. See https://puppet.com/docs/puppet/latest/http_api/http_certificate_status.html"))
481
- x509_store(:cache => true).verify(cert.content)
482
- end
483
-
484
405
  # Verify a given host's certificate. The certname is passed in, and
485
406
  # the indirector will be used to locate the actual contents of the
486
407
  # certificate with that name.
487
408
  #
488
409
  # @param name [String] certificate name to verify
410
+ # @param purpose [Integer] bitwise combination of X509::PURPOSE_*
489
411
  #
490
412
  # @raise [ArgumentError] if the certificate name cannot be found
491
413
  # (i.e. doesn't exist or is unsigned)
492
414
  # @raise [CertificateVerficationError] if the certificate has been revoked
493
415
  #
494
416
  # @return [Boolean] true if signed, there are no cases where false is returned
495
- def verify(name)
417
+ def verify(name, purpose = OpenSSL::X509::PURPOSE_ANY)
496
418
  unless cert = Puppet::SSL::Certificate.indirection.find(name)
497
419
  raise ArgumentError, _("Could not find a certificate for %{name}") % { name: name }
498
420
  end
499
- store = create_x509_store
421
+ store = create_x509_store(purpose)
500
422
 
501
423
  raise CertificateVerificationError.new(store.error), store.error_string unless store.verify(cert.content)
502
424
  end
@@ -266,9 +266,17 @@ DOC
266
266
  end
267
267
 
268
268
  if options[:dns_alt_names]
269
- names = options[:dns_alt_names].split(/\s*,\s*/).map(&:strip) + [name]
270
- names = names.sort.uniq.map {|name| "DNS:#{name}" }.join(", ")
271
- alt_names_ext = extension_factory.create_extension("subjectAltName", names, false)
269
+ raw_names = options[:dns_alt_names].split(/\s*,\s*/).map(&:strip) + [name]
270
+
271
+ parsed_names = raw_names.map do |name|
272
+ if !name.start_with?("IP:") && !name.start_with?("DNS:")
273
+ "DNS:#{name}"
274
+ else
275
+ name
276
+ end
277
+ end.sort.uniq.join(", ")
278
+
279
+ alt_names_ext = extension_factory.create_extension("subjectAltName", parsed_names, false)
272
280
 
273
281
  extensions << alt_names_ext
274
282
  end
@@ -835,6 +835,9 @@ Puppet::Type.newtype(:file) do
835
835
  rescue Errno::EACCES
836
836
  warning _("Could not stat; permission denied")
837
837
  nil
838
+ rescue Errno::EINVAL
839
+ warning _("Could not stat; invalid pathname")
840
+ nil
838
841
  end
839
842
  end
840
843
 
@@ -675,13 +675,23 @@ module Puppet
675
675
  end
676
676
 
677
677
  def generate
678
- return [] if self[:purge_ssh_keys].empty?
679
- find_unmanaged_keys
678
+ if !self[:purge_ssh_keys].empty?
679
+ if Puppet::Type.type(:ssh_authorized_key).nil?
680
+ warning _("Ssh_authorized_key type is not available. Cannot purge SSH keys.")
681
+ else
682
+ return find_unmanaged_keys
683
+ end
684
+ end
685
+
686
+ []
680
687
  end
681
688
 
682
689
  newparam(:purge_ssh_keys) do
683
690
  desc "Whether to purge authorized SSH keys for this user if they are not managed
684
- with the `ssh_authorized_key` resource type. Allowed values are:
691
+ with the `ssh_authorized_key` resource type. This parameter is a noop if the
692
+ ssh_authorized_key type is not available.
693
+
694
+ Allowed values are:
685
695
 
686
696
  * `false` (default) --- don't purge SSH keys for this user.
687
697
  * `true` --- look for keys in the `.ssh/authorized_keys` file in the user's
@@ -780,6 +790,10 @@ module Puppet
780
790
  # @return [Array<Puppet::Type::Ssh_authorized_key] a list of resources
781
791
  # representing the found keys
782
792
  def unknown_keys_in_file(keyfile)
793
+ # The ssh_authorized_key type is distributed as a module on the Forge,
794
+ # so we shouldn't rely on it being available.
795
+ return [] unless Puppet::Type.type(:ssh_authorized_key)
796
+
783
797
  names = []
784
798
  name_index = 0
785
799
  # RFC 4716 specifies UTF-8 allowed in public key files per https://www.ietf.org/rfc/rfc4716.txt