bolt 0.25.0 → 1.0.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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e5ae133bdd2f4e2a8d0c8b0660c0f80d3f4187efd005ccdeb02694775c9f8af
4
- data.tar.gz: 870bb25eeaaefb615d637767909ff607550a12d572a8360ae9f8a386dd86d11e
3
+ metadata.gz: 1e8d1a8d37a48ddf246cd058bbe4b071732c000c90592da48aac5ed7285143cf
4
+ data.tar.gz: 9c1aeade908ced86c6d6b6f3e459949c438e0831e4dfc2401daaca6124663077
5
5
  SHA512:
6
- metadata.gz: fb2090aac1cab95bbffa72ca1bb99af214ed910512e5fd19878b9d832518e2ee56df623c1ad74c41b160fc129bc7cf2904a876b267d2dfe8c2391fecdd941468
7
- data.tar.gz: ff0d54e1b27bfcf35b3d78e6f4e9d95d5b470abf5aa2311acc85459a54bb9a8746a103633fb24bc55520406ac7eeba863ada6023185e6f0f8a9e1a36fe206b4e
6
+ metadata.gz: e060cf1af91bfe4f3f6ea97d83e38fd4ed5a65a2fdc1e3d1af28337bb59835fa2fba62cc34d98d7000c37426f5ea76b83e7bd2d540f48c09a40aef8f37cdf202
7
+ data.tar.gz: d01e9efae28d08b0dffaab1bd6ca6b2679c01b7f390473a09557f61118a957d909f509e0aa480999bc0b8df3dced6b00bea2806ad6a89fb9f1d8bd5ccf0c4e5c
@@ -98,9 +98,8 @@ Puppet::Functions.create_function(:run_task) do
98
98
 
99
99
  options['_description'] = description if description
100
100
 
101
- # Don't bother loading the local task definition if all targets use the 'pcp' transport
102
- # and the local-validation option is set to false for all of them
103
- if !targets.empty? && targets.all? { |t| t.protocol == 'pcp' && t.options['local-validation'] == false }
101
+ # Don't bother loading the local task definition if all targets use the 'pcp' transport.
102
+ if !targets.empty? && targets.all? { |t| t.protocol == 'pcp' }
104
103
  # create a fake task
105
104
  task = Bolt::Task.new(name: task_name, files: [{ 'name' => '', 'path' => '' }])
106
105
  else
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Note this file includes very few 'requires' because it expects to be used from the CLI.
4
+
3
5
  require 'optparse'
4
6
 
5
7
  module Bolt
data/lib/bolt/catalog.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'bolt/config'
4
+ require 'bolt/inventory'
3
5
  require 'bolt/pal'
4
6
  require 'bolt/puppetdb'
7
+ require 'bolt/util'
5
8
 
6
9
  Bolt::PAL.load_puppet
7
10
 
@@ -53,6 +56,7 @@ module Bolt
53
56
  pal_main = request['code_ast'] || request['code_string']
54
57
  target = request['target']
55
58
  pdb_client = Bolt::PuppetDB::Client.new(Bolt::PuppetDB::Config.new(request['pdb_config']))
59
+ options = request['puppet_config'] || {}
56
60
 
57
61
  with_puppet_settings(request['hiera_config']) do
58
62
  Puppet[:rich_data] = true
@@ -65,6 +69,10 @@ module Bolt
65
69
  bolt_inventory: setup_inventory(request['inventory'])) do
66
70
  Puppet.lookup(:pal_current_node).trusted_data = target['trusted']
67
71
  pal.with_catalog_compiler do |compiler|
72
+ # Configure language strictness in the CatalogCompiler. We want Bolt to be able
73
+ # to compile most Puppet 4+ manifests, so we default to allowing deprecated functions.
74
+ Puppet[:strict] = options['strict'] || :warning
75
+ Puppet[:strict_variables] = options['strict_variables'] || false
68
76
  ast = Puppet::Pops::Serialization::FromDataConverter.convert(pal_main)
69
77
  compiler.evaluate(ast)
70
78
  compiler.compile_additions
data/lib/bolt/cli.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Avoid requiring the CLI from other files. It has side-effects - such as loading r10k -
4
+ # that are undesirable when using Bolt as a library.
5
+
3
6
  require 'uri'
