bolt 2.25.0 → 2.30.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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +4 -3
  3. data/bolt-modules/boltlib/lib/puppet/datatypes/result.rb +2 -1
  4. data/bolt-modules/boltlib/lib/puppet/functions/download_file.rb +1 -1
  5. data/bolt-modules/dir/lib/puppet/functions/dir/children.rb +1 -1
  6. data/lib/bolt/analytics.rb +7 -3
  7. data/lib/bolt/applicator.rb +21 -21
  8. data/lib/bolt/bolt_option_parser.rb +116 -26
  9. data/lib/bolt/catalog.rb +5 -3
  10. data/lib/bolt/cli.rb +194 -185
  11. data/lib/bolt/config.rb +61 -26
  12. data/lib/bolt/config/options.rb +35 -2
  13. data/lib/bolt/executor.rb +2 -2
  14. data/lib/bolt/inventory.rb +8 -1
  15. data/lib/bolt/inventory/group.rb +1 -1
  16. data/lib/bolt/inventory/inventory.rb +1 -1
  17. data/lib/bolt/inventory/target.rb +1 -1
  18. data/lib/bolt/logger.rb +35 -21
  19. data/lib/bolt/module_installer.rb +172 -0
  20. data/lib/bolt/outputter.rb +4 -0
  21. data/lib/bolt/outputter/human.rb +53 -11
  22. data/lib/bolt/outputter/json.rb +7 -1
  23. data/lib/bolt/outputter/logger.rb +3 -3
  24. data/lib/bolt/pal.rb +29 -20
  25. data/lib/bolt/pal/yaml_plan/evaluator.rb +1 -1
  26. data/lib/bolt/plugin/module.rb +1 -1
  27. data/lib/bolt/plugin/puppetdb.rb +1 -1
  28. data/lib/bolt/project.rb +89 -28
  29. data/lib/bolt/project_migrator.rb +80 -0
  30. data/lib/bolt/project_migrator/base.rb +39 -0
  31. data/lib/bolt/project_migrator/config.rb +67 -0
  32. data/lib/bolt/project_migrator/inventory.rb +67 -0
  33. data/lib/bolt/project_migrator/modules.rb +198 -0
  34. data/lib/bolt/puppetdb/client.rb +1 -1
  35. data/lib/bolt/puppetdb/config.rb +1 -1
  36. data/lib/bolt/puppetfile.rb +142 -0
  37. data/lib/bolt/puppetfile/installer.rb +43 -0
  38. data/lib/bolt/puppetfile/module.rb +90 -0
  39. data/lib/bolt/r10k_log_proxy.rb +1 -1
  40. data/lib/bolt/rerun.rb +2 -2
  41. data/lib/bolt/result.rb +23 -0
  42. data/lib/bolt/shell.rb +1 -1
  43. data/lib/bolt/shell/bash.rb +1 -1
  44. data/lib/bolt/task.rb +1 -1
  45. data/lib/bolt/transport/base.rb +5 -5
  46. data/lib/bolt/transport/docker/connection.rb +1 -1
  47. data/lib/bolt/transport/local/connection.rb +1 -1
  48. data/lib/bolt/transport/ssh.rb +1 -1
  49. data/lib/bolt/transport/ssh/connection.rb +1 -1
  50. data/lib/bolt/transport/ssh/exec_connection.rb +1 -1
  51. data/lib/bolt/transport/winrm.rb +1 -1
  52. data/lib/bolt/transport/winrm/connection.rb +1 -1
  53. data/lib/bolt/util.rb +52 -11
  54. data/lib/bolt/version.rb +1 -1
  55. data/lib/bolt_server/acl.rb +2 -2
  56. data/lib/bolt_server/base_config.rb +3 -3
  57. data/lib/bolt_server/config.rb +1 -1
  58. data/lib/bolt_server/file_cache.rb +12 -12
  59. data/lib/bolt_server/transport_app.rb +125 -26
  60. data/lib/bolt_spec/bolt_context.rb +4 -4
  61. data/lib/bolt_spec/plans/mock_executor.rb +1 -1
  62. metadata +15 -13
  63. data/lib/bolt/project_migrate.rb +0 -138
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.25.0
4
+ version: 2.30.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-08-26 00:00:00.000000000 Z
11
+ date: 2020-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -182,20 +182,14 @@ dependencies:
182
182
  name: puppet
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: 6.16.0
188
- - - "<"
185
+ - - '='
189
186
  - !ruby/object:Gem::Version
