bolt 3.15.0 → 3.18.0

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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +7 -7
  3. data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +1 -4
  4. data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -4
  5. data/bolt-modules/file/lib/puppet/functions/file/exists.rb +1 -4
  6. data/bolt-modules/file/lib/puppet/functions/file/read.rb +1 -4
  7. data/bolt-modules/file/lib/puppet/functions/file/readable.rb +1 -4
  8. data/lib/bolt/analytics.rb +4 -21
  9. data/lib/bolt/application.rb +627 -0
  10. data/lib/bolt/applicator.rb +7 -6
  11. data/lib/bolt/apply_inventory.rb +3 -3
  12. data/lib/bolt/apply_result.rb +2 -2
  13. data/lib/bolt/bolt_option_parser.rb +27 -3
  14. data/lib/bolt/catalog.rb +10 -11
  15. data/lib/bolt/cli.rb +607 -809
  16. data/lib/bolt/config/modulepath.rb +1 -1
  17. data/lib/bolt/config/options.rb +32 -13
  18. data/lib/bolt/config/transport/base.rb +4 -4
  19. data/lib/bolt/config/transport/docker.rb +2 -2
  20. data/lib/bolt/config/transport/local.rb +2 -2
  21. data/lib/bolt/config/transport/lxd.rb +2 -2
  22. data/lib/bolt/config/transport/orch.rb +2 -2
  23. data/lib/bolt/config/transport/podman.rb +2 -2
  24. data/lib/bolt/config/transport/remote.rb +2 -2
  25. data/lib/bolt/config/transport/ssh.rb +2 -2
  26. data/lib/bolt/config/transport/winrm.rb +2 -2
  27. data/lib/bolt/config.rb +5 -5
  28. data/lib/bolt/container_result.rb +2 -2
  29. data/lib/bolt/error.rb +1 -1
  30. data/lib/bolt/executor.rb +17 -14
  31. data/lib/bolt/fiber_executor.rb +9 -5
  32. data/lib/bolt/inventory/group.rb +4 -4
  33. data/lib/bolt/inventory/inventory.rb +64 -41
  34. data/lib/bolt/inventory/options.rb +1 -1
  35. data/lib/bolt/inventory/target.rb +1 -1
  36. data/lib/bolt/inventory.rb +10 -17
  37. data/lib/bolt/module_installer/installer.rb +2 -2
  38. data/lib/bolt/module_installer/puppetfile/forge_module.rb +1 -1
  39. data/lib/bolt/module_installer/puppetfile/git_module.rb +1 -1
  40. data/lib/bolt/module_installer/puppetfile/module.rb +1 -1
  41. data/lib/bolt/module_installer/puppetfile.rb +27 -13
  42. data/lib/bolt/module_installer/resolver.rb +3 -3
  43. data/lib/bolt/module_installer/specs/forge_spec.rb +1 -1
  44. data/lib/bolt/module_installer/specs/git_spec.rb +1 -1
  45. data/lib/bolt/module_installer/specs.rb +3 -3
  46. data/lib/bolt/module_installer.rb +6 -6
  47. data/lib/bolt/node/errors.rb +1 -1
  48. data/lib/bolt/node/output.rb +1 -1
  49. data/lib/bolt/outputter/human.rb +85 -34
  50. data/lib/bolt/outputter/json.rb +63 -38
  51. data/lib/bolt/outputter/logger.rb +1 -1
  52. data/lib/bolt/outputter/rainbow.rb +1 -1
  53. data/lib/bolt/outputter.rb +4 -4
  54. data/lib/bolt/pal/logging.rb +1 -1
  55. data/lib/bolt/pal/yaml_plan/evaluator.rb +1 -1
  56. data/lib/bolt/pal/yaml_plan/loader.rb +2 -2
  57. data/lib/bolt/pal/yaml_plan/step.rb +11 -11
  58. data/lib/bolt/pal/yaml_plan/transpiler.rb +3 -3
  59. data/lib/bolt/pal/yaml_plan.rb +2 -2
  60. data/lib/bolt/pal.rb +11 -11
  61. data/lib/bolt/plan_creator.rb +88 -29
  62. data/lib/bolt/plan_future.rb +11 -6
  63. data/lib/bolt/plan_result.rb +3 -3
  64. data/lib/bolt/plugin/cache.rb +2 -2
  65. data/lib/bolt/plugin/module.rb +1 -1
  66. data/lib/bolt/plugin.rb +18 -24
  67. data/lib/bolt/project.rb +4 -11
  68. data/lib/bolt/project_manager/config_migrator.rb +1 -1
  69. data/lib/bolt/project_manager/inventory_migrator.rb +1 -1
  70. data/lib/bolt/project_manager/migrator.rb +1 -1
  71. data/lib/bolt/project_manager/module_migrator.rb +5 -5
  72. data/lib/bolt/project_manager.rb +23 -4
  73. data/lib/bolt/puppetdb/config.rb +1 -1
  74. data/lib/bolt/puppetdb.rb +3 -3
  75. data/lib/bolt/result.rb +1 -1
  76. data/lib/bolt/result_set.rb +2 -1
  77. data/lib/bolt/shell/bash.rb +12 -2
  78. data/lib/bolt/shell/powershell.rb +9 -2
  79. data/lib/bolt/shell.rb +2 -2
  80. data/lib/bolt/target.rb +2 -2
  81. data/lib/bolt/transport/base.rb +1 -1
  82. data/lib/bolt/transport/docker/connection.rb +1 -1
  83. data/lib/bolt/transport/docker.rb +2 -2
  84. data/lib/bolt/transport/local/connection.rb +19 -3
  85. data/lib/bolt/transport/local.rb +3 -3
  86. data/lib/bolt/transport/lxd/connection.rb +1 -1
  87. data/lib/bolt/transport/lxd.rb +4 -4
  88. data/lib/bolt/transport/orch/connection.rb +13 -1
  89. data/lib/bolt/transport/orch.rb +2 -2
  90. data/lib/bolt/transport/podman/connection.rb +1 -1
  91. data/lib/bolt/transport/podman.rb +2 -2
  92. data/lib/bolt/transport/remote.rb +2 -2
  93. data/lib/bolt/transport/simple.rb +3 -3
  94. data/lib/bolt/transport/ssh/connection.rb +3 -3
  95. data/lib/bolt/transport/ssh.rb +5 -5
  96. data/lib/bolt/transport/winrm/connection.rb +2 -2
  97. data/lib/bolt/transport/winrm.rb +3 -3
  98. data/lib/bolt/util.rb +8 -31
  99. data/lib/bolt/validator.rb +1 -1
  100. data/lib/bolt/version.rb +1 -1
  101. data/lib/bolt.rb +1 -1
  102. data/lib/bolt_server/file_cache.rb +12 -0
  103. data/lib/bolt_server/schemas/action-apply.json +32 -0
  104. data/lib/bolt_server/schemas/action-apply_prep.json +19 -0
  105. data/lib/bolt_server/transport_app.rb +129 -26
  106. data/lib/bolt_spec/bolt_context.rb +7 -5
  107. data/lib/bolt_spec/plans/mock_executor.rb +3 -3
  108. data/lib/bolt_spec/run.rb +1 -1
  109. data/libexec/bolt_catalog +1 -1
  110. metadata +7 -5
  111. data/lib/bolt/secret.rb +0 -37
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/config'
3
+ require_relative '../../bolt/config'
4
4
 
