bolt 2.15.0 → 2.20.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 +4 -4
- data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/add_to_group.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +20 -9
- data/bolt-modules/boltlib/lib/puppet/functions/catch_errors.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/download_file.rb +123 -0
- data/bolt-modules/boltlib/lib/puppet/functions/facts.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_resources.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_target.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_targets.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/resource.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +3 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +2 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +7 -4
- data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +2 -1
- data/bolt-modules/boltlib/lib/puppet/functions/set_config.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_resources.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_var.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/vars.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/write_file.rb +1 -0
- data/bolt-modules/ctrl/lib/puppet/functions/ctrl/do_until.rb +2 -0
- data/bolt-modules/ctrl/lib/puppet/functions/ctrl/sleep.rb +2 -0
- data/bolt-modules/file/lib/puppet/functions/file/exists.rb +1 -0
- data/bolt-modules/file/lib/puppet/functions/file/join.rb +2 -0
- data/bolt-modules/file/lib/puppet/functions/file/read.rb +2 -0
- data/bolt-modules/file/lib/puppet/functions/file/readable.rb +2 -0
- data/bolt-modules/file/lib/puppet/functions/file/write.rb +2 -0
- data/bolt-modules/out/lib/puppet/functions/out/message.rb +2 -0
- data/bolt-modules/prompt/lib/puppet/functions/prompt.rb +1 -0
- data/bolt-modules/system/lib/puppet/functions/system/env.rb +2 -0
- data/lib/bolt/applicator.rb +21 -15
- data/lib/bolt/apply_result.rb +1 -1
- data/lib/bolt/bolt_option_parser.rb +55 -20
- data/lib/bolt/catalog.rb +3 -2
- data/lib/bolt/cli.rb +116 -47
- data/lib/bolt/config.rb +48 -148
- data/lib/bolt/config/options.rb +488 -0
- data/lib/bolt/config/transport/base.rb +16 -16
- data/lib/bolt/config/transport/docker.rb +9 -23
- data/lib/bolt/config/transport/local.rb +6 -44
- data/lib/bolt/config/transport/options.rb +460 -0
- data/lib/bolt/config/transport/orch.rb +9 -18
- data/lib/bolt/config/transport/remote.rb +3 -6
- data/lib/bolt/config/transport/ssh.rb +74 -154
- data/lib/bolt/config/transport/winrm.rb +18 -47
- data/lib/bolt/executor.rb +15 -0
- data/lib/bolt/inventory/group.rb +4 -3
- data/lib/bolt/inventory/inventory.rb +4 -17
- data/lib/bolt/inventory/target.rb +18 -5
- data/lib/bolt/logger.rb +24 -1
- data/lib/bolt/outputter.rb +1 -1
- data/lib/bolt/outputter/rainbow.rb +14 -3
- data/lib/bolt/pal.rb +31 -11
- data/lib/bolt/pal/yaml_plan/evaluator.rb +19 -2
- data/lib/bolt/pal/yaml_plan/step.rb +11 -2
- data/lib/bolt/pal/yaml_plan/step/download.rb +38 -0
- data/lib/bolt/pal/yaml_plan/step/upload.rb +3 -3
- data/lib/bolt/plugin/module.rb +2 -4
- data/lib/bolt/plugin/puppetdb.rb +3 -2
- data/lib/bolt/project.rb +41 -44
- data/lib/bolt/puppetdb/client.rb +2 -0
- data/lib/bolt/puppetdb/config.rb +16 -0
- data/lib/bolt/result.rb +7 -0
- data/lib/bolt/shell/bash.rb +53 -45
- data/lib/bolt/shell/powershell.rb +23 -12
- data/lib/bolt/shell/powershell/snippets.rb +15 -6
- data/lib/bolt/transport/base.rb +24 -0
- data/lib/bolt/transport/docker.rb +17 -5
- data/lib/bolt/transport/docker/connection.rb +20 -2
- data/lib/bolt/transport/local/connection.rb +14 -1
- data/lib/bolt/transport/orch.rb +20 -0
- data/lib/bolt/transport/simple.rb +6 -0
- data/lib/bolt/transport/ssh.rb +7 -1
- data/lib/bolt/transport/ssh/connection.rb +9 -1
- data/lib/bolt/transport/ssh/exec_connection.rb +23 -2
- data/lib/bolt/transport/winrm/connection.rb +109 -8
- data/lib/bolt/util.rb +26 -11
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/transport_app.rb +3 -2
- data/lib/bolt_spec/bolt_context.rb +7 -2
- data/lib/bolt_spec/plans.rb +15 -2
- data/lib/bolt_spec/plans/action_stubs.rb +2 -1
- data/lib/bolt_spec/plans/action_stubs/download_stub.rb +66 -0
- data/lib/bolt_spec/plans/mock_executor.rb +14 -1
- data/lib/bolt_spec/run.rb +22 -0
- data/libexec/bolt_catalog +3 -2
- metadata +20 -29
@@ -7,24 +7,15 @@ module Bolt
|
|
7
7
|
class Config
|
8
8
|
module Transport
|
9
9
|
class Orch < Base
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
"job-poll-timeout" => { type: Integer,
|
20
|
-
desc: "Set time to wait for orchestrator job status." },
|
21
|
-
"service-url" => { type: String,
|
22
|
-
desc: "The URL of the orchestrator API." },
|
23
|
-
"task-environment" => { type: String,
|
24
|
-
desc: "The environment the orchestrator loads task code from." },
|
25
|
-
"token-file" => { type: String,
|
26
|
-
desc: "The path to the token file." }
|
27
|
-
}.freeze
|
10
|
+
OPTIONS = %w[
|
11
|
+
cacert
|
12
|
+
host
|
13
|
+
job-poll-interval
|
14
|
+
job-poll-timeout
|
15
|
+
service-url
|
16
|
+
task-environment
|
17
|
+
token-file
|
18
|
+
].freeze
|
28
19
|
|
29
20
|
DEFAULTS = {
|
30
21
|
"task-environment" => "production"
|
@@ -7,12 +7,9 @@ module Bolt
|
|
7
7
|
class Config
|
8
8
|
module Transport
|
9
9
|
class Remote < Base
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
"run-on" => { type: String,
|
14
|
-
desc: "The proxy target that the task executes on." }
|
15
|
-
}.freeze
|
10
|
+
OPTIONS = %w[
|
11
|
+
run-on
|
12
|
+
].freeze
|
16
13
|
|
17
14
|
DEFAULTS = {
|
18
15
|
"run-on" => "localhost"
|
@@ -7,148 +7,82 @@ module Bolt
|
|
7
7
|
class Config
|
8
8
|
module Transport
|
9
9
|
class SSH < Base
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
"All supported, non-deprecated algorithms are available by default when "\
|
51
|
-
"this option is not used. To reference all default algorithms "\
|
52
|
-
"using this option, add 'defaults' to the list of supported "\
|
53
|
-
"algorithms." },
|
54
|
-
"host-key-check" => { type: TrueClass,
|
55
|
-
external: true,
|
56
|
-
desc: "Whether to perform host key validation when connecting." },
|
57
|
-
"interpreters" => { type: Hash,
|
58
|
-
external: true,
|
59
|
-
desc: "A map of an extension name to the absolute path of an executable, "\
|
60
|
-
"enabling you to override the shebang defined in a task executable. "\
|
61
|
-
"The extension can optionally be specified with the `.` character "\
|
62
|
-
"(`.py` and `py` both map to a task executable `task.py`) and the "\
|
63
|
-
"extension is case sensitive. When a target's name is `localhost`, "\
|
64
|
-
"Ruby tasks run with the Bolt Ruby interpreter by default." },
|
65
|
-
"kex-algorithms" => { type: Array,
|
66
|
-
desc: "List of key exchange algorithms to use when establishing a "\
|
67
|
-
"connection to a target. Supported algorithms are defined by the "\
|
68
|
-
"Ruby net-ssh library "\
|
69
|
-
"([docs](https://github.com/net-ssh/net-ssh#supported-algorithms)). "\
|
70
|
-
"All supported, non-deprecated algorithms are available by default when "\
|
71
|
-
"this option is not used. To reference all default algorithms "\
|
72
|
-
"using this option, add 'defaults' to the list of supported "\
|
73
|
-
"algorithms." },
|
74
|
-
"load-config" => { type: TrueClass,
|
75
|
-
desc: "Whether to load system SSH configuration." },
|
76
|
-
"login-shell" => { type: String,
|
77
|
-
desc: "Which login shell Bolt should expect on the target. "\
|
78
|
-
"Supported shells are #{LOGIN_SHELLS.join(', ')}. "\
|
79
|
-
"**This option is experimental.**" },
|
80
|
-
"mac-algorithms" => { type: Array,
|
81
|
-
desc: "List of message authentication code algorithms to use when "\
|
82
|
-
"establishing a connection to a target. Supported algorithms are "\
|
83
|
-
"defined by the Ruby net-ssh library "\
|
84
|
-
"([docs](https://github.com/net-ssh/net-ssh#supported-algorithms)). "\
|
85
|
-
"All supported, non-deprecated algorithms are available by default when "\
|
86
|
-
"this option is not used. To reference all default algorithms "\
|
87
|
-
"using this option, add 'defaults' to the list of supported "\
|
88
|
-
"algorithms." },
|
89
|
-
"password" => { type: String,
|
90
|
-
desc: "Login password." },
|
91
|
-
"port" => { type: Integer,
|
92
|
-
external: true,
|
93
|
-
desc: "Connection port." },
|
94
|
-
"private-key" => { external: true,
|
95
|
-
desc: "Either the path to the private key file to use for authentication, or "\
|
96
|
-
"a hash with the key `key-data` and the contents of the private key." },
|
97
|
-
"proxyjump" => { type: String,
|
98
|
-
desc: "A jump host to proxy connections through, and an optional user to "\
|
99
|
-
"connect with." },
|
100
|
-
"run-as" => { type: String,
|
101
|
-
external: true,
|
102
|
-
desc: "A different user to run commands as after login." },
|
103
|
-
"run-as-command" => { type: Array,
|
104
|
-
external: true,
|
105
|
-
desc: "The command to elevate permissions. Bolt appends the user and command "\
|
106
|
-
"strings to the configured `run-as-command` before running it on the "\
|
107
|
-
"target. This command must not require an interactive password prompt, "\
|
108
|
-
"and the `sudo-password` option is ignored when `run-as-command` is "\
|
109
|
-
"specified. The `run-as-command` must be specified as an array." },
|
110
|
-
"script-dir" => { type: String,
|
111
|
-
external: true,
|
112
|
-
desc: "The subdirectory of the tmpdir to use in place of a randomized "\
|
113
|
-
"subdirectory for uploading and executing temporary files on the "\
|
114
|
-
"target. It's expected that this directory already exists as a subdir "\
|
115
|
-
"of tmpdir, which is either configured or defaults to `/tmp`." },
|
116
|
-
"ssh-command" => { external: true,
|
117
|
-
desc: "Command and flags to use when SSHing. This enables the external "\
|
118
|
-
"SSH transport which shells out to the specified command. "\
|
119
|
-
"**This option is experimental.**" },
|
120
|
-
"sudo-executable" => { type: String,
|
121
|
-
external: true,
|
122
|
-
desc: "The executable to use when escalating to the configured `run-as` "\
|
123
|
-
"user. This is useful when you want to escalate using the configured "\
|
124
|
-
"`sudo-password`, since `run-as-command` does not use `sudo-password` "\
|
125
|
-
"or support prompting. The command executed on the target is "\
|
126
|
-
"`<sudo-executable> -S -u <user> -p custom_bolt_prompt <command>`. "\
|
127
|
-
"**This option is experimental.**" },
|
128
|
-
"sudo-password" => { type: String,
|
129
|
-
external: true,
|
130
|
-
desc: "Password to use when changing users via `run-as`." },
|
131
|
-
"tmpdir" => { type: String,
|
132
|
-
external: true,
|
133
|
-
desc: "The directory to upload and execute temporary files on the target." },
|
134
|
-
"tty" => { type: TrueClass,
|
135
|
-
desc: "Request a pseudo tty for the session. This option is generally "\
|
136
|
-
"only used in conjunction with the `run-as` option when the sudoers "\
|
137
|
-
"policy requires a `tty`." },
|
138
|
-
"user" => { type: String,
|
139
|
-
external: true,
|
140
|
-
desc: "Login user." }
|
141
|
-
}.freeze
|
10
|
+
# Options available when using the net-ssh-based transport
|
11
|
+
OPTIONS = %w[
|
12
|
+
cleanup
|
13
|
+
connect-timeout
|
14
|
+
disconnect-timeout
|
15
|
+
encryption-algorithms
|
16
|
+
extensions
|
17
|
+
host
|
18
|
+
host-key-algorithms
|
19
|
+
host-key-check
|
20
|
+
interpreters
|
21
|
+
kex-algorithms
|
22
|
+
load-config
|
23
|
+
login-shell
|
24
|
+
mac-algorithms
|
25
|
+
password
|
26
|
+
port
|
27
|
+
private-key
|
28
|
+
proxyjump
|
29
|
+
script-dir
|
30
|
+
tmpdir
|
31
|
+
tty
|
32
|
+
user
|
33
|
+
].concat(RUN_AS_OPTIONS).sort.freeze
|
34
|
+
|
35
|
+
# Options available when using the native ssh transport
|
36
|
+
NATIVE_OPTIONS = %w[
|
37
|
+
cleanup
|
38
|
+
copy-command
|
39
|
+
host
|
40
|
+
host-key-check
|
41
|
+
interpreters
|
42
|
+
native-ssh
|
43
|
+
port
|
44
|
+
private-key
|
45
|
+
script-dir
|
46
|
+
ssh-command
|
47
|
+
tmpdir
|
48
|
+
user
|
49
|
+
].concat(RUN_AS_OPTIONS).sort.freeze
|
142
50
|
|
143
51
|
DEFAULTS = {
|
144
52
|
"cleanup" => true,
|
145
53
|
"connect-timeout" => 10,
|
146
|
-
"tty" => false,
|
147
|
-
"load-config" => true,
|
148
54
|
"disconnect-timeout" => 5,
|
149
|
-
"
|
55
|
+
"load-config" => true,
|
56
|
+
"login-shell" => 'bash',
|
57
|
+
"tty" => false
|
150
58
|
}.freeze
|
151
59
|
|
60
|
+
# The set of options available for the ssh and native ssh transports overlap, so we
|
61
|
+
# need to check which transport is used before fully initializing, otherwise options
|
62
|
+
# may not be filtered correctly.
|
63
|
+
def initialize(data = {}, project = nil)
|
64
|
+
assert_hash_or_config(data)
|
65
|
+
@native = true if data['native-ssh']
|
66
|
+
super(data, project)
|
67
|
+
end
|
68
|
+
|
69
|
+
# This method is used to filter CLI options in the Config class. This
|
70
|
+
# should include `ssh-command` so that we can later warn if the option
|
71
|
+
# is present without `native-ssh`
|
72
|
+
def self.options
|
73
|
+
%w[ssh-command native-ssh].concat(OPTIONS)
|
74
|
+
end
|
75
|
+
|
76
|
+
private def filter(unfiltered)
|
77
|
+
# Because we filter before merging config together it's impossible to
|
78
|
+
# know whether both ssh-command *and* native-ssh will be specified
|
79
|
+
# unless they are both in the filter. However, we can't add
|
80
|
+
# ssh-command to OPTIONS since that's used for documenting available
|
81
|
+
# options. This makes it so that ssh-command is preserved so we can
|
82
|
+
# warn once all config is resolved if native-ssh isn't set.
|
83
|
+
@native ? unfiltered.slice(*NATIVE_OPTIONS) : unfiltered.slice(*self.class.options)
|
84
|
+
end
|
85
|
+
|
152
86
|
private def validate
|
153
87
|
super
|
154
88
|
|
@@ -163,11 +97,11 @@ module Bolt
|
|
163
97
|
@config['private-key'] = File.expand_path(key_opt, @project)
|
164
98
|
|
165
99
|
# We have an explicit test for this to only warn if using net-ssh transport
|
166
|
-
Bolt::Util.validate_file('ssh key', @config['private-key']) if @config['ssh
|
100
|
+
Bolt::Util.validate_file('ssh key', @config['private-key']) if @config['native-ssh']
|
167
101
|
end
|
168
102
|
|
169
|
-
if key_opt.instance_of?(Hash) && @config['ssh
|
170
|
-
raise Bolt::ValidationError, 'private-key must be a filepath when using ssh
|
103
|
+
if key_opt.instance_of?(Hash) && @config['native-ssh']
|
104
|
+
raise Bolt::ValidationError, 'private-key must be a filepath when using native-ssh'
|
171
105
|
end
|
172
106
|
end
|
173
107
|
|
@@ -197,24 +131,10 @@ module Bolt
|
|
197
131
|
end
|
198
132
|
end
|
199
133
|
|
200
|
-
if @config['ssh
|
201
|
-
msg = 'Cannot use
|
134
|
+
if @config['native-ssh'] && !@config['load-config']
|
135
|
+
msg = 'Cannot use native SSH transport with load-config set to false'
|
202
136
|
raise Bolt::ValidationError, msg
|
203
137
|
end
|
204
|
-
|
205
|
-
if (ssh_cmd = @config['ssh-command'])
|
206
|
-
unless ssh_cmd.is_a?(String) || ssh_cmd.is_a?(Array)
|
207
|
-
raise Bolt::ValidationError,
|
208
|
-
"ssh-command must be a String or Array, received #{ssh_cmd.class} #{ssh_cmd.inspect}"
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
if (copy_cmd = @config['copy-command'])
|
213
|
-
unless copy_cmd.is_a?(String) || copy_cmd.is_a?(Array)
|
214
|
-
raise Bolt::ValidationError,
|
215
|
-
"copy-command must be a String or Array, received #{copy_cmd.class} #{copy_cmd.inspect}"
|
216
|
-
end
|
217
|
-
end
|
218
138
|
end
|
219
139
|
end
|
220
140
|
end
|
@@ -7,53 +7,24 @@ module Bolt
|
|
7
7
|
class Config
|
8
8
|
module Transport
|
9
9
|
class WinRM < Base
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
desc: "Which file transfer protocol to use. Either `winrm` or `smb`. Using `smb` is "\
|
29
|
-
"recommended for large file transfers." },
|
30
|
-
"host" => { type: String,
|
31
|
-
desc: "Host name." },
|
32
|
-
"interpreters" => { type: Hash,
|
33
|
-
desc: "A map of an extension name to the absolute path of an executable, "\
|
34
|
-
"enabling you to override the shebang defined in a task executable. The "\
|
35
|
-
"extension can optionally be specified with the `.` character (`.py` and "\
|
36
|
-
"`py` both map to a task executable `task.py`) and the extension is case "\
|
37
|
-
"sensitive. When a target's name is `localhost`, Ruby tasks run with the "\
|
38
|
-
"Bolt Ruby interpreter by default." },
|
39
|
-
"password" => { type: String,
|
40
|
-
desc: "Login password. **Required unless using Kerberos.**" },
|
41
|
-
"port" => { type: Integer,
|
42
|
-
desc: "Connection port." },
|
43
|
-
"realm" => { type: String,
|
44
|
-
desc: "Kerberos realm (Active Directory domain) to authenticate against." },
|
45
|
-
"smb-port" => { type: Integer,
|
46
|
-
desc: "With file-protocol set to smb, this is the port to establish a "\
|
47
|
-
"connection on." },
|
48
|
-
"ssl" => { type: TrueClass,
|
49
|
-
desc: "When true, Bolt uses secure https connections for WinRM." },
|
50
|
-
"ssl-verify" => { type: TrueClass,
|
51
|
-
desc: "When true, verifies the targets certificate matches the cacert." },
|
52
|
-
"tmpdir" => { type: String,
|
53
|
-
desc: "The directory to upload and execute temporary files on the target." },
|
54
|
-
"user" => { type: String,
|
55
|
-
desc: "Login user. **Required unless using Kerberos.**" }
|
56
|
-
}.freeze
|
10
|
+
OPTIONS = %w[
|
11
|
+
basic-auth-only
|
12
|
+
cacert
|
13
|
+
cleanup
|
14
|
+
connect-timeout
|
15
|
+
extensions
|
16
|
+
file-protocol
|
17
|
+
host
|
18
|
+
interpreters
|
19
|
+
password
|
20
|
+
port
|
21
|
+
realm
|
22
|
+
smb-port
|
23
|
+
ssl
|
24
|
+
ssl-verify
|
25
|
+
tmpdir
|
26
|
+
user
|
27
|
+
].freeze
|
57
28
|
|
58
29
|
DEFAULTS = {
|
59
30
|
"basic-auth-only" => false,
|
data/lib/bolt/executor.rb
CHANGED
@@ -320,6 +320,21 @@ module Bolt
|
|
320
320
|
end
|
321
321
|
end
|
322
322
|
|
323
|
+
def download_file(targets, source, destination, options = {})
|
324
|
+
description = options.fetch(:description, "file download from #{source} to #{destination}")
|
325
|
+
FileUtils.mkdir_p(destination)
|
326
|
+
|
327
|
+
log_action(description, targets) do
|
328
|
+
options[:run_as] = run_as if run_as && !options.key?(:run_as)
|
329
|
+
|
330
|
+
batch_execute(targets) do |transport, batch|
|
331
|
+
with_node_logging("Downloading file #{source} to #{destination}", batch) do
|
332
|
+
transport.batch_download(batch, source, destination, options, &method(:publish_event))
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
323
338
|
def run_plan(scope, plan, params)
|
324
339
|
plan.call_by_name_with_scope(scope, params, true)
|
325
340
|
end
|
data/lib/bolt/inventory/group.rb
CHANGED
@@ -16,7 +16,7 @@ module Bolt
|
|
16
16
|
DATA_KEYS = %w[config facts vars features plugin_hooks].freeze
|
17
17
|
TARGET_KEYS = DATA_KEYS + %w[name alias uri]
|
18
18
|
GROUP_KEYS = DATA_KEYS + %w[name groups targets]
|
19
|
-
CONFIG_KEYS = Bolt::Config::
|
19
|
+
CONFIG_KEYS = Bolt::Config::INVENTORY_OPTIONS.keys
|
20
20
|
|
21
21
|
def initialize(input, plugins)
|
22
22
|
@logger = Logging.logger[self]
|
@@ -50,10 +50,11 @@ module Bolt
|
|
50
50
|
# or it could be a name/alias of a target defined in another group.
|
51
51
|
# We can't tell the difference until all groups have been resolved,
|
52
52
|
# so we store the string on its own here and process it later.
|
53
|
-
|
53
|
+
case target
|
54
|
+
when String
|
54
55
|
@string_targets << target
|
55
56
|
# Handle plugins at this level so that lookups cannot trigger recursive lookups
|
56
|
-
|
57
|
+
when Hash
|
57
58
|
add_target_definition(target)
|
58
59
|
else
|
59
60
|
raise ValidationError.new("Target entry must be a String or Hash, not #{target.class}", @name)
|
@@ -78,20 +78,6 @@ module Bolt
|
|
78
78
|
target_array.first
|
79
79
|
end
|
80
80
|
|
81
|
-
def self.localhost_defaults(data)
|
82
|
-
defaults = {
|
83
|
-
'config' => {
|
84
|
-
'transport' => 'local',
|
85
|
-
'local' => { 'interpreters' => { '.rb' => RbConfig.ruby } }
|
86
|
-
},
|
87
|
-
'features' => ['puppet-agent']
|
88
|
-
}
|
89
|
-
data = Bolt::Util.deep_merge(defaults, data)
|
90
|
-
# If features is an empty array deep_merge won't add the puppet-agent
|
91
|
-
data['features'] += ['puppet-agent'] if data['features'].empty?
|
92
|
-
data
|
93
|
-
end
|
94
|
-
|
95
81
|
#### PRIVATE ####
|
96
82
|
def group_data_for(target_name)
|
97
83
|
@groups.group_collect(target_name)
|
@@ -123,11 +109,12 @@ module Bolt
|
|
123
109
|
private :resolve_name
|
124
110
|
|
125
111
|
def expand_targets(targets)
|
126
|
-
|
112
|
+
case targets
|
113
|
+
when Bolt::Target
|
127
114
|
targets
|
128
|
-
|
115
|
+
when Array
|
129
116
|
targets.map { |tish| expand_targets(tish) }
|
130
|
-
|
117
|
+
when String
|
131
118
|
# Expand a comma-separated list
|
132
119
|
targets.split(/[[:space:],]+/).reject(&:empty?).map do |name|
|
133
120
|
ts = resolve_name(name)
|