bolt 2.33.1 → 2.37.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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +1 -1
  3. data/bolt-modules/boltlib/lib/puppet/datatypes/applyresult.rb +1 -0
  4. data/bolt-modules/boltlib/lib/puppet/functions/catch_errors.rb +1 -3
  5. data/bolt-modules/boltlib/lib/puppet/functions/download_file.rb +17 -6
  6. data/bolt-modules/boltlib/lib/puppet/functions/parallelize.rb +56 -0
  7. data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +24 -6
  8. data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +27 -8
  9. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +21 -1
  10. data/bolt-modules/boltlib/lib/puppet/functions/run_task_with.rb +18 -1
  11. data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +24 -6
  12. data/lib/bolt/analytics.rb +27 -8
  13. data/lib/bolt/apply_result.rb +3 -3
  14. data/lib/bolt/bolt_option_parser.rb +48 -16
  15. data/lib/bolt/cli.rb +95 -227
  16. data/lib/bolt/config.rb +145 -54
  17. data/lib/bolt/config/options.rb +76 -10
  18. data/lib/bolt/config/transport/base.rb +10 -19
  19. data/lib/bolt/config/transport/local.rb +0 -7
  20. data/lib/bolt/config/transport/options.rb +1 -1
  21. data/lib/bolt/config/transport/ssh.rb +8 -14
  22. data/lib/bolt/config/validator.rb +231 -0
  23. data/lib/bolt/error.rb +33 -3
  24. data/lib/bolt/executor.rb +92 -6
  25. data/lib/bolt/inventory/group.rb +2 -1
  26. data/lib/bolt/module_installer.rb +1 -1
  27. data/lib/bolt/module_installer/specs/forge_spec.rb +5 -4
  28. data/lib/bolt/module_installer/specs/git_spec.rb +4 -3
  29. data/lib/bolt/outputter/human.rb +21 -9
  30. data/lib/bolt/outputter/rainbow.rb +1 -1
  31. data/lib/bolt/pal.rb +19 -7
  32. data/lib/bolt/pal/yaml_plan.rb +7 -0
  33. data/lib/bolt/plan_creator.rb +160 -0
  34. data/lib/bolt/plugin.rb +42 -13
  35. data/lib/bolt/plugin/cache.rb +76 -0
  36. data/lib/bolt/plugin/module.rb +4 -4
  37. data/lib/bolt/project.rb +46 -40
  38. data/lib/bolt/project_manager.rb +199 -0
  39. data/lib/bolt/{project_migrator/config.rb → project_manager/config_migrator.rb} +43 -5
  40. data/lib/bolt/{project_migrator/inventory.rb → project_manager/inventory_migrator.rb} +5 -5
  41. data/lib/bolt/{project_migrator/base.rb → project_manager/migrator.rb} +2 -2
  42. data/lib/bolt/{project_migrator/modules.rb → project_manager/module_migrator.rb} +3 -3
  43. data/lib/bolt/puppetdb/client.rb +3 -2
  44. data/lib/bolt/puppetdb/config.rb +9 -8
  45. data/lib/bolt/rerun.rb +1 -5
  46. data/lib/bolt/shell/bash.rb +8 -2
  47. data/lib/bolt/shell/powershell.rb +17 -1
  48. data/lib/bolt/task/run.rb +1 -1
  49. data/lib/bolt/transport/orch.rb +0 -5
  50. data/lib/bolt/transport/orch/connection.rb +10 -3
  51. data/lib/bolt/transport/remote.rb +1 -1
  52. data/lib/bolt/transport/ssh/exec_connection.rb +6 -2
  53. data/lib/bolt/util.rb +41 -7
  54. data/lib/bolt/version.rb +1 -1
  55. data/lib/bolt/yarn.rb +23 -0
  56. data/lib/bolt_server/base_config.rb +3 -1
  57. data/lib/bolt_server/config.rb +3 -1
  58. data/lib/bolt_server/file_cache.rb +2 -0
  59. data/lib/bolt_server/plugin.rb +13 -0
  60. data/lib/bolt_server/plugin/puppet_connect_data.rb +37 -0
  61. data/lib/bolt_server/schemas/connect-data.json +22 -0
  62. data/lib/bolt_server/schemas/partials/task.json +2 -2
  63. data/lib/bolt_server/transport_app.rb +72 -13
  64. data/lib/bolt_spec/plans/mock_executor.rb +4 -1
  65. data/libexec/apply_catalog.rb +1 -1
  66. data/libexec/custom_facts.rb +1 -1
  67. data/libexec/query_resources.rb +1 -1
  68. metadata +15 -13
  69. data/lib/bolt/project_migrator.rb +0 -80
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "title": "project_inventory_targets connect plugin data",
4
+ "description": "POST project_inventory_targets connect plugin data",
5
+ "type": "object",
6
+ "properties": {
7
+ "puppet_connect_data": {
8
+ "type": "object",
9
+ "patternProperties": {
10
+ ".*": {
11
+ "type": "object",
12
+ "properties": {
13
+ "value": {}
14
+ },
15
+ "required": ["value"]
16
+ }
17
+ },
18
+ "additionalProperties": false
19
+ }
20
+ },
21
+ "required": ["puppet_connect_data"]
22
+ }
@@ -64,7 +64,7 @@
64
64
  "description": "Environment the task is in",