5
5
  module Bolt
6
6
  class Config
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/config/transport/docker'
4
- require 'bolt/config/transport/local'
5
- require 'bolt/config/transport/lxd'
6
- require 'bolt/config/transport/orch'
7
- require 'bolt/config/transport/podman'
8
- require 'bolt/config/transport/remote'
9
- require 'bolt/config/transport/ssh'
10
- require 'bolt/config/transport/winrm'
3
+ require_relative '../../bolt/config/transport/docker'
4
+ require_relative '../../bolt/config/transport/local'
5
+ require_relative '../../bolt/config/transport/lxd'
6
+ require_relative '../../bolt/config/transport/orch'
7
+ require_relative '../../bolt/config/transport/podman'
8
+ require_relative '../../bolt/config/transport/remote'
9
+ require_relative '../../bolt/config/transport/ssh'
10
+ require_relative '../../bolt/config/transport/winrm'
11
11
 
12
12
  module Bolt
13
13
  class Config
@@ -147,14 +147,23 @@ module Bolt
147
147
  type: Hash,
148
148
  properties: {
149
149
  "file_paths" => {
150
- description: "Load scripts from the `scripts/` directory of a module",
150
+ description: "Load scripts from the `scripts/` directory of a module.",
151
+ type: [TrueClass, FalseClass],
152
+ _example: true,
153
+ _default: false,
154
+ _deprecation: "Bolt no longer honors this option and enables loading scripts from the scripts "\
155
+ "directory by default."
156
+ },
157
+ "script_interpreter" => {
158
+ description: "Use a target's [`interpreters` configuration](bolt_transports_reference.md#interpreters) "\
159
+ "when running a script.",
151
160
  type: [TrueClass, FalseClass],
152
161
  _example: true,
153
162
  _default: false
154
163
  }
155
164
  },
