bolt 2.27.0 → 2.32.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +13 -12
  3. data/bolt-modules/boltlib/lib/puppet/functions/write_file.rb +2 -2
  4. data/bolt-modules/out/lib/puppet/functions/out/message.rb +44 -1
  5. data/bolt-modules/prompt/lib/puppet/functions/prompt.rb +3 -0
  6. data/guides/module.txt +19 -0
  7. data/guides/modulepath.txt +25 -0
  8. data/lib/bolt/applicator.rb +14 -14
  9. data/lib/bolt/bolt_option_parser.rb +74 -22
  10. data/lib/bolt/catalog.rb +1 -1
  11. data/lib/bolt/cli.rb +178 -127
  12. data/lib/bolt/config.rb +13 -1
  13. data/lib/bolt/config/modulepath.rb +30 -0
  14. data/lib/bolt/config/options.rb +38 -9
  15. data/lib/bolt/config/transport/options.rb +1 -1
  16. data/lib/bolt/executor.rb +1 -1
  17. data/lib/bolt/inventory.rb +11 -10
  18. data/lib/bolt/logger.rb +26 -19
  19. data/lib/bolt/module_installer.rb +197 -0
  20. data/lib/bolt/{puppetfile → module_installer}/installer.rb +3 -2
  21. data/lib/bolt/module_installer/puppetfile.rb +117 -0
  22. data/lib/bolt/module_installer/puppetfile/forge_module.rb +54 -0
  23. data/lib/bolt/module_installer/puppetfile/git_module.rb +37 -0
  24. data/lib/bolt/module_installer/puppetfile/module.rb +26 -0
  25. data/lib/bolt/module_installer/resolver.rb +76 -0
  26. data/lib/bolt/module_installer/specs.rb +93 -0
  27. data/lib/bolt/module_installer/specs/forge_spec.rb +84 -0
  28. data/lib/bolt/module_installer/specs/git_spec.rb +178 -0
  29. data/lib/bolt/outputter.rb +2 -45
  30. data/lib/bolt/outputter/human.rb +78 -18
  31. data/lib/bolt/outputter/json.rb +22 -7
  32. data/lib/bolt/outputter/logger.rb +2 -2
  33. data/lib/bolt/pal.rb +29 -25
  34. data/lib/bolt/plugin.rb +1 -1
  35. data/lib/bolt/plugin/module.rb +1 -1
  36. data/lib/bolt/project.rb +32 -22
  37. data/lib/bolt/project_migrator.rb +80 -0
  38. data/lib/bolt/project_migrator/base.rb +39 -0
  39. data/lib/bolt/project_migrator/config.rb +67 -0
  40. data/lib/bolt/project_migrator/inventory.rb +67 -0
  41. data/lib/bolt/project_migrator/modules.rb +200 -0
  42. data/lib/bolt/shell/bash.rb +4 -3
  43. data/lib/bolt/transport/base.rb +4 -4
  44. data/lib/bolt/transport/ssh/connection.rb +1 -1
  45. data/lib/bolt/util.rb +51 -10
  46. data/lib/bolt/version.rb +1 -1
  47. data/lib/bolt_server/acl.rb +2 -2
  48. data/lib/bolt_server/base_config.rb +3 -3
  49. data/lib/bolt_server/file_cache.rb +11 -11
  50. data/lib/bolt_server/schemas/partials/task.json +17 -2
  51. data/lib/bolt_server/transport_app.rb +93 -13
  52. data/lib/bolt_spec/bolt_context.rb +8 -6
  53. data/lib/bolt_spec/plans.rb +1 -1
  54. data/lib/bolt_spec/plans/mock_executor.rb +1 -1
  55. data/lib/bolt_spec/run.rb +1 -1
  56. metadata +30 -11
  57. data/lib/bolt/project_migrate.rb +0 -138
  58. data/lib/bolt/puppetfile.rb +0 -160
  59. data/lib/bolt/puppetfile/module.rb +0 -66
  60. data/lib/bolt_server/pe/pal.rb +0 -67
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bolt/error'
4
-
5
- # This class represents a module specification. It used by the Bolt::Puppetfile
6
- # class to have a consistent API for accessing a module's attributes.
7
- #
8
- module Bolt
9
- class Puppetfile
10
- class Module
11
- attr_reader :owner, :name, :version
12
-
13
- def initialize(owner, name, version = nil)
14
- @owner = owner
15
- @name = name
16
- @version = version
17
- end
18
-
19
- # Creates a new module from a hash.
20
- #
21
- def self.from_hash(mod)
22
- unless mod['name'].is_a?(String)
23
- raise Bolt::ValidationError,
24
- "Module name must be a String, not #{mod['name'].inspect}"
25
- end
26
-
27
- owner, name = mod['name'].tr('/', '-').split('-', 2)
28
-
29
- unless owner && name
30
- raise Bolt::ValidationError, "Module name #{mod['name']} must include both the owner and module name."
31
- end
32
-
33
- new(owner, name)
34
- end
35
-
36
- # Returns the module's title.
37
- #
38
- def title
39
- "#{@owner}-#{@name}"
40
- end
41
-
42
- # Checks two modules for equality.
43
- #
44
- def eql?(other)
45
- self.class == other.class && @owner == other.owner && @name == other.name
46
- end
47
- alias == eql?
48
-
49
- # Hashes the module.
50
- #
51
- def hash
52
- [@owner, @name].hash
53
- end
54
-
55
- # Returns the Puppetfile specification for the module.
56
- #
57
- def to_spec
58
- if @version
59
- "mod #{title.inspect}, #{@version.inspect}"
60
- else
61
- "mod #{title.inspect}"
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bolt/pal'
4
- require 'bolt/util'
5
-
6
- module BoltServer
7
- module PE
8
- class PAL < Bolt::PAL
9
- # PE_BOLTLIB_PATH is intended to function exactly like the BOLTLIB_PATH used
10
- # in Bolt::PAL. Paths and variable names are similar to what exists in
11
- # Bolt::PAL, but with a 'PE' prefix.
12
- PE_BOLTLIB_PATH = '/opt/puppetlabs/server/apps/bolt-server/pe-bolt-modules'
13
-
14
- # For now at least, we maintain an entirely separate codedir from
15
- # puppetserver by default, so that filesync can work properly. If filesync
16
- # is not used, this can instead match the usual puppetserver codedir.
17
- # See the `orchestrator.bolt.codedir` tk config setting.
18
- DEFAULT_BOLT_CODEDIR = '/opt/puppetlabs/server/data/orchestration-services/code'
19
-
20
- # This function is nearly identical to Bolt::Pal's `with_puppet_settings` with the
21
- # one difference that we set the codedir to point to actual code, rather than the
22
- # tmpdir. We only use this funtion inside the PEBolt::PAL initializer so that Puppet
23
- # is correctly configured to pull environment configuration correctly. If we don't
24
- # set codedir in this way: when we try to load and interpolate the modulepath it
25
- # won't correctly load.
26
- def with_pe_pal_init_settings(codedir, environmentpath, basemodulepath)
27
- Dir.mktmpdir('pe-bolt') do |dir|
28
- cli = []
29
- Puppet::Settings::REQUIRED_APP_SETTINGS.each do |setting|
30
- dir = setting == :codedir ? codedir : dir
31
- cli << "--#{setting}" << dir
32
- end
33
- cli << "--environmentpath" << environmentpath
34
- cli << "--basemodulepath" << basemodulepath
35
- Puppet.settings.send(:clear_everything_for_tests)
36
- Puppet.initialize_settings(cli)
37
- yield
38
- # Ensure the puppet settings go back to what bolt expects after
39
- # we finish with the settings we need for PEBolt::PAL init.
40
- with_puppet_settings { |_| nil }
41
- end
42
- end
43
-
44
- def initialize(plan_executor_config, environment_name, hiera_config = nil, max_compiles = nil)
45
- # Bolt::PAL#initialize takes the modulepath as its first argument, but we
46
- # want to customize it later, so we pass an empty value:
47
- super([], hiera_config, max_compiles)
48
-
49
- codedir = plan_executor_config['codedir'] || DEFAULT_BOLT_CODEDIR
50
- environmentpath = plan_executor_config['environmentpath'] || "#{codedir}/environments"
51
- basemodulepath = plan_executor_config['basemodulepath'] || "#{codedir}/modules:/opt/puppetlabs/puppet/modules"
52
-
53
- with_pe_pal_init_settings(codedir, environmentpath, basemodulepath) do
54
- environment = Puppet.lookup(:environments).get!(environment_name)
55
- # A new modulepath is created from scratch (rather than using super's @modulepath)
56
- # so that we can have full control over all the entries in modulepath. In the future
57
- # it's likely we will need to preceed _both_ Bolt::PAL::BOLTLIB_PATH _and_
58
- # Bolt::PAL::MODULES_PATH which would be more complex if we tried to use @modulepath since
59
- # we need to append our modulepaths and exclude modules shiped in bolt gem code
60
- modulepath_dirs = environment.modulepath
61
- @user_modulepath = modulepath_dirs
62
- @modulepath = [PE_BOLTLIB_PATH, Bolt::PAL::BOLTLIB_PATH, *modulepath_dirs]
63
- end
64
- end
65
- end
66
- end
67
- end