bolt 0.12.0 → 0.13.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/lib/bolt/cli.rb +1 -5
- data/lib/bolt/config.rb +11 -5
- data/lib/bolt/execution_result.rb +1 -1
- data/lib/bolt/node.rb +0 -1
- data/lib/bolt/node/ssh.rb +16 -10
- data/lib/bolt/version.rb +1 -1
- data/modules/boltlib/lib/puppet/functions/file_upload.rb +1 -0
- data/modules/boltlib/lib/puppet/functions/run_command.rb +1 -0
- data/modules/boltlib/lib/puppet/functions/run_script.rb +2 -0
- data/modules/boltlib/lib/puppet/functions/run_task.rb +6 -0
- data/vendored/puppet/lib/puppet/application/filebucket.rb +23 -10
- data/vendored/puppet/lib/puppet/defaults.rb +23 -13
- data/vendored/puppet/lib/puppet/pops/pcore.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +7 -1
- data/vendored/puppet/lib/puppet/reference/configuration.rb +4 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b45ba6bf81dbfe329d47a503bf505f1eaf3e5449
|
4
|
+
data.tar.gz: 7d701baa18ad45ddec7cf1cdca86c06e41df1178
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28a20849dbc613f7aea831a27162906e7b70a988b97e75931fc17f6bb9605bc9d731aaa1778182f070188b5f84ba74654e40c95cef405e8987139e93fea419f8
|
7
|
+
data.tar.gz: c875018a2539e59aedb3c247ec41faad45f86e1aa12ab3dfc6ac7eb6553b1203d6c730596e1d67e4c6e37c2e97a977bb9fd594e1543a1b316a791fddb4fc5a1b
|
data/lib/bolt/cli.rb
CHANGED
@@ -109,6 +109,7 @@ HELP
|
|
109
109
|
}
|
110
110
|
@config = Bolt::Config.new
|
111
111
|
@parser = create_option_parser(@options)
|
112
|
+
@logger = Logger.new(STDERR)
|
112
113
|
end
|
113
114
|
|
114
115
|
def create_option_parser(results)
|
@@ -186,11 +187,6 @@ HELP
|
|
186
187
|
"User to run as using privilege escalation") do |user|
|
187
188
|
results[:run_as] = user
|
188
189
|
end
|
189
|
-
opts.on('--sudo [PROGRAM]',
|
190
|
-
"Program to execute for privilege escalation. " \
|
191
|
-
"Currently only sudo is supported.") do |program|
|
192
|
-
results[:sudo] = program || 'sudo'
|
193
|
-
end
|
194
190
|
opts.on('--sudo-password [PASSWORD]',
|
195
191
|
'Password for privilege escalation') do |password|
|
196
192
|
if password.nil?
|
data/lib/bolt/config.rb
CHANGED
@@ -21,7 +21,7 @@ module Bolt
|
|
21
21
|
log_destination: STDERR
|
22
22
|
}.freeze
|
23
23
|
|
24
|
-
TRANSPORT_OPTIONS = %i[insecure password run_as
|
24
|
+
TRANSPORT_OPTIONS = %i[insecure password run_as sudo_password
|
25
25
|
key tty tmpdir user connect_timeout cacert
|
26
26
|
token_file orch_task_environment service_url].freeze
|
27
27
|
|
@@ -112,6 +112,9 @@ module Bolt
|
|
112
112
|
if data['ssh']['tmpdir']
|
113
113
|
self[:transports][:ssh][:tmpdir] = data['ssh']['tmpdir']
|
114
114
|
end
|
115
|
+
if data['ssh']['run-as']
|
116
|
+
self[:transports][:ssh][:run_as] = data['ssh']['run-as']
|
117
|
+
end
|
115
118
|
end
|
116
119
|
|
117
120
|
if data['winrm']
|
@@ -167,14 +170,17 @@ module Bolt
|
|
167
170
|
self[:transports][transport][key] = options[key] if options[key]
|
168
171
|
end
|
169
172
|
end
|
173
|
+
|
174
|
+
if options[:sudo_password] && self[:transports][:ssh][:run_as].nil?
|
175
|
+
logger = Logger.new(self[:log_destination])
|
176
|
+
logger.warn("'--sudo-password will not be used without specifying a" \
|
177
|
+
"user to escalate to with --run-as")
|
178
|
+
end
|
170
179
|
end
|
171
180
|
|
172
181
|
def validate
|
173
182
|
TRANSPORTS.each do |transport|
|
174
|
-
|
175
|
-
if tconf[:sudo] && tconf[:sudo] != 'sudo'
|
176
|
-
raise Bolt::CLIError, "Only 'sudo' is supported for privilege escalation."
|
177
|
-
end
|
183
|
+
self[:transports][transport]
|
178
184
|
end
|
179
185
|
|
180
186
|
unless %w[human json].include? self[:format]
|
data/lib/bolt/node.rb
CHANGED
@@ -46,7 +46,6 @@ module Bolt
|
|
46
46
|
@tty = transport_conf[:tty]
|
47
47
|
@insecure = transport_conf[:insecure]
|
48
48
|
@connect_timeout = transport_conf[:connect_timeout]
|
49
|
-
@sudo = transport_conf[:sudo]
|
50
49
|
@sudo_password = transport_conf[:sudo_password]
|
51
50
|
@run_as = transport_conf[:run_as]
|
52
51
|
@tmpdir = transport_conf[:tmpdir]
|
data/lib/bolt/node/ssh.rb
CHANGED
@@ -99,7 +99,7 @@ module Bolt
|
|
99
99
|
|
100
100
|
def execute(command, sudoable: false, **options)
|
101
101
|
result_output = Bolt::Node::Output.new
|
102
|
-
use_sudo = sudoable &&
|
102
|
+
use_sudo = sudoable && @run_as
|
103
103
|
if use_sudo
|
104
104
|
user_clause = if @run_as
|
105
105
|
"-u #{@run_as}"
|
@@ -276,7 +276,7 @@ SCRIPT
|
|
276
276
|
|
277
277
|
def _run_task(task, input_method, arguments)
|
278
278
|
export_args = {}
|
279
|
-
stdin = nil
|
279
|
+
stdin, output = nil
|
280
280
|
|
281
281
|
@logger.info { "Running task '#{task}'" }
|
282
282
|
@logger.debug { "arguments: #{arguments}\ninput_method: #{input_method}" }
|
@@ -291,15 +291,21 @@ SCRIPT
|
|
291
291
|
end.join(' ')
|
292
292
|
end
|
293
293
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
294
|
+
command = export_args.empty? ? '' : "#{export_args} "
|
295
|
+
|
296
|
+
if @run_as
|
297
|
+
with_remote_task(task, stdin) do |remote_path|
|
298
|
+
command += "'#{remote_path}'"
|
299
|
+
output = execute(command, sudoable: true)
|
300
|
+
end
|
301
|
+
else
|
302
|
+
with_remote_file(task) do |remote_path|
|
303
|
+
command += "'#{remote_path}'"
|
304
|
+
output = execute(command, stdin: stdin)
|
305
|
+
end
|
302
306
|
end
|
307
|
+
Bolt::TaskResult.from_output(output)
|
308
|
+
|
303
309
|
# TODO: We should be able to rely on the excutor for this but it will mean
|
304
310
|
# a test refactor
|
305
311
|
rescue StandardError => e
|
data/lib/bolt/version.rb
CHANGED
@@ -15,6 +15,7 @@ Puppet::Functions.create_function(:file_upload, Puppet::Functions::InternalFunct
|
|
15
15
|
param 'String[1]', :source
|
16
16
|
param 'String[1]', :destination
|
17
17
|
repeated_param 'TargetOrTargets', :targets
|
18
|
+
return_type 'ExecutionResult'
|
18
19
|
end
|
19
20
|
|
20
21
|
def file_upload(scope, source, destination, *targets)
|
@@ -15,12 +15,14 @@ Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFuncti
|
|
15
15
|
param 'String[1]', :script
|
16
16
|
param 'TargetOrTargets', :targets
|
17
17
|
param 'Struct[arguments => Array[String]]', :arguments
|
18
|
+
return_type 'ExecutionResult'
|
18
19
|
end
|
19
20
|
|
20
21
|
dispatch :run_script do
|
21
22
|
scope_param
|
22
23
|
param 'String[1]', :script
|
23
24
|
repeated_param 'TargetOrTargets', :targets
|
25
|
+
return_type 'ExecutionResult'
|
24
26
|
end
|
25
27
|
|
26
28
|
def run_script(scope, script, *targets)
|
@@ -14,6 +14,7 @@ Puppet::Functions.create_function(:run_task) do
|
|
14
14
|
param 'String[1]', :task_name
|
15
15
|
param 'TargetOrTargets', :targets
|
16
16
|
optional_param 'Hash[String[1], Any]', :task_args
|
17
|
+
return_type 'ExecutionResult'
|
17
18
|
end
|
18
19
|
|
19
20
|
# this is used from 'bolt task run'
|
@@ -56,6 +57,11 @@ Puppet::Functions.create_function(:run_task) do
|
|
56
57
|
task_signature.runnable_with?(use_args) do |mismatch|
|
57
58
|
raise Puppet::ParseError, mismatch
|
58
59
|
end || (raise Puppet::ParseError, 'Task parameters did not match')
|
60
|
+
|
61
|
+
unless Puppet::Pops::Types::TypeFactory.data.instance?(use_args)
|
62
|
+
raise Puppet::ParseError, 'Task parameters is not of type Data'
|
63
|
+
end
|
64
|
+
|
59
65
|
task = task_signature.task
|
60
66
|
|
61
67
|
if executor.noop
|
@@ -66,7 +66,8 @@ central filebucket.
|
|
66
66
|
Note that 'filebucket' defaults to using a network-based filebucket
|
67
67
|
available on the server named 'puppet'. To use this, you'll have to be
|
68
68
|
running as a user with valid Puppet certificates. Alternatively, you can
|
69
|
-
use your local file bucket by specifying '--local'
|
69
|
+
use your local file bucket by specifying '--local', or by specifying
|
70
|
+
'--bucket' with a local path.
|
70
71
|
|
71
72
|
|
72
73
|
OPTIONS
|
@@ -77,33 +78,40 @@ setting, so you can specify '--ssldir <directory>' as an
|
|
77
78
|
argument.
|
78
79
|
|
79
80
|
See the configuration file documentation at
|
80
|
-
https://
|
81
|
+
https://puppet.com/docs/puppet/latest/configuration.html for the
|
81
82
|
full list of acceptable parameters. A commented list of all
|
82
83
|
configuration options can also be generated by running puppet with
|
83
84
|
'--genconfig'.
|
84
85
|
|
86
|
+
* --bucket:
|
87
|
+
Specify a filebucket path. If '--local' is also set, this path
|
88
|
+
overrides the default '--local' path set in '$clientbucketdir'.
|
89
|
+
|
85
90
|
* --debug:
|
86
91
|
Enable full debugging.
|
87
92
|
|
88
93
|
* --fromdate:
|
89
|
-
(list only) Select bucket files from 'fromdate'
|
94
|
+
(list only) Select bucket files from 'fromdate'.
|
90
95
|
|
91
96
|
* --help:
|
92
|
-
Print this help message
|
97
|
+
Print this help message.
|
93
98
|
|
94
99
|
* --local:
|
95
|
-
Use the local filebucket. This
|
96
|
-
information
|
100
|
+
Use the local filebucket. This uses the default configuration
|
101
|
+
information and the bucket located at the '$clientbucketdir'
|
102
|
+
setting by default. If '--bucket' is set, puppet uses that
|
103
|
+
path instead.
|
97
104
|
|
98
105
|
* --remote:
|
99
|
-
Use a remote filebucket. This
|
100
|
-
information
|
106
|
+
Use a remote filebucket. This uses the default configuration
|
107
|
+
information and the bucket located at the '$bucketdir' setting
|
108
|
+
by default.
|
101
109
|
|
102
110
|
* --server:
|
103
111
|
The server to send the file to, instead of locally.
|
104
112
|
|
105
113
|
* --todate:
|
106
|
-
(list only) Select bucket files until 'todate'
|
114
|
+
(list only) Select bucket files until 'todate'.
|
107
115
|
|
108
116
|
* --verbose:
|
109
117
|
Print extra information.
|
@@ -130,7 +138,7 @@ EXAMPLE
|
|
130
138
|
$ echo again >> /tmp/TestFile
|
131
139
|
$ puppet filebucket -l backup /tmp/TestFile
|
132
140
|
/tmp/TestFile: 7ae322f5791217e031dc60188f4521ef
|
133
|
-
$ puppet filebucket -l
|
141
|
+
$ puppet filebucket -l list
|
134
142
|
d43a6ecaa892a1962398ac9170ea9bf2 2015-05-11 09:27:56 /tmp/TestFile
|
135
143
|
7ae322f5791217e031dc60188f4521ef 2015-05-11 09:52:15 /tmp/TestFile
|
136
144
|
$ puppet filebucket -l -f 2015-01-01 -t 2015-01-11 list
|
@@ -142,6 +150,11 @@ EXAMPLE
|
|
142
150
|
7ae322f5791217e031dc60188f4521ef 2015-05-11 09:52:15 /tmp/TestFile
|
143
151
|
$ puppet filebucket -l -t "2015-05-11 09:30:00" list
|
144
152
|
d43a6ecaa892a1962398ac9170ea9bf2 2015-05-11 09:27:56 /tmp/TestFile
|
153
|
+
## Manage files in a specific local filebucket
|
154
|
+
$ puppet filebucket -b /tmp/TestBucket backup /tmp/TestFile2
|
155
|
+
/tmp/TestFile2: d41d8cd98f00b204e9800998ecf8427e
|
156
|
+
$ puppet filebucket -b /tmp/TestBucket list
|
157
|
+
d41d8cd98f00b204e9800998ecf8427e 2015-05-11 09:33:22 /tmp/TestFile2
|
145
158
|
|
146
159
|
AUTHOR
|
147
160
|
------
|
@@ -1594,23 +1594,33 @@ EOT
|
|
1594
1594
|
:splaylimit => {
|
1595
1595
|
:default => "$runinterval",
|
1596
1596
|
:type => :duration,
|
1597
|
-
:desc => "The maximum time to delay before
|
1598
|
-
|
1597
|
+
:desc => "The maximum time to delay before an agent's first run when
|
1598
|
+
`splay` is enabled. Defaults to the agent's `$runinterval`. The
|
1599
|
+
`splay` interval is random and recalculated each time the agent is started or
|
1600
|
+
restarted. #{AS_DURATION}",
|
1599
1601
|
},
|
1600
1602
|
:splay => {
|
1601
1603
|
:default => false,
|
1602
1604
|
:type => :boolean,
|
1603
|
-
:desc => "Whether to sleep for a
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1605
|
+
:desc => "Whether to sleep for a random amount of time, ranging from
|
1606
|
+
immediately up to its `$splaylimit`, before performing its first agent run
|
1607
|
+
after a service restart. After this period, the agent runs periodically
|
1608
|
+
on its `$runinterval`.
|
1609
|
+
|
1610
|
+
For example, assume a default 30-minute `$runinterval`, `splay` set to its
|
1611
|
+
default of `false`, and an agent starting at :00 past the hour. The agent
|
1612
|
+
would check in every 30 minutes at :01 and :31 past the hour.
|
1613
|
+
|
1614
|
+
With `splay` enabled, it waits any amount of time up to its `$splaylimit`
|
1615
|
+
before its first run. For example, it might randomly wait 8 minutes,
|
1616
|
+
then start its first run at :08 past the hour. With the `$runinterval`
|
1617
|
+
at its default 30 minutes, its next run will be at :38 past the hour.
|
1618
|
+
|
1619
|
+
If you restart an agent's puppet service with `splay` enabled, it
|
1620
|
+
recalculates its splay period and delays its first agent run after
|
1621
|
+
restarting for this new period. If you simultaneously restart a group of
|
1622
|
+
puppet agents with `splay` enabled, their checkins to your puppet masters
|
1623
|
+
can be distributed more evenly.",
|
1614
1624
|
},
|
1615
1625
|
:clientbucketdir => {
|
1616
1626
|
:default => "$vardir/clientbucket",
|
@@ -62,7 +62,7 @@ module Pcore
|
|
62
62
|
Struct[
|
63
63
|
Optional[description] => String,
|
64
64
|
Optional[sensitive] => Boolean,
|
65
|
-
type => Type
|
65
|
+
type => Type]]],
|
66
66
|
value => undef
|
67
67
|
},
|
68
68
|
|
@@ -73,7 +73,7 @@ module Pcore
|
|
73
73
|
Struct[
|
74
74
|
Optional[description] => String,
|
75
75
|
Optional[sensitive] => Boolean,
|
76
|
-
type => Type
|
76
|
+
type => Type]]],
|
77
77
|
value => undef
|
78
78
|
},
|
79
79
|
|
@@ -680,7 +680,13 @@ class TypeFormatter
|
|
680
680
|
end
|
681
681
|
|
682
682
|
def range_array_part(t)
|
683
|
-
t.nil? || t.unbounded?
|
683
|
+
if t.nil? || t.unbounded?
|
684
|
+
EMPTY_ARRAY
|
685
|
+
else
|
686
|
+
result = [t.from.nil? ? 'default' : t.from.to_s]
|
687
|
+
result << t.to.to_s unless t.to.nil?
|
688
|
+
result
|
689
|
+
end
|
684
690
|
end
|
685
691
|
|
686
692
|
def append_object_hash(hash)
|
@@ -48,7 +48,7 @@ config = Puppet::Util::Reference.newreference(:configuration, :depth => 1, :doc
|
|
48
48
|
end
|
49
49
|
|
50
50
|
config.header = <<EOT
|
51
|
-
## Configuration
|
51
|
+
## Configuration settings
|
52
52
|
|
53
53
|
* Each of these settings can be specified in `puppet.conf` or on the
|
54
54
|
command line.
|
@@ -67,6 +67,8 @@ config.header = <<EOT
|
|
67
67
|
combined with other units, and defaults to seconds when omitted. Examples are
|
68
68
|
'3600' which is equivalent to '1h' (one hour), and '1825d' which is equivalent
|
69
69
|
to '5y' (5 years).
|
70
|
+
* If you use the `splay` setting, note that the period that it waits changes
|
71
|
+
each time the Puppet agent is restarted.
|
70
72
|
* Settings that take a single file or directory can optionally set the owner,
|
71
73
|
group, and mode for their value: `rundir = $vardir/run { owner = puppet,
|
72
74
|
group = puppet, mode = 644 }`
|
@@ -75,7 +77,7 @@ config.header = <<EOT
|
|
75
77
|
|
76
78
|
See the [configuration guide][confguide] for more details.
|
77
79
|
|
78
|
-
[confguide]: https://
|
80
|
+
[confguide]: https://puppet.com/docs/puppet/latest/config_about_settings.html
|
79
81
|
|
80
82
|
* * *
|
81
83
|
|
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.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -1577,7 +1577,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1577
1577
|
version: '0'
|
1578
1578
|
requirements: []
|
1579
1579
|
rubyforge_project:
|
1580
|
-
rubygems_version: 2.
|
1580
|
+
rubygems_version: 2.5.1
|
1581
1581
|
signing_key:
|
1582
1582
|
specification_version: 4
|
1583
1583
|
summary: Execute commands remotely over SSH and WinRM
|