4
7
  require 'benchmark'
5
8
  require 'json'
data/lib/bolt/config.rb CHANGED
@@ -5,7 +5,6 @@ require 'logging'
5
5
  require 'concurrent'
6
6
  require 'pathname'
7
7
  require 'bolt/boltdir'
8
- require 'bolt/cli'
9
8
  require 'bolt/transport/ssh'
10
9
  require 'bolt/transport/winrm'
11
10
  require 'bolt/transport/orch'
@@ -49,8 +48,7 @@ module Bolt
49
48
  'ssl-verify' => true
50
49
  },
51
50
  pcp: {
52
- 'task-environment' => 'production',
53
- 'local-validation' => false
51
+ 'task-environment' => 'production'
54
52
  },
55
53
  local: {}
56
54
  }.freeze
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'set'
4
- require 'bolt/util'
5
- require 'bolt/target'
4
+ require 'bolt/config'
6
5
  require 'bolt/inventory/group'
6
+ require 'bolt/target'
7
+ require 'bolt/util'
7
8
 
8
9
  module Bolt
9
10
  class Inventory
@@ -59,14 +59,6 @@ module Bolt
59
59
  value
60
60
  end
61
61
 
62
- def check_deprecated_config(context, name, config)
63
- if config && config['transports']
64
- msg = "#{context} #{name} contains invalid config option 'transports', see " \
65
- "https://puppet.com/docs/bolt/0.x/inventory_file.html for the updated format"
66
- raise ValidationError.new(msg, @name)
67
- end
68
- end
69
-
70
62
  def validate(used_names = Set.new, node_names = Set.new, depth = 0)
71
63
  if used_names.include?(@name)
72
64
  raise ValidationError.new("Tried to redefine group #{@name}", @name)
@@ -77,8 +69,6 @@ module Bolt
77
69
  raise ValidationError.new("Group #{@name} conflicts with node of the same name", @name)
78
70
  end
79
71
 
80
- check_deprecated_config('Group', @name, @config)
81
-
82
72
  used_names << @name
83
73
 
84
74
  @nodes.each_value do |n|
@@ -95,8 +85,6 @@ module Bolt
95
85
  raise ValidationError.new("Group #{n['name']} conflicts with node of the same name", n['name'])
96
86
  end
97
87
 
98
- check_deprecated_config('Node', n['name'], n['config'])
99
-
100
88
  node_names << n['name']
101
89
  end
102
90
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logging'
4
+ require 'bolt/result'
4
5
 
5
6
  module Bolt
6
7
  module Transport
@@ -4,7 +4,6 @@ require 'json'
4
4
  require 'fileutils'
5
5
  require 'tmpdir'
6
6
  require 'bolt/transport/base'
7
- require 'bolt/result'
8
7
  require 'bolt/util'
9
8
 
10
9
  module Bolt
@@ -6,7 +6,6 @@ require 'json'
6
6
  require 'orchestrator_client'
7
7
  require 'bolt/transport/base'
8
8
  require 'bolt/transport/orch/connection'
9
- require 'bolt/result'
10
9
 
11
10
  module Bolt
12
11
  module Transport
@@ -23,17 +22,12 @@ module Bolt
23
22
  attr_writer :plan_context
24
23
 
25
24
  def self.options
26
- %w[service-url cacert token-file task-environment local-validation]
25
+ %w[service-url cacert token-file task-environment]
27
26
  end
28
27
 
29
28
  PROVIDED_FEATURES = ['puppet-agent'].freeze
30
29
 
31
- def self.validate(options)
32
- validation_flag = options['local-validation']
33
- unless !!validation_flag == validation_flag
34
- raise Bolt::ValidationError, 'local-validation option must be a Boolean true or false'
35
- end
36
- end
30
+ def self.validate(options); end
37
31
 
38
32
  def initialize(*args)
39
33
  @connections = {}
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'bolt/node/errors'
3
4
  require 'bolt/transport/base'
4
5
 
5
6
  module Bolt
data/lib/bolt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bolt
4
- VERSION = '0.25.0'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'bolt_spec/plans/mock_executor'
4
4
  require 'bolt/config'
