ztk 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/ztk.rb +3 -23
- data/lib/ztk/ansi.rb +94 -33
- data/lib/ztk/background.rb +4 -23
- data/lib/ztk/base.rb +5 -24
- data/lib/ztk/benchmark.rb +4 -23
- data/lib/ztk/command.rb +49 -40
- data/lib/ztk/config.rb +3 -22
- data/lib/ztk/dsl.rb +3 -22
- data/lib/ztk/dsl/base.rb +14 -22
- data/lib/ztk/dsl/core.rb +4 -24
- data/lib/ztk/dsl/core/actions.rb +1 -21
- data/lib/ztk/dsl/core/actions/find.rb +2 -22
- data/lib/ztk/dsl/core/actions/timestamps.rb +2 -22
- data/lib/ztk/dsl/core/attributes.rb +2 -22
- data/lib/ztk/dsl/core/dataset.rb +2 -22
- data/lib/ztk/dsl/core/io.rb +2 -22
- data/lib/ztk/dsl/core/relations.rb +2 -22
- data/lib/ztk/dsl/core/relations/belongs_to.rb +2 -22
- data/lib/ztk/dsl/core/relations/has_many.rb +2 -22
- data/lib/ztk/locator.rb +3 -22
- data/lib/ztk/logger.rb +2 -21
- data/lib/ztk/parallel.rb +4 -23
- data/lib/ztk/pty.rb +8 -23
- data/lib/ztk/report.rb +4 -23
- data/lib/ztk/rescue_retry.rb +4 -24
- data/lib/ztk/spinner.rb +6 -25
- data/lib/ztk/ssh.rb +20 -27
- data/lib/ztk/ssh/bootstrap.rb +17 -19
- data/lib/ztk/ssh/command.rb +1 -19
- data/lib/ztk/ssh/download.rb +1 -19
- data/lib/ztk/ssh/exec.rb +14 -24
- data/lib/ztk/ssh/file.rb +1 -19
- data/lib/ztk/ssh/upload.rb +5 -22
- data/lib/ztk/tcp_socket_check.rb +3 -22
- data/lib/ztk/template.rb +4 -23
- data/lib/ztk/ui.rb +5 -25
- data/lib/ztk/version.rb +1 -21
- data/spec/spec_helper.rb +1 -1
- data/spec/ztk/background_spec.rb +1 -1
- data/spec/ztk/base_spec.rb +1 -1
- data/spec/ztk/benchmark_spec.rb +1 -1
- data/spec/ztk/command_spec.rb +1 -1
- data/spec/ztk/config_spec.rb +1 -1
- data/spec/ztk/dsl_spec.rb +1 -1
- data/spec/ztk/locator_spec.rb +1 -1
- data/spec/ztk/logger_spec.rb +1 -1
- data/spec/ztk/parallel_spec.rb +1 -1
- data/spec/ztk/pty_spec.rb +1 -1
- data/spec/ztk/rescue_retry_spec.rb +1 -1
- data/spec/ztk/spinner_spec.rb +1 -1
- data/spec/ztk/ssh_spec.rb +1 -1
- data/spec/ztk/tcp_socket_check_spec.rb +1 -1
- data/spec/ztk/template_spec.rb +1 -1
- data/spec/ztk/ui_spec.rb +1 -1
- data/spec/ztk/version_spec.rb +1 -1
- data/ztk.gemspec +2 -2
- metadata +4 -4
@@ -1,26 +1,6 @@
|
|
1
|
-
################################################################################
|
2
|
-
#
|
3
|
-
# Author: Zachary Patten <zachary@jovelabs.net>
|
4
|
-
# Copyright: Copyright (c) Zachary Patten
|
5
|
-
# License: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
################################################################################
|
20
|
-
|
21
1
|
module ZTK::DSL::Core::Relations
|
22
2
|
|
23
|
-
# @author Zachary Patten <zachary
|
3
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
24
4
|
# @api private
|
25
5
|
module HasMany
|
26
6
|
|
@@ -57,7 +37,7 @@ module ZTK::DSL::Core::Relations
|
|
57
37
|
end
|
58
38
|
end
|
59
39
|
|
60
|
-
# @author Zachary Patten <zachary
|
40
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
61
41
|
module ClassMethods
|
62
42
|
|
63
43
|
def has_many(key, options={})
|
data/lib/ztk/locator.rb
CHANGED
@@ -1,30 +1,11 @@
|
|
1
|
-
################################################################################
|
2
|
-
#
|
3
|
-
# Author: Zachary Patten <zachary@jovelabs.net>
|
4
|
-
# Copyright: Copyright (c) Zachary Patten
|
5
|
-
# License: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
################################################################################
|
20
1
|
module ZTK
|
21
2
|
|
22
|
-
#
|
3
|
+
# Locator Error Class
|
23
4
|
#
|
24
|
-
# @author Zachary Patten <zachary
|
5
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
25
6
|
class LocatorError < Error; end
|
26
7
|
|
27
|
-
# @author Zachary Patten <zachary
|
8
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
28
9
|
class Locator
|
29
10
|
|
30
11
|
class << self
|
data/lib/ztk/logger.rb
CHANGED
@@ -1,23 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author: Zachary Patten <zachary@jovelabs.net>
|
4
|
-
# Copyright: Copyright (c) Zachary Patten
|
5
|
-
# License: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
################################################################################
|
20
|
-
require "logger"
|
1
|
+
require 'logger'
|
21
2
|
|
22
3
|
module ZTK
|
23
4
|
|
@@ -41,7 +22,7 @@ module ZTK
|
|
41
22
|
# $logger.error { "This is a error message!" }
|
42
23
|
# $logger.fatal { "This is a fatal message!" }
|
43
24
|
#
|
44
|
-
# @author Zachary Patten <zachary
|
25
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
45
26
|
class Logger < ::Logger
|
46
27
|
|
47
28
|
# Log Levels
|
data/lib/ztk/parallel.rb
CHANGED
@@ -1,29 +1,10 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author: Zachary Patten <zachary@jovelabs.net>
|
4
|
-
# Copyright: Copyright (c) Zachary Patten
|
5
|
-
# License: Apache License, VersIOn 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, VersIOn 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissIOns and
|
17
|
-
# limitatIOns under the License.
|
18
|
-
#
|
19
|
-
################################################################################
|
20
|
-
require "base64"
|
1
|
+
require 'base64'
|
21
2
|
|
22
3
|
module ZTK
|
23
4
|
|
24
|
-
#
|
5
|
+
# Parallel Error Class
|
25
6
|
#
|
26
|
-
# @author Zachary Patten <zachary
|
7
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
27
8
|
class ParallelError < Error; end
|
28
9
|
|
29
10
|
# Parallel Processing Class
|
@@ -112,7 +93,7 @@ module ZTK
|
|
112
93
|
# [0, 1, 2]
|
113
94
|
# => nil
|
114
95
|
#
|
115
|
-
# @author Zachary Patten <zachary
|
96
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
116
97
|
class Parallel < ZTK::Base
|
117
98
|
|
118
99
|
# Default Maximum Number of Forks
|
data/lib/ztk/pty.rb
CHANGED
@@ -1,37 +1,22 @@
|
|
1
|
-
################################################################################
|
2
|
-
#
|
3
|
-
# Author: Zachary Patten <zachary@jovelabs.net>
|
4
|
-
# Copyright: Copyright (c) Zachary Patten
|
5
|
-
# License: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
################################################################################
|
20
1
|
require 'pty'
|
21
2
|
|
22
3
|
module ZTK
|
23
4
|
|
24
|
-
#
|
25
|
-
#
|
5
|
+
# PTY Error Class
|
6
|
+
#
|
7
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
26
8
|
class PTYError < Error; end
|
27
9
|
|
28
10
|
# Ruby PTY Class Wrapper
|
29
|
-
#
|
11
|
+
#
|
12
|
+
# Wraps the Ruby PTY class, providing better functionality.
|
13
|
+
#
|
14
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
30
15
|
class PTY
|
31
16
|
|
32
17
|
class << self
|
33
18
|
|
34
|
-
#
|
19
|
+
# Spawns a ruby-based PTY.
|
35
20
|
#
|
36
21
|
# @param [Array] args An argument splat to be passed to PTY::spawn
|
37
22
|
#
|
data/lib/ztk/report.rb
CHANGED
@@ -1,33 +1,14 @@
|
|
1
|
-
################################################################################
|
2
|
-
#
|
3
|
-
# Author: Zachary Patten <zachary@jovelabs.net>
|
4
|
-
# Copyright: Copyright (c) Zachary Patten
|
5
|
-
# License: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
################################################################################
|
20
1
|
require 'socket'
|
21
2
|
require 'timeout'
|
22
3
|
|
23
4
|
module ZTK
|
24
5
|
|
25
|
-
#
|
6
|
+
# Report Error Class
|
26
7
|
#
|
27
|
-
# @author Zachary Patten <zachary
|
8
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
28
9
|
class ReportError < Error; end
|
29
10
|
|
30
|
-
#
|
11
|
+
# Report Class
|
31
12
|
#
|
32
13
|
# This class contains tools for generating spreadsheet or key-value list
|
33
14
|
# styled output. Report methods are currently meant to be interchangeable;
|
@@ -36,7 +17,7 @@ module ZTK
|
|
36
17
|
#
|
37
18
|
# The idea here is that everything is auto-sized and simply displayed.
|
38
19
|
#
|
39
|
-
# @author Zachary Patten <zachary
|
20
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
40
21
|
class Report < ZTK::Base
|
41
22
|
|
42
23
|
# @param [Hash] configuration Configuration options hash.
|
data/lib/ztk/rescue_retry.rb
CHANGED
@@ -1,31 +1,11 @@
|
|
1
|
-
################################################################################
|
2
|
-
#
|
3
|
-
# Author: Zachary Patten <zachary@jovelabs.net>
|
4
|
-
# Copyright: Copyright (c) Zachary Patten
|
5
|
-
# License: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
################################################################################
|
20
|
-
|
21
1
|
module ZTK
|
22
2
|
|
23
|
-
#
|
3
|
+
# RescueRetry Error Class
|
24
4
|
#
|
25
|
-
# @author Zachary Patten <zachary
|
5
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
26
6
|
class RescueRetryError < Error; end
|
27
7
|
|
28
|
-
#
|
8
|
+
# RescueRetry Class
|
29
9
|
#
|
30
10
|
# This class contains an exception handling tool, which will allowing retry
|
31
11
|
# of all or specific *Exceptions* based on a set number of attempts to make.
|
@@ -94,7 +74,7 @@ module ZTK
|
|
94
74
|
# 1
|
95
75
|
# => nil
|
96
76
|
#
|
97
|
-
# @author Zachary Patten <zachary
|
77
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
98
78
|
class RescueRetry
|
99
79
|
|
100
80
|
class << self
|
data/lib/ztk/spinner.rb
CHANGED
@@ -1,38 +1,19 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author: Zachary Patten <zachary@jovelabs.net>
|
4
|
-
# Copyright: Copyright (c) Zachary Patten
|
5
|
-
# License: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
################################################################################
|
20
|
-
require "ostruct"
|
1
|
+
require 'ostruct'
|
21
2
|
|
22
3
|
module ZTK
|
23
4
|
|
24
|
-
#
|
5
|
+
# Spinner Error Class
|
25
6
|
#
|
26
|
-
# @author Zachary Patten <zachary
|
7
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
27
8
|
class SpinnerError < Error; end
|
28
9
|
|
29
|
-
#
|
10
|
+
# Spinner Class
|
30
11
|
#
|
31
12
|
# This class can be used to display an "activity indicator" to a user while
|
32
13
|
# a task is executed in the supplied block. This indicator takes the form
|
33
14
|
# of a spinner.
|
34
15
|
#
|
35
|
-
# @author Zachary Patten <zachary
|
16
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
36
17
|
class Spinner
|
37
18
|
|
38
19
|
class << self
|
@@ -54,7 +35,7 @@ module ZTK
|
|
54
35
|
# taking place "behind the scenes".
|
55
36
|
# @return [Object] The return value of the block.
|
56
37
|
#
|
57
|
-
# @author Zachary Patten <zachary
|
38
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
58
39
|
# @author Stephen Nelson-Smith <stephen@atalanta-systems.com>
|
59
40
|
def spin(options={}, &block)
|
60
41
|
options = Base.build_config({
|
data/lib/ztk/ssh.rb
CHANGED
@@ -1,32 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# License: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
################################################################################
|
20
|
-
require "ostruct"
|
21
|
-
require "net/ssh"
|
22
|
-
require "net/ssh/proxy/command"
|
23
|
-
require "net/sftp"
|
1
|
+
require 'ostruct'
|
2
|
+
require 'net/ssh'
|
3
|
+
require 'net/ssh/proxy/command'
|
4
|
+
require 'net/sftp'
|
24
5
|
|
25
6
|
module ZTK
|
26
7
|
|
27
|
-
#
|
8
|
+
# SSH Error Class
|
28
9
|
#
|
29
|
-
# @author Zachary Patten <zachary
|
10
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
30
11
|
class SSHError < Error; end
|
31
12
|
|
32
13
|
# SSH Multi-function Class
|
@@ -82,7 +63,7 @@ module ZTK
|
|
82
63
|
# config.host_key_verify = true
|
83
64
|
# end
|
84
65
|
#
|
85
|
-
# @author Zachary Patten <zachary
|
66
|
+
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
86
67
|
class SSH < ZTK::Base
|
87
68
|
# Exit Signal Mappings
|
88
69
|
EXIT_SIGNALS = {
|
@@ -153,6 +134,16 @@ module ZTK
|
|
153
134
|
# enable SSH agent forwarding.
|
154
135
|
# @option configuration [String, Array<String>] :proxy_keys A single or
|
155
136
|
# series of identity files to use for authentication with the proxy.
|
137
|
+
# @option options [Boolean] :ignore_exit_status (false) Whether or not
|
138
|
+
# we should ignore the exit status of the the process we spawn. By
|
139
|
+
# default we do not ignore the exit status and throw an exception if it is
|
140
|
+
# non-zero.
|
141
|
+
# @option options [Integer] :exit_code (0) The exit code we expect the
|
142
|
+
# process to return. This is ignore if *ignore_exit_status* is true.
|
143
|
+
# @option options [Boolean] :silence (false) Whether or not we should
|
144
|
+
# squelch the output of the process. The output will always go to the
|
145
|
+
# logging device supplied in the ZTK::UI object. The output is always
|
146
|
+
# available in the return value from the method additionally.
|
156
147
|
def initialize(configuration={})
|
157
148
|
super({
|
158
149
|
:forward_agent => true,
|
@@ -160,7 +151,9 @@ module ZTK
|
|
160
151
|
:user_known_hosts_file => '/dev/null',
|
161
152
|
:timeout => 60,
|
162
153
|
:ignore_exit_status => false,
|
163
|
-
:request_pty => true
|
154
|
+
:request_pty => true,
|
155
|
+
:exit_code => 0,
|
156
|
+
:silence => false
|
164
157
|
}.merge(configuration))
|
165
158
|
config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
|
166
159
|
end
|
data/lib/ztk/ssh/bootstrap.rb
CHANGED
@@ -1,28 +1,26 @@
|
|
1
|
-
################################################################################
|
2
|
-
#
|
3
|
-
# Author: Zachary Patten <zachary@jovelabs.net>
|
4
|
-
# Copyright: Copyright (c) Zachary Patten
|
5
|
-
# License: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
################################################################################
|
20
1
|
module ZTK
|
21
2
|
class SSH
|
22
3
|
|
4
|
+
# SSH Bootstrap Functionality
|
23
5
|
module Bootstrap
|
24
6
|
require 'tempfile'
|
25
7
|
|
8
|
+
# SSH Bootstrap
|
9
|
+
#
|
10
|
+
# Renders the *content* string into a file on the remote host and proceeds
|
11
|
+
# to execute it via */bin/bash*. Sudo is prefixed by default, but can be
|
12
|
+
# disabled.
|
13
|
+
#
|
14
|
+
# @example Sample Bootstrap, assuming the @ssh variable is an instance of ZTK::SSH connected to a host.
|
15
|
+
# @ssh.bootstrap(IO.read("bootstrap.sh"))
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# @ssh.bootstrap("apt-get -y upgrade")
|
19
|
+
#
|
20
|
+
# @param [String] content What to render out to the bootstrap file we will
|
21
|
+
# execute.
|
22
|
+
# @param [Boolean] use_sudo Whether or not we should prefix *sudo*
|
23
|
+
# on our command.
|
26
24
|
def bootstrap(content, use_sudo=true)
|
27
25
|
tempfile = Tempfile.new("bootstrap")
|
28
26
|
|