65
65
  "type": "string"
66
66
  },
67
- "project": {
67
+ "versioned_project": {
68
68
  "description": "Project the task is in",
69
69
  "type": "string"
70
70
  }
@@ -77,7 +77,7 @@
77
77
  },
78
78
  {
79
79
  "required": [
80
- "project"
80
+ "versioned_project"
81
81
  ]
82
82
  }
83
83
  ],
@@ -8,6 +8,8 @@ require 'bolt/inventory'
8
8
  require 'bolt/project'
9
9
  require 'bolt/target'
10
10
  require 'bolt_server/file_cache'
11
+ require 'bolt_server/plugin'
12
+ require 'bolt_server/plugin/puppet_connect_data'
11
13
  require 'bolt/task/puppet_server'
12
14
  require 'json'
13
15
  require 'json-schema'
@@ -35,6 +37,7 @@ module BoltServer
35
37
  action-upload_file
36
38
  transport-ssh
37
39
  transport-winrm
40
+ connect-data
38
41
  ].freeze
39
42
 
40
43
  # PE_BOLTLIB_PATH is intended to function exactly like the BOLTLIB_PATH used
@@ -48,6 +51,10 @@ module BoltServer
48
51
  # See the `orchestrator.bolt.codedir` tk config setting.
49
52
  DEFAULT_BOLT_CODEDIR = '/opt/puppetlabs/server/data/orchestration-services/code'
50
53
 
54
+ MISSING_PROJECT_REF_RESPONSE = [
55
+ 400, Bolt::ValidationError.new('`project_ref` is a required argument').to_json
56
+ ].freeze
57
+
51
58
  def initialize(config)
52
59
  @config = config