190
187
  version: 6.18.0
191
188
  type: :runtime
192
189
  prerelease: false
193
190
  version_requirements: !ruby/object:Gem::Requirement
194
191
  requirements:
195
- - - ">="
196
- - !ruby/object:Gem::Version
197
- version: 6.16.0
198
- - - "<"
192
+ - - '='
199
193
  - !ruby/object:Gem::Version
200
194
  version: 6.18.0
201
195
  - !ruby/object:Gem::Dependency
@@ -204,14 +198,14 @@ dependencies:
204
198
  requirements:
205
199
  - - "~>"
206
200
  - !ruby/object:Gem::Version
207
- version: 0.1.0
201
+ version: '0.4'
208
202
  type: :runtime
209
203
  prerelease: false
210
204
  version_requirements: !ruby/object:Gem::Requirement
211
205
  requirements:
212
206
  - - "~>"
213
207
  - !ruby/object:Gem::Version
214
- version: 0.1.0
208
+ version: '0.4'
215
209
  - !ruby/object:Gem::Dependency
216
210
  name: puppet-resource_api
217
211
  requirement: !ruby/object:Gem::Requirement
@@ -467,6 +461,7 @@ files:
467
461
  - lib/bolt/inventory/target.rb
468
462
  - lib/bolt/logger.rb
469
463
  - lib/bolt/module.rb
464
+ - lib/bolt/module_installer.rb
470
465
  - lib/bolt/node/errors.rb
471
466
  - lib/bolt/node/output.rb
472
467
  - lib/bolt/outputter.rb
@@ -500,10 +495,17 @@ files:
500
495
  - lib/bolt/plugin/puppetdb.rb
501
496
  - lib/bolt/plugin/task.rb
502
497
  - lib/bolt/project.rb
503
- - lib/bolt/project_migrate.rb
498
+ - lib/bolt/project_migrator.rb
499
+ - lib/bolt/project_migrator/base.rb
500
+ - lib/bolt/project_migrator/config.rb
501
+ - lib/bolt/project_migrator/inventory.rb
502
+ - lib/bolt/project_migrator/modules.rb
504
503
  - lib/bolt/puppetdb.rb
505
504
  - lib/bolt/puppetdb/client.rb
506
505
  - lib/bolt/puppetdb/config.rb
506
+ - lib/bolt/puppetfile.rb
507
+ - lib/bolt/puppetfile/installer.rb
508
+ - lib/bolt/puppetfile/module.rb
507
509
  - lib/bolt/r10k_log_proxy.rb
508
510
  - lib/bolt/rerun.rb
509
511
  - lib/bolt/resource_instance.rb