5
+ require 'bolt/inventory'
6
+ require 'bolt/pal'
5
7
 
6
8
  # These helpers are intended to be used for plan unit testing without calling
7
9
  # out to target nodes. It accomplishes this by replacing bolt's executor with a
data/lib/bolt_spec/run.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # shorthand for requiring the parts of bolt we need
4
- require 'bolt/cli'
3
+ require 'bolt/analytics'
4
+ require 'bolt/config'
5
+ require 'bolt/executor'
6
+ require 'bolt/inventory'
7
+ require 'bolt/pal'
8
+ require 'bolt/puppetdb'
5
9
  require 'bolt/util'
6
10
 
7
11
  # This is intended to provide a relatively stable method of executing bolt in process from tests.
@@ -8,37 +8,29 @@ require 'tempfile'
8
8
 
9
9
  args = JSON.parse(STDIN.read)
10
10
 
11
- Dir.mktmpdir do |moduledir|
11
+ Dir.mktmpdir do |puppet_root|
12
+ # Create temporary directories for all core Puppet settings so we don't clobber
13
+ # existing state or read from puppet.conf. Also create a temporary modulepath.
14
+ moduledir = File.join(puppet_root, 'modules')
15
+ Dir.mkdir(moduledir)
16
+ cli = Puppet::Settings::REQUIRED_APP_SETTINGS.flat_map do |setting|
17
+ ["--#{setting}", File.join(puppet_root, setting.to_s.chomp('dir'))]
18
+ end
19
+ cli << '--modulepath' << moduledir
20
+ Puppet.initialize_settings(cli)
21
+
12
22
  Tempfile.open('plugins.tar.gz') do |plugins|
13
23
  File.binwrite(plugins, Base64.decode64(args['plugins']))
14
24
  Puppet::ModuleTool::Tar.instance.unpack(plugins, moduledir, Etc.getlogin || Etc.getpwuid.name)
15
25
  end
16
26
 
17
- Puppet.initialize_settings
18
- env = Puppet.lookup(:environments).get('production').override_with(modulepath: [moduledir])
27
+ env = Puppet.lookup(:environments).get('production')
19
28
  env.each_plugin_directory do |dir|
20
29
  $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
21
30
  end
22
31
 
23
- dirs = []
24
- external_dirs = []
25
- env.modules.each do |mod|
26
- dirs << File.join(mod.plugins, 'facter') if mod.plugins?
27
- external_dirs << mod.pluginfacts if mod.pluginfacts?
28
- end
29
-
30
- Facter.reset
31
- Facter.search(*dirs) unless dirs.empty?
32
- Facter.search_external(external_dirs)
33
-
34
- if Puppet.respond_to? :initialize_facts
35
- Puppet.initialize_facts
36
- else
37
- Facter.add(:puppetversion) do
38
- setcode { Puppet.version.to_s }
39
- end
40
- end
41
-
42
- puts(Facter.to_hash.to_json)
32
+ facts = Puppet::Node::Facts.indirection.find(SecureRandom.uuid, environment: env)
33
+ puts(facts.values.to_json)
43
34
  end
35
+
44
36
  exit 0
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: 0.25.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-04 00:00:00.000000000 Z
11
+ date: 2018-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -258,7 +258,6 @@ files:
258
258
  - bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb
259
259
  - bolt-modules/boltlib/lib/puppet/functions/facts.rb
260
260
  - bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
261
- - bolt-modules/boltlib/lib/puppet/functions/file_upload.rb
262
261
  - bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
263
262
  - bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
264
263
  - bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This function wraps the upload_file function with a deprecation warning, for backward compatibility.
4
- Puppet::Functions.create_function(:file_upload, Puppet::Functions::InternalFunction) do
5
- def file_upload(*args)
6
- executor = Puppet.lookup(:bolt_executor) { nil }
7
- executor&.report_function_call('file_upload')
8
-
9
- file, line = Puppet::Pops::PuppetStack.top_of_stack
10
-
11
- msg = "The file_upload function is deprecated and will be removed; use upload_file instead"
12
- Puppet.puppet_deprecation_warning(msg, key: 'bolt-function/file_upload', file: file, line: line)
13
-
14
- call_function('upload_file', *args)
15
- end
16
- end