bolt 1.30.1 → 1.31.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.

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: 1.30.1
4
+ version: 1.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-19 00:00:00.000000000 Z
11
+ date: 2019-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -372,6 +372,7 @@ files:
372
372
  - lib/bolt/inventory/group2.rb
373
373
  - lib/bolt/inventory/inventory2.rb
374
374
  - lib/bolt/logger.rb
375
+ - lib/bolt/module.rb
375
376
  - lib/bolt/node/errors.rb
376
377
  - lib/bolt/node/output.rb
377
378
  - lib/bolt/outputter.rb
@@ -396,8 +397,9 @@ files:
396
397
  - lib/bolt/pal/yaml_plan/transpiler.rb
397
398
  - lib/bolt/plan_result.rb
398
399
  - lib/bolt/plugin.rb
399
- - lib/bolt/plugin/aws.rb
400
+ - lib/bolt/plugin/aws_inventory.rb
400
401
  - lib/bolt/plugin/install_agent.rb
402
+ - lib/bolt/plugin/module.rb
401
403
  - lib/bolt/plugin/pkcs7.rb
402
404
  - lib/bolt/plugin/prompt.rb
403
405
  - lib/bolt/plugin/puppetdb.rb
@@ -416,6 +418,7 @@ files:
416
418
  - lib/bolt/target.rb
417
419
  - lib/bolt/task.rb
418
420
  - lib/bolt/task/puppet_server.rb
421
+ - lib/bolt/task/run.rb
419
422
  - lib/bolt/transport/base.rb
420
423
  - lib/bolt/transport/docker.rb
421
424
  - lib/bolt/transport/docker/connection.rb
@@ -443,6 +446,7 @@ files:
443
446
  - lib/bolt_server/file_cache.rb
444
447
  - lib/bolt_server/schemas/action-check_node_connections.json
445
448
  - lib/bolt_server/schemas/action-run_command.json
449
+ - lib/bolt_server/schemas/action-run_script.json
446
450
  - lib/bolt_server/schemas/action-run_task.json
447
451
  - lib/bolt_server/schemas/action-upload_file.json
448
452
  - lib/bolt_server/schemas/partials/target-any.json
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
-
5
- module Bolt
6
- class Plugin
7
- class Aws
8
- class EC2
9
- attr_accessor :client
10
- attr_reader :config
11
-
12
- def initialize(config)
13
- require 'aws-sdk-ec2'
14
- @config = config
15
- @logger = Logging.logger[self]
16
- end
17
-
18
- def name
19
- 'aws::ec2'
20
- end
21
-
22
- def hooks
23
- %w[inventory_targets]
24
- end
25
-
26
- def config_client(opts)
27
- return client if client
28
-
29
- options = {}
30
-
31
- if opts.key?('region')
32
- options[:region] = opts['region']
33
- end
34
- if opts.key?('profile')
35
- options[:profile] = opts['profile']
36
- end
37
- if config['credentials']
38
- creds = File.expand_path(config['credentials'])
39
- if File.exist?(creds)
40
- options[:credentials] = ::Aws::SharedCredentials.new(path: creds)
41
- else
42
- raise Bolt::ValidationError, "Cannot load credentials file #{config['credentials']}"
43
- end
44
- end
45
-
46
- ::Aws::EC2::Client.new(options)
47
- end
48
-
49
- def inventory_targets(opts)
50
- client = config_client(opts)
51
- resource = ::Aws::EC2::Resource.new(client: client)
52
-
53
- # Retrieve a list of EC2 instances and create a list of targets
54
- # Note: It doesn't seem possible to filter stubbed responses...
55
- resource.instances(filters: opts['filters']).map do |instance|
56
- next unless instance.state.name == 'running'
57
- target = {}
58
-
59
- if opts.key?('uri')
60
- uri = lookup(instance, opts['uri'])
61
- target['uri'] = uri if uri
62
- end
63
- if opts.key?('name')
64
- real_name = lookup(instance, opts['name'])
65
- target['name'] = real_name if real_name
66
- end
67
- if opts.key?('config')
68
- target['config'] = resolve_config(instance, opts['config'])
69
- end
70
-
71
- target if target['uri'] || target['name']
72
- end.compact
73
- end
74
-
75
- # Look for an instance attribute specified in the inventory file
76
- def lookup(instance, attribute)
77
- value = instance.data.respond_to?(attribute) ? instance.data[attribute] : nil
78
- unless value
79
- warn_missing_attribute(instance, attribute)
80
- end
81
- value
82
- end
83
-
84
- def warn_missing_attribute(instance, attribute)
85
- @logger.warn("Could not find attribute #{attribute} of instance #{instance.instance_id}")
86
- end
87
-
88
- # Walk the "template" config mapping provided in the plugin config and
89
- # replace all values with the corresponding value from the resource
90
- # parameters.
91
- def resolve_config(name, config_template)
92
- Bolt::Util.walk_vals(config_template) do |value|
93
- if value.is_a?(String)
94
- lookup(name, value)
95
- else
96
- value
97
- end
98
- end
99
- end
100
- end
101
- end
102
- end
103
- end