53
60
  @schemas = Hash[REQUEST_SCHEMAS.map do |basename|
@@ -231,9 +238,9 @@ module BoltServer
231
238
  #
232
239
  # WARNING: THIS FUNCTION SHOULD ONLY BE CALLED INSIDE A SYNCHRONIZED PAL MUTEX
233
240
  def modulepath_from_environment(environment_name)
234
- codedir = DEFAULT_BOLT_CODEDIR
235
- environmentpath = "#{codedir}/environments"
236
- basemodulepath = "#{codedir}/modules:/opt/puppetlabs/puppet/modules"
241
+ codedir = @config['environments-codedir'] || DEFAULT_BOLT_CODEDIR
242
+ environmentpath = @config['environmentpath'] || "#{codedir}/environments"
243
+ basemodulepath = @config['basemodulepath'] || "#{codedir}/modules:/opt/puppetlabs/puppet/modules"
237
244
  modulepath_dirs = nil
238
245
  with_pe_pal_init_settings(codedir, environmentpath, basemodulepath) do
239
246
  environment = Puppet.lookup(:environments).get!(environment_name)
@@ -261,13 +268,16 @@ module BoltServer
261
268
  end
262
269
  end
263
270
 
264
- def in_bolt_project(bolt_project)
265
- return [400, '`project_ref` is a required argument'] if bolt_project.nil?
266
- project_dir = File.join(@config['projects-dir'], bolt_project)
267
- return [400, "`project_ref`: #{project_dir} does not exist"] unless Dir.exist?(project_dir)
271
+ def config_from_project(project_ref)
272
+ project_dir = File.join(@config['projects-dir'], project_ref)
273
+ raise Bolt::ValidationError, "`project_ref`: #{project_dir} does not exist" unless Dir.exist?(project_dir)
274
+ project = Bolt::Project.create_project(project_dir)
275
+ Bolt::Config.from_project(project, { log: { 'bolt-debug.log' => 'disable' } })
276
+ end
277
+
278
+ def in_bolt_project(project_ref)
268
279
  @pal_mutex.synchronize do
269
- project = Bolt::Project.create_project(project_dir)
270
- bolt_config = Bolt::Config.from_project(project, { log: { 'bolt-debug.log' => 'disable' } })
280
+ bolt_config = config_from_project(project_ref)
271
281
  modulepath_object = Bolt::Config::Modulepath.new(
272
282
  bolt_config.modulepath,
273
283
  boltlib_path: [PE_BOLTLIB_PATH, Bolt::Config::Modulepath::BOLTLIB_PATH]
@@ -278,8 +288,6 @@ module BoltServer
278
288
  config: bolt_config
279
289
  }
280
290
  yield context
281
- rescue Bolt::Error => e
282
- [400, e.to_json]
283
291
  end
284
292
  end
285
293
 
@@ -508,11 +516,14 @@ module BoltServer
508
516
  #
509
517
  # @param project_ref [String] the project to fetch the plan from
510
518
  get '/project_plans/:module_name/:plan_name' do
519
+ return MISSING_PROJECT_REF_RESPONSE if params['project_ref'].nil?
511
520
  in_bolt_project(params['project_ref']) do |context|
512
521
  plan_info = pe_plan_info(context[:pal], params[:module_name], params[:plan_name])
513
522
  plan_info = allowed_helper(plan_info, context[:config].project.plans)
514
523
  [200, plan_info.to_json]
515
524
  end
525
+ rescue Bolt::Error => e
526
+ [400, e.to_json]
516
527
  end
517
528
 
518
529
  # Fetches the metadata for a single task
@@ -532,14 +543,17 @@ module BoltServer
532
543
  #
533
544
  # @param bolt_project_ref [String] the reference to the bolt-project directory to load task metadata from
534
545
  get '/project_tasks/:module_name/:task_name' do
546
+ return MISSING_PROJECT_REF_RESPONSE if params['project_ref'].nil?
535
547
  in_bolt_project(params['project_ref']) do |context|
536
548
  ps_parameters = {
537
- 'project' => params['project_ref']
549
+ 'versioned_project' => params['project_ref']
538
550
  }
539
551
  task_info = pe_task_info(context[:pal], params[:module_name], params[:task_name], ps_parameters)
540
552
  task_info = allowed_helper(task_info, context[:config].project.tasks)
541
553
  [200, task_info.to_json]
542
554
  end
555
+ rescue Bolt::Error => e
556
+ [400, e.to_json]
543
557
  end
544
558
 
545
559
  # Fetches the list of plans for an environment, optionally fetching all metadata for each plan
@@ -570,6 +584,7 @@ module BoltServer
570
584
  #
571
585
  # @param project_ref [String] the project to fetch the list of plans from
572
586
  get '/project_plans' do
587
+ return MISSING_PROJECT_REF_RESPONSE if params['project_ref'].nil?
573
588
  in_bolt_project(params['project_ref']) do |context|
574
589
  plans_response = plan_list(context[:pal])
575
590
 
@@ -582,6 +597,8 @@ module BoltServer
582
597
  # to bolt-server smaller/simpler.
583
598
  [200, plans_response.to_json]
584
599
  end
600
+ rescue Bolt::Error => e
601
+ [400, e.to_json]
585
602
  end
586
603
 
587
604
  # Fetches the list of tasks for an environment
@@ -603,6 +620,7 @@ module BoltServer
603
620
  #
604
621
  # @param project_ref [String] the project to fetch the list of tasks from
605
622
  get '/project_tasks' do
623
+ return MISSING_PROJECT_REF_RESPONSE if params['project_ref'].nil?
606
624
  in_bolt_project(params['project_ref']) do |context|
607
625
  tasks_response = task_list(context[:pal])
608
626
 
@@ -615,28 +633,69 @@ module BoltServer
615
633
  # to bolt-server smaller/simpler.
616
634
  [200, tasks_response.to_json]
617
635
  end
636
+ rescue Bolt::Error => e
637
+ [400, e.to_json]
618
638
  end
619
639
 
620
640
  # Implements puppetserver's file_metadatas endpoint for projects.
621
641
  #
622
642
  # @param project_ref [String] the project_ref to fetch the file metadatas from
623
643
  get '/project_file_metadatas/:module_name/*' do
644
+ return MISSING_PROJECT_REF_RESPONSE if params['project_ref'].nil?
624
645
  in_bolt_project(params['project_ref']) do |context|
625
646
  file = params[:splat].first
626
647
  metadatas = file_metadatas(context[:pal], params[:module_name], file)
627
648
  [200, metadatas.to_json]
628
649
  end
650
+ rescue Bolt::Error => e
651
+ [400, e.to_json]
629
652
  rescue ArgumentError => e
630
653
  [400, e.message]
631
654
  end
632
655
 
656
+ # Returns a list of targets parsed from a Project inventory
657
+ #
658
+ # @param project_ref [String] the project_ref to compute the inventory from
659
+ post '/project_inventory_targets' do
660
+ return MISSING_PROJECT_REF_RESPONSE if params['project_ref'].nil?
661
+ content_type :json
662
+ body = JSON.parse(request.body.read)
663
+ error = validate_schema(@schemas["connect-data"], body)
664
+ return [400, error_result(error).to_json] unless error.nil?
665
+ in_bolt_project(params['project_ref']) do |context|
666
+ if context[:config].inventoryfile &&
667
+ context[:config].project.inventory_file.to_s !=
668
+ context[:config].inventoryfile
669
+ raise Bolt::ValidationError, "Project inventory must be defined in the " \
670
+ "inventory.yaml file at the root of the project directory"
671
+ end
672
+
673
+ Bolt::Util.validate_file('inventory file', context[:config].project.inventory_file)
674
+
675
+ begin
676
+ connect_plugin = BoltServer::Plugin::PuppetConnectData.new(body['puppet_connect_data'])
677
+ plugins = Bolt::Plugin.setup(context[:config], context[:pal], load_plugins: false)
678
+ plugins.add_plugin(connect_plugin)
679
+ inventory = Bolt::Inventory.from_config(context[:config], plugins)
680
+ target_list = inventory.get_targets('all').map { |targ| targ.to_h.merge({ 'transport' => targ.transport }) }
681
+ rescue Bolt::Plugin::PluginError::LoadingDisabled => e
682
+ msg = "Cannot load plugin #{e.details['plugin_name']}: plugin not supported"
683
+ raise BoltServer::Plugin::PluginNotSupported.new(msg, e.details['plugin_name'])
684
+ end
685
+
686
+ [200, target_list.to_json]
687
+ end
688
+ rescue Bolt::Error => e
689
+ [500, e.to_json]
690
+ end
691
+
633
692
  error 404 do
634
693
  err = Bolt::Error.new("Could not find route #{request.path}",
635
694
  'boltserver/not-found')
636
695
  [404, err.to_json]
637
696
  end
638
697
 
639
- error 500 do
698
+ error StandardError do
640
699
  e = env['sinatra.error']
641
700
  err = Bolt::Error.new("500: Unknown error: #{e.message}",
642
701
  'boltserver/server-error')
@@ -17,12 +17,13 @@ module BoltSpec
17
17
 
18
18
  # Nothing on the executor is 'public'
19
19
  class MockExecutor
20
- attr_reader :noop, :error_message
20
+ attr_reader :noop, :error_message, :in_parallel
21
21
  attr_accessor :run_as, :transport_features, :execute_any_plan
22
22
 
23
23
  def initialize(modulepath)
24
24
  @noop = false
25
25
  @run_as = nil
26
+ @in_parallel = false
26
27
  @error_message = nil
27
28
  @allow_apply = false
28
29
  @modulepath = [modulepath].flatten.map { |path| File.absolute_path(path) }
@@ -133,6 +134,7 @@ module BoltSpec
133
134
  # through to another conditional statement
134
135
  doub = @plan_doubles[plan_name] || @plan_doubles[:default]
135
136
 
137
+ # rubocop:disable Lint/DuplicateBranch
136
138
  # High level:
137
139
  # - If we've explicitly allowed execution of the plan (normally the main plan
138
140
  # passed into BoltSpec::Plan::run_plan()), then execute it
@@ -165,6 +167,7 @@ module BoltSpec
165
167
  @error_message = "Unexpected call to 'run_plan(#{plan_name}, #{params_str})'"
166
168
  raise UnexpectedInvocation, @error_message
167
169
  end
170
+ # rubocop:enable Lint/DuplicateBranch
168
171
  result
169
172
  end
170
173
 
@@ -74,7 +74,7 @@ begin
74
74
  Puppet::ResourceApi::Transport.inject_device(type, transport)
75
75
 
76
76
  Puppet[:facts_terminus] = :network_device
77
- Puppet[:certname] = conn_info['uri']
77
+ Puppet[:certname] = conn_info['name']
78
78
  end
79
79
 
80
80
  # Ensure custom facts are available for provider suitability tests
@@ -51,7 +51,7 @@ Dir.mktmpdir do |puppet_root|
51
51
  Puppet::ResourceApi::Transport.inject_device(type, transport)
52
52
 
53
53
  Puppet[:facts_terminus] = :network_device
54
- Puppet[:certname] = conn_info['uri']
54
+ Puppet[:certname] = conn_info['name']
55
55
  end
56
56
 
57
57
  facts = Puppet::Node::Facts.indirection.find(SecureRandom.uuid, environment: env)
@@ -59,7 +59,7 @@ Dir.mktmpdir do |puppet_root|
59
59
  Puppet::ResourceApi::Transport.inject_device(type, transport)
60
60
 
61
61
  Puppet[:facts_terminus] = :network_device
62
- Puppet[:certname] = conn_info['uri']
62
+ Puppet[:certname] = conn_info['name']
63
63
  end
64
64
 
65
65
  resources = args['resources'].flat_map do |resource_desc|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.33.1
4
+ version: 2.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-02 00:00:00.000000000 Z
11
+ date: 2020-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -185,9 +185,6 @@ dependencies:
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: 6.18.0
188
- - - "<="
189
- - !ruby/object:Gem::Version
190
- version: '6.19'
191
188
  type: :runtime
192
189
  prerelease: false
193
190
  version_requirements: !ruby/object:Gem::Requirement
@@ -195,9 +192,6 @@ dependencies:
195
192
  - - ">="
196
193
  - !ruby/object:Gem::Version
197
194
  version: 6.18.0
198
- - - "<="
199
- - !ruby/object:Gem::Version
200
- version: '6.19'
201
195
  - !ruby/object:Gem::Dependency
202
196
  name: puppetfile-resolver
203
197
  requirement: !ruby/object:Gem::Requirement
@@ -404,6 +398,7 @@ files:
404
398
  - bolt-modules/boltlib/lib/puppet/functions/get_resources.rb
405
399
  - bolt-modules/boltlib/lib/puppet/functions/get_target.rb
406
400
  - bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
401
+ - bolt-modules/boltlib/lib/puppet/functions/parallelize.rb
407
402
  - bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
408
403
  - bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb
409
404
  - bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
@@ -463,6 +458,7 @@ files:
463
458
  - lib/bolt/config/transport/remote.rb
464
459
  - lib/bolt/config/transport/ssh.rb
465
460
  - lib/bolt/config/transport/winrm.rb
461
+ - lib/bolt/config/validator.rb
466
462
  - lib/bolt/error.rb
467
463
  - lib/bolt/executor.rb
468
464
  - lib/bolt/inventory.rb
@@ -506,19 +502,21 @@ files:
506
502
  - lib/bolt/pal/yaml_plan/step/task.rb
507
503
  - lib/bolt/pal/yaml_plan/step/upload.rb
508
504
  - lib/bolt/pal/yaml_plan/transpiler.rb
505
+ - lib/bolt/plan_creator.rb
509
506
  - lib/bolt/plan_result.rb
510
507
  - lib/bolt/plugin.rb
508
+ - lib/bolt/plugin/cache.rb
511
509
  - lib/bolt/plugin/env_var.rb
512
510
  - lib/bolt/plugin/module.rb
513
511
  - lib/bolt/plugin/prompt.rb
514
512
  - lib/bolt/plugin/puppetdb.rb
515
513
  - lib/bolt/plugin/task.rb
516
514
  - lib/bolt/project.rb
517
- - lib/bolt/project_migrator.rb
518
- - lib/bolt/project_migrator/base.rb
519
- - lib/bolt/project_migrator/config.rb
520
- - lib/bolt/project_migrator/inventory.rb
521
- - lib/bolt/project_migrator/modules.rb
515
+ - lib/bolt/project_manager.rb
516
+ - lib/bolt/project_manager/config_migrator.rb
517
+ - lib/bolt/project_manager/inventory_migrator.rb
518
+ - lib/bolt/project_manager/migrator.rb
519
+ - lib/bolt/project_manager/module_migrator.rb
522
520
  - lib/bolt/puppetdb.rb
523
521
  - lib/bolt/puppetdb/client.rb
524
522
  - lib/bolt/puppetdb/config.rb
@@ -554,15 +552,19 @@ files:
554
552
  - lib/bolt/util.rb
555
553
  - lib/bolt/util/puppet_log_level.rb
556
554
  - lib/bolt/version.rb
555
+ - lib/bolt/yarn.rb
557
556
  - lib/bolt_server/acl.rb
558
557
  - lib/bolt_server/base_config.rb
559
558
  - lib/bolt_server/config.rb
560
559
  - lib/bolt_server/file_cache.rb
560
+ - lib/bolt_server/plugin.rb
561
+ - lib/bolt_server/plugin/puppet_connect_data.rb
561
562
  - lib/bolt_server/schemas/action-check_node_connections.json
562
563
  - lib/bolt_server/schemas/action-run_command.json
563
564
  - lib/bolt_server/schemas/action-run_script.json
564
565
  - lib/bolt_server/schemas/action-run_task.json
565
566
  - lib/bolt_server/schemas/action-upload_file.json
567
+ - lib/bolt_server/schemas/connect-data.json
566
568
  - lib/bolt_server/schemas/partials/target-any.json
567
569
  - lib/bolt_server/schemas/partials/target-ssh.json
568
570
  - lib/bolt_server/schemas/partials/target-winrm.json
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bolt/project_migrator/config'
4
- require 'bolt/project_migrator/inventory'
5
- require 'bolt/project_migrator/modules'
6
-
7
- module Bolt
8
- class ProjectMigrator
9
- def initialize(config, outputter)
10
- @config = config
11
- @outputter = outputter
12
- end
13
-
14
- def migrate
15
- unless $stdin.tty?
16
- raise Bolt::Error.new(
17
- "stdin is not a tty, unable to migrate project",
18
- 'bolt/stdin-not-a-tty-error'
19
- )
20
- end
21
-
22
- @outputter.print_message("Migrating project #{@config.project.path}\n\n")
23
-
24
- @outputter.print_action_step(
25
- "Migrating a Bolt project may make irreversible changes to the project's "\
26
- "configuration and inventory files. Before continuing, make sure the "\
27
- "project has a backup or uses a version control system."
28
- )
29
-
30
- return 0 unless Bolt::Util.prompt_yes_no("Continue with project migration?", @outputter)
31
-
32
- @outputter.print_message('')
33
-
34
- ok = migrate_inventory && migrate_config && migrate_modules
35
-
36
- if ok
37
- @outputter.print_message("Project successfully migrated")
38
- else
39
- @outputter.print_error("Project could not be migrated completely")
40
- end
41
-
42
- ok ? 0 : 1
43
- end
44
-
45
- # Migrates the project-level configuration file to the latest version.
46
- #
47
- private def migrate_config
48
- migrator = Bolt::ProjectMigrator::Config.new(@outputter)
49
-
50
- migrator.migrate(
51
- @config.project.config_file,
52
- @config.project.project_file,
53
- @config.inventoryfile || @config.project.inventory_file,
54
- @config.project.backup_dir
55
- )
56
- end
57
-
58
- # Migrates the inventory file to the latest version.
59
- #
60
- private def migrate_inventory
61
- migrator = Bolt::ProjectMigrator::Inventory.new(@outputter)
62
-
63
- migrator.migrate(
64
- @config.inventoryfile || @config.project.inventory_file,
65
- @config.project.backup_dir
66
- )
67
- end
68
-
69
- # Migrates the project's modules to use current best practices.
70
- #
71
- private def migrate_modules
72
- migrator = Bolt::ProjectMigrator::Modules.new(@outputter)
73
-
74
- migrator.migrate(
75
- @config.project,
76
- @config.modulepath
77
- )
78
- end
79
- end
80
- end