@@ -1,138 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bolt
4
- class ProjectMigrate
5
- attr_reader :path, :project_file, :backup_dir, :outputter, :inventory_file, :config_file
6
-
7
- # This init mostly makes testing easier
8
- def initialize(path, outputter, configured_inventory = nil)
9
- @path = Pathname.new(path).expand_path
10
- @project_file = @path + 'bolt-project.yaml'
11
- @config_file = @path + 'bolt.yaml'
12
- @backup_dir = @path + '.bolt-bak'
13
- @inventory_file = configured_inventory || @path + 'inventory.yaml'
14
- @outputter = outputter
15
- end
16
-
17
- def migrate_project
18
- inv_ok = inventory_1_to_2(inventory_file, outputter) if inventory_file.file?
19
- config_ok = bolt_yaml_to_bolt_project(inventory_file, outputter)
20
- inv_ok && config_ok ? 0 : 1
21
- end
22
-
23
- # This could be made public and used elsewhere if the need arises
24
- private def backup_file(origin_path)
25
- unless File.exist?(origin_path)
26
- outputter.print_message "Could not find file #{origin_path}, skipping backup."
27
- return
28
- end
29
-
30
- date = Time.new.strftime("%Y%m%d_%H%M%S%L")
31
- FileUtils.mkdir_p(backup_dir)
32
-
33
- filename = File.basename(origin_path)
34
- backup_path = File.join(backup_dir, "#{filename}.#{date}.bak")
35
-
36
- outputter.print_message "Backing up #{filename} from #{origin_path} to #{backup_path}"
37
-
38
- begin
39
- FileUtils.cp(origin_path, backup_path)
40
- rescue StandardError => e
41
- raise Bolt::FileError.new("#{e.message}; unable to create backup of #{filename}.", origin_path)
42
- end
43
- end
44
-
45
- private def bolt_yaml_to_bolt_project(inventory_file, outputter)
46
- # If bolt-project.yaml already exists
47
- if project_file.file?
48
- outputter.print_message "bolt-project.yaml already exists in Bolt "\
49
- "project at #{path}. Skipping project file update."
50
-
51
- # If bolt.yaml doesn't exist
52
- elsif !config_file.file?
53
- outputter.print_message "Could not find bolt.yaml in project at "\
54
- "#{path}. Skipping project file update."
55
-
56
- else
57
- config_data = Bolt::Util.read_optional_yaml_hash(config_file, 'config')
58
- transport_data, project_data = config_data.partition do |k, _|
59
- Bolt::Config::INVENTORY_OPTIONS.keys.include?(k)
60
- end.map(&:to_h)
61
-
62
- if transport_data.any?
63
- if File.exist?(inventory_file)
64
- inventory_data = Bolt::Util.read_yaml_hash(inventory_file, 'inventory')
65
- merged = Bolt::Util.deep_merge(transport_data, inventory_data['config'] || {})
66
- inventory_data['config'] = merged
67
- backup_file(inventory_file)
68
- else
69
- FileUtils.touch(inventory_file)
70
- inventory_data = { 'config' => transport_data }
71
- end
72
-
73
- backup_file(config_file)
74
-
75
- begin
76
- outputter.print_message "Moving transportation configuration options "\
77
- "'#{transport_data.keys.join(', ')}' from bolt.yaml to inventory.yaml"
78
- File.write(inventory_file, inventory_data.to_yaml)
79
- File.write(config_file, project_data.to_yaml)
80
- rescue StandardError => e
81
- raise Bolt::FileError.new("#{e.message}; unable to write inventory.", inventory_file)
82
- end
83
- end
84
-
85
- outputter.print_message "Renaming bolt.yaml to bolt-project.yaml"
86
- FileUtils.mv(config_file, project_file)
87
- outputter.print_message "Successfully updated project. Please add a "\
88
- "'name' key to bolt-project.yaml to use project-level tasks and plans. "\
89
- "Learn more about projects by running 'bolt guide project'."
90
- # If nothing errored, this succeeded
91
- true
92
- end
93
- end
94
-
95
- private def inventory_1_to_2(inventory_file, outputter)
96
- data = Bolt::Util.read_yaml_hash(inventory_file, 'inventory')
97
- data.delete('version') if data['version'] != 2
98
- migrated = migrate_group(data)
99
-
100
- ok = if migrated
101
- backup_file(inventory_file)
102
- File.write(inventory_file, data.to_yaml)
103
- end
104
-
105
- result = if migrated && ok
106
- "Successfully migrated Bolt inventory to the latest version."
107
- elsif !migrated
108
- "Bolt inventory is already on the latest version. Skipping inventory update."
109
- else
110
- "Could not migrate Bolt inventory to the latest version. See "\
111
- "https://puppet.com/docs/bolt/latest/inventory_file_v2.html to manually update."
112
- end
113
- outputter.print_message(result)
114
- ok
115
- end
116
-
117
- # Walks an inventory hash and replaces all 'nodes' keys with 'targets' keys
118
- # and all 'name' keys nested in a 'targets' hash with 'uri' keys. Data is
119
- # modified in place.
120
- private def migrate_group(group)
121
- migrated = false
122
- if group.key?('nodes')
123
- migrated = true
124
- targets = group['nodes'].map do |target|
125
- target['uri'] = target.delete('name') if target.is_a?(Hash)
126
- target
127
- end
128
- group.delete('nodes')
129
- group['targets'] = targets
130
- end
131
- (group['groups'] || []).each do |subgroup|
132
- migrated_group = migrate_group(subgroup)
133
- migrated ||= migrated_group
134
- end
135
- migrated
136
- end
137
- end
138
- end