156
165
  _plugin: false,
157
- _example: { 'file_paths' => true }
166
+ _example: { 'script_interpreter' => true }
158
167
  },
159
168
  "hiera-config" => {
160
169
  description: "The path to the Hiera configuration file.",
@@ -248,10 +257,16 @@ module Bolt
248
257
  type: Hash,
249
258
  properties: {
250
259
  "forge" => {
251
- description: "A subsection that can have its own `proxy` setting to set an HTTP proxy for Forge "\
252
- "operations only, and a `baseurl` setting to specify a different Forge host.",
260
+ description: "A subsection for configuring connections to a Forge host.",
253
261
  type: Hash,
254
262
  properties: {
263
+ "authorization_token" => {
264
+ description: "The token used to authorize requests to the Forge host. Must also specify "\
265
+ "`baseurl` when using this option.",
266
+ type: String,
267
+ _example: "Bearer eyJhbGciOiJIUzI1NiIsInR5c...",
268
+ _plugin: true
269
+ },
255
270
  "baseurl" => {
256
271
  description: "The URL to the Forge host.",
257
272
  type: String,
@@ -265,7 +280,11 @@ module Bolt
265
280
  _example: "https://my-forge-proxy.com:8080"
266
281
  }
267
282
  },
268
- _example: { "baseurl" => "https://forge.example.com", "proxy" => "https://my-forge-proxy.com:8080" }
283
+ _example: {
284
+ "authorization_token" => "Bearer eyJhbGciOiJIUzI1NiIsInR5c...",
285
+ "baseurl" => "https://forge.example.com",
286
+ "proxy" => "https://my-forge-proxy.com:8080"
287
+ }
269
288
  },
270
289
  "proxy" => {
271
290
  description: "The HTTP proxy to use for Git and Forge operations.",
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/util'
5
- require 'bolt/validator'
6
- require 'bolt/config/transport/options'
3
+ require_relative '../../../bolt/error'
4
+ require_relative '../../../bolt/util'
5
+ require_relative '../../../bolt/validator'
6
+ require_relative '../../../bolt/config/transport/options'
7
7
 
8
8
  module Bolt
9
9
  class Config
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/config/transport/base'
3
+ require_relative '../../../bolt/error'
4
+ require_relative '../../../bolt/config/transport/base'
5
5
 
6
6
  module Bolt
7
7
  class Config
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/config/transport/base'
3
+ require_relative '../../../bolt/error'
4
+ require_relative '../../../bolt/config/transport/base'
5
5
 
6
6
  module Bolt
7
7
  class Config
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/config/transport/base'
3
+ require_relative '../../../bolt/error'
4
+ require_relative '../../../bolt/config/transport/base'
5
5
 
6
6
  module Bolt
7
7
  class Config
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/config/transport/base'
3
+ require_relative '../../../bolt/error'
4
+ require_relative '../../../bolt/config/transport/base'
5
5
 
6
6
  module Bolt
7
7
  class Config
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/config/transport/base'
3
+ require_relative '../../../bolt/error'
4
+ require_relative '../../../bolt/config/transport/base'
5
5
 
6
6
  module Bolt
7
7
  class Config
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/config/transport/base'
3
+ require_relative '../../../bolt/error'
4
+ require_relative '../../../bolt/config/transport/base'
5
5
 
6
6
  module Bolt
7
7
  class Config
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/config/transport/base'
3
+ require_relative '../../../bolt/error'
4
+ require_relative '../../../bolt/config/transport/base'
5
5
 
6
6
  module Bolt
7
7
  class Config
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/config/transport/base'
3
+ require_relative '../../../bolt/error'
4
+ require_relative '../../../bolt/config/transport/base'
5
5
 
6
6
  module Bolt
7
7
  class Config
data/lib/bolt/config.rb CHANGED
@@ -3,11 +3,11 @@
3
3
  require 'etc'
4
4
  require 'logging'
5
5
  require 'pathname'
6
- require 'bolt/project'
7
- require 'bolt/logger'
8
- require 'bolt/util'
9
- require 'bolt/config/options'
10
- require 'bolt/validator'
6
+ require_relative '../bolt/project'
7
+ require_relative '../bolt/logger'
8
+ require_relative '../bolt/util'
9
+ require_relative 'config/options'
10
+ require_relative '../bolt/validator'
11
11
 
12
12
  module Bolt
13
13
  class UnknownTransportError < Bolt::Error
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'bolt/error'
5
- require 'bolt/result'
4
+ require_relative '../bolt/error'
5
+ require_relative '../bolt/result'
6
6
 
7
7
  module Bolt
8
8
  class ContainerResult
data/lib/bolt/error.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/util'
3
+ require_relative '../bolt/util'
4
4
 
5
5
  module Bolt
6
6
  class Error < RuntimeError
data/lib/bolt/executor.rb CHANGED
@@ -6,21 +6,21 @@ require 'json'
6
6
  require 'logging'
7
7
  require 'pathname'
8
8
  require 'set'
9
- require 'bolt/analytics'
10
- require 'bolt/config'
11
- require 'bolt/fiber_executor'
12
- require 'bolt/puppetdb'
13
- require 'bolt/result'
14
- require 'bolt/result_set'
9
+ require_relative '../bolt/analytics'
10
+ require_relative '../bolt/config'
11
+ require_relative '../bolt/fiber_executor'
12
+ require_relative '../bolt/puppetdb'
13
+ require_relative '../bolt/result'
14
+ require_relative '../bolt/result_set'
15
15
  # Load transports
16
- require 'bolt/transport/docker'
17
- require 'bolt/transport/local'
18
- require 'bolt/transport/lxd'
19
- require 'bolt/transport/orch'
20
- require 'bolt/transport/podman'
21
- require 'bolt/transport/remote'
22
- require 'bolt/transport/ssh'
23
- require 'bolt/transport/winrm'
16
+ require_relative '../bolt/transport/docker'
17
+ require_relative '../bolt/transport/local'
18
+ require_relative '../bolt/transport/lxd'
19
+ require_relative '../bolt/transport/orch'
20
+ require_relative '../bolt/transport/podman'
21
+ require_relative '../bolt/transport/remote'
22
+ require_relative '../bolt/transport/ssh'
23
+ require_relative '../bolt/transport/winrm'
24
24
 
25
25
  module Bolt
26
26
  TRANSPORTS = {
@@ -300,6 +300,9 @@ module Bolt
300
300
  description = options.fetch(:description, "script #{script}")
301
301
  log_action(description, targets) do
302
302
  options[:run_as] = run_as if run_as && !options.key?(:run_as)
303
+ options[:script_interpreter] = (future || {}).fetch('script_interpreter', false)
304
+
305
+ @analytics&.event('Future', 'script_interpreter', label: options[:script_interpreter].to_s)
303
306
 
304
307
  batch_execute(targets) do |transport, batch|
305
308
  with_node_logging("Running script #{script} with '#{arguments.to_json}'", batch) do
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/logger'
4
- require 'bolt/plan_future'
3
+ require_relative '../bolt/logger'
4
+ require_relative '../bolt/plan_future'
5
5
 
6
6
  module Bolt
7
7
  class FiberExecutor
@@ -52,7 +52,7 @@ module Bolt
52
52
  # tracking which Futures to wait on when `wait()` is called without
53
53
  # arguments.
54
54
  @id += 1
55
- future = Bolt::PlanFuture.new(future, @id, name: name, plan_id: plan_id)
55
+ future = Bolt::PlanFuture.new(future, @id, name: name, plan_id: plan_id, scope: newscope)
56
56
  @logger.trace("Created future #{future.name}")
57
57
 
58
58
  # Register the PlanFuture with the FiberExecutor to be executed
@@ -68,11 +68,15 @@ module Bolt
68
68
  #
69
69
  def round_robin
70
70
  active_futures.each do |future|
71
- # If the Fiber is still running and can be resumed, then resume it
71
+ # If the Fiber is still running and can be resumed, then resume it.
72
+ # Override Puppet's global_scope to prevent ephemerals in other scopes
73
+ # from being popped off in the wrong order due to race conditions.
74
+ # This primarily happens when running executor functions from custom
75
+ # Puppet language functions, but may happen elsewhere.
72
76
  @logger.trace("Checking future '#{future.name}'")
73
77
  if future.alive?
74
78
  @logger.trace("Resuming future '#{future.name}'")
75
- future.resume
79
+ Puppet.override(global_scope: future.scope) { future.resume }
76
80
  end
77
81
 
78
82
  # Once we've restarted the Fiber, check to see if it's finished again
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/config/options'
4
- require 'bolt/inventory/group'
5
- require 'bolt/inventory/inventory'
6
- require 'bolt/inventory/target'
3
+ require_relative '../../bolt/config/options'
4
+ require_relative '../../bolt/inventory/group'
5
+ require_relative '../../bolt/inventory/inventory'
6
+ require_relative '../../bolt/inventory/target'
7
7
 
8
8
  module Bolt
9
9
  class Inventory
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/inventory/group'
4
- require 'bolt/inventory/target'
3
+ require_relative '../../bolt/inventory/group'
4
+ require_relative '../../bolt/inventory/target'
5
5
 
6
6
  module Bolt
7
7
  class Inventory
8
8
  class Inventory
9
- attr_reader :config, :plugins, :source, :targets, :transport
9
+ attr_reader :plugins, :source, :targets, :transport
10
10
 
11
11
  class WildcardError < Bolt::Error
12
12
  def initialize(target)
@@ -14,25 +14,15 @@ module Bolt
14
14
  end
15
15
  end
16
16
 
17
- # TODO: Pass transport config instead of config object
18
17
  def initialize(data, transport, transports, plugins, source = nil)
19
- @logger = Bolt::Logger.logger(self)
20
- @data = data || {}
21
- @transport = transport
22
- @config = transports
23
- @plugins = plugins
24
- @groups = Group.new(@data, plugins, all_group: true)
25
- @group_lookup = {}
26
- @targets = {}
27
- @source = source
28
-
29
- @groups.resolve_string_targets(@groups.target_aliases, @groups.all_targets)
30
-
31
- collect_groups
32
- end
33
-
34
- def validate
35
- @groups.validate
18
+ @logger = Bolt::Logger.logger(self)
19
+ @data = data || {}
20
+ @transport = transport
21
+ @config = transports
22
+ @config_resolved = transports.values.all?(&:resolved?)
23
+ @plugins = plugins
24
+ @targets = {}
25
+ @source = source
36
26
  end
37
27
 
38
28
  def version
@@ -43,13 +33,46 @@ module Bolt
43
33
  Bolt::Target
44
34
  end
45
35
 
46
- def collect_groups
47
- # Provide a lookup map for finding a group by name
48
- @group_lookup = @groups.collect_groups
36
+ # Load and resolve the groups in the inventory. Loading groups resolves
37
+ # all plugin references except for those for target data and config.
38
+ #
39
+ # @return [Bolt::Inventory::Group]
40
+ #
41
+ def groups
42
+ @groups ||= Group.new(@data, @plugins, all_group: true).tap do |groups|
43
+ groups.resolve_string_targets(groups.target_aliases, groups.all_targets)
44
+ groups.validate
45
+ end
49
46
  end
50
47
 
48
+ # Return a list of all group names in the inventory.
49
+ #
50
+ # @return [Array[String]]
51
+ #
51
52
  def group_names
52
- @group_lookup.keys
53
+ group_lookup.keys
54
+ end
55
+
56
+ # Return a map of all groups in the inventory.
57
+ #
58
+ # @return [Hash[String, Bolt::Inventory::Group]]
59
+ #
60
+ def group_lookup
61
+ @group_lookup ||= groups.collect_groups
62
+ end
63
+
64
+ # Return a map of transport configuration for the inventory. Any
65
+ # unresolved plugin references are resolved.
66
+ #
67
+ # @return [Hash[String, Bolt::Config::Transport]]
68
+ #
69
+ def config
70
+ if @config_resolved
71
+ @config
72
+ else
73
+ @config_resolved = true
74
+ @config.transform_values! { |t| t.resolved? ? t : t.resolve(@plugins) }
75
+ end
53
76
  end
54
77
 
55
78
  def group_names_for(target_name)
@@ -57,7 +80,7 @@ module Bolt
57
80
  end
58
81
 
59
82
  def target_names
60
- @groups.all_targets
83
+ groups.all_targets
61
84
  end
62
85
  # alias for analytics
63
86
  alias node_names target_names
@@ -81,7 +104,7 @@ module Bolt
81
104
 
82
105
  #### PRIVATE ####
83
106
  def group_data_for(target_name)
84
- @groups.group_collect(target_name)
107
+ groups.group_collect(target_name)
85
108
  end
86
109
 
87
110
  # If target is a group name, expand it to the members of that group.
@@ -89,15 +112,15 @@ module Bolt
89
112
  # If a wildcard string, error if no matches are found.
90
113
  # Else fall back to [target] if no matches are found.
91
114
  def resolve_name(target)
92
- if (group = @group_lookup[target])
115
+ if (group = group_lookup[target])
93
116
  group.all_targets
94
117
  else
95
118
  # Try to wildcard match targets in inventory
96
119
  # Ignore case because hostnames are generally case-insensitive
97
120
  regexp = Regexp.new("^#{Regexp.escape(target).gsub('\*', '.*?')}$", Regexp::IGNORECASE)
98
121
 
99
- targets = @groups.all_targets.select { |targ| targ =~ regexp }
100
- targets += @groups.target_aliases.select { |target_alias, _target| target_alias =~ regexp }.values
122
+ targets = groups.all_targets.select { |targ| targ =~ regexp }
123
+ targets += groups.target_aliases.select { |target_alias, _target| target_alias =~ regexp }.values
101
124
 
102
125
  if targets.empty?
103
126
  raise(WildcardError, target) if target.include?('*')
@@ -165,7 +188,7 @@ module Bolt
165
188
  # associated references. This is used when a target is resolved by
166
189
  # get_targets.
167
190
  def create_target_from_inventory(target_name)
168
- target_data = @groups.target_collect(target_name) || { 'uri' => target_name }
191
+ target_data = groups.target_collect(target_name) || { 'uri' => target_name }
169
192
 
170
193
  target = Bolt::Inventory::Target.new(target_data, self)
171
194
  @targets[target.name] = target
@@ -187,24 +210,24 @@ module Bolt
187
210
  @targets[new_target.name] = new_target
188
211
 
189
212
  if existing_target
190
- clear_alia_from_group(@groups, new_target.name)
213
+ clear_alia_from_group(groups, new_target.name)
191
214
  else
192
215
  add_to_group([new_target], 'all')
193
216
  end
194
217
 
195
218
  if new_target.target_alias
196
- @groups.insert_alia(new_target.name, Array(new_target.target_alias))
219
+ groups.insert_alia(new_target.name, Array(new_target.target_alias))
197
220
  end
198
221
 
199
222
  new_target
200
223
  end
201
224
 
202
225
  def validate_target_from_hash(target)
203
- groups = Set.new(group_names)
204
- targets = target_names
226
+ used_groups = Set.new(group_names)
227
+ used_targets = target_names
205
228
 
206
229
  # Make sure there are no group name conflicts
207
- if groups.include?(target.name)
230
+ if used_groups.include?(target.name)
208
231
  raise ValidationError.new("Target name #{target.name} conflicts with group of the same name", nil)
209
232
  end
210
233
 
@@ -217,11 +240,11 @@ module Bolt
217
240
  end
218
241
 
219
242
  # Make sure there are no conflicts with the new target aliases
220
- used_aliases = @groups.target_aliases
243
+ used_aliases = groups.target_aliases
221
244
  Array(target.target_alias).each do |alia|
222
- if groups.include?(alia)
245
+ if used_groups.include?(alia)
223
246
  raise ValidationError.new("Alias #{alia} conflicts with group of the same name", nil)
224
- elsif targets.include?(alia)
247
+ elsif used_targets.include?(alia)
225
248
  raise ValidationError.new("Alias #{alia} conflicts with target of the same name", nil)
226
249
  elsif used_aliases[alia] && used_aliases[alia] != target.name
227
250
  raise ValidationError.new(
@@ -250,7 +273,7 @@ module Bolt
250
273
  end
251
274
 
252
275
  if group_names.include?(desired_group)
253
- remove_target(@groups, @targets[target.first.name], desired_group)
276
+ remove_target(groups, @targets[target.first.name], desired_group)
254
277
  else
255
278
  raise ValidationError.new("Group #{desired_group} does not exist in inventory", nil)
256
279
  end
@@ -260,7 +283,7 @@ module Bolt
260
283
  if group_names.include?(desired_group)
261
284
  targets.each do |target|
262
285
  # Add the inventory copy of the target
263
- add_target(@groups, @targets[target.name], desired_group)
286
+ add_target(groups, @targets[target.name], desired_group)
264
287
  end
265
288
  else
266
289
  raise ValidationError.new("Group #{desired_group} does not exist in inventory", nil)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/config/options'
3
+ require_relative '../../bolt/config/options'
4
4
 
5
5
  module Bolt
6
6
  class Inventory
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/resource_instance'
3
+ require_relative '../../bolt/resource_instance'
4
4
 
5
5
  module Bolt
6
6
  class Inventory
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'set'
4
- require 'bolt/config'
5
- require 'bolt/inventory/group'
6
- require 'bolt/inventory/inventory'
7
- require 'bolt/inventory/options'
8
- require 'bolt/target'
9
- require 'bolt/util'
10
- require 'bolt/plugin'
11
- require 'bolt/validator'
4
+ require_relative '../bolt/config'
5
+ require_relative 'inventory/group'
6
+ require_relative 'inventory/inventory'
7
+ require_relative 'inventory/options'
8
+ require_relative '../bolt/target'
9
+ require_relative '../bolt/util'
10
+ require_relative '../bolt/plugin'
11
+ require_relative '../bolt/validator'
12
12
  require 'yaml'
13
13
 
14
14
  module Bolt
@@ -91,19 +91,12 @@ module Bolt
91
91
  end
92
92
  end
93
93
 
94
- # Resolve plugin references from transport config
95
- config.transports.each_value do |t|
96
- t.resolve(plugins) unless t.resolved?
97
- end
98
-
99
94
  Bolt::Validator.new.tap do |validator|
100
95
  validator.validate(data, schema, source)
101
96
  validator.warnings.each { |warning| Bolt::Logger.warn(warning[:id], warning[:msg]) }
102
97
  end
103
98
 
104
- inventory = create_version(data, config.transport, config.transports, plugins, source)
105
- inventory.validate
106
- inventory
99
+ create_version(data, config.transport, config.transports, plugins, source)
107
100
  end
108
101
 
109
102
  def self.create_version(data, transport, transports, plugins, source = nil)
@@ -119,7 +112,7 @@ module Bolt
119
112
 
120
113
  def self.empty
121
114
  config = Bolt::Config.default
122
- plugins = Bolt::Plugin.setup(config, nil)
115
+ plugins = Bolt::Plugin.new(config, nil)
123
116
 
124
117
  create_version({}, config.transport, config.transports, plugins, nil)
125
118
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/r10k_log_proxy'
4
- require 'bolt/error'
3
+ require_relative '../../bolt/r10k_log_proxy'
4
+ require_relative '../../bolt/error'
5
5
 
6
6
  # This class is used to install modules from a Puppetfile to a module directory.
7
7
  #
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'semantic_puppet'
4
- require 'bolt/module_installer/puppetfile/module'
4
+ require_relative '../../../bolt/module_installer/puppetfile/module'
5
5
 
6
6
  # This class represents a resolved Forge module.
7
7
  #
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/module_installer/puppetfile/module'
3
+ require_relative '../../../bolt/module_installer/puppetfile/module'
4
4
 
5
5
  # This class represents a resolved Git module.
6
6
  #
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
3
+ require_relative '../../../bolt/error'
4
4
 
5
5
  module Bolt
6
6
  class ModuleInstaller