symphony-ssh 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/symphony/tasks/sshscript.rb +27 -12
- metadata +12 -13
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f30fb65c28ed9ed46e7e4778e1a53ddc6a62e56c2d966ec51a7bf386bf111fb2
|
4
|
+
data.tar.gz: 8fb32494e41a1836deade9158906a803f16afa1b65baa350cf46936cec49525e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73e175a3c18dfdcfd473d36ec4d2b8e47c4b613d7ceee7ef42dda2652a14f41c2fdc6e2c000fe13255115cb56cab582b235b30a4e5b780eae47fcf59b3304888
|
7
|
+
data.tar.gz: b2cbc3bbb891de3bc13d1623b2658b7dc6a0d7712135a11826a04a307d530e78d42ab751872e3c32647e4daec9a1629d7254a95aac517c733432b39168b94c3b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -27,7 +27,9 @@ require 'symphony/tasks/ssh'
|
|
27
27
|
### key: (optional) The path to an SSH private key
|
28
28
|
### attributes: (optional) Additional data to attach to the template
|
29
29
|
### nocleanup: (optional) Leave the remote script after execution? (default to false)
|
30
|
-
###
|
30
|
+
### delete_cmd: (optional) The command to delete the remote script. (default to 'rm')
|
31
|
+
### run_binary: (optional) Windows doesn't allow direct execution of scripts, this is prefixed to the remote command if present.
|
32
|
+
### tempdir: (optional) The destination temp directory. (defaults to /tmp/, needs to include the separator character)
|
31
33
|
###
|
32
34
|
###
|
33
35
|
### Additionally, this class responds to the 'symphony.ssh' configurability
|
@@ -79,11 +81,9 @@ class Symphony::Task::SSHScript < Symphony::Task
|
|
79
81
|
def work( payload, metadata )
|
80
82
|
template = payload[ 'template' ]
|
81
83
|
attributes = payload[ 'attributes' ] || {}
|
82
|
-
port = payload[ 'port' ] || 22
|
83
84
|
user = payload[ 'user' ] || Symphony::Task::SSH.user
|
84
85
|
key = payload[ 'key' ] || Symphony::Task::SSH.key
|
85
|
-
|
86
|
-
tempdir = payload[ 'tempdir' ] || '/tmp'
|
86
|
+
tempdir = payload[ 'tempdir' ] || '/tmp/'
|
87
87
|
|
88
88
|
raise ArgumentError, "Missing required option 'template'" unless template
|
89
89
|
raise ArgumentError, "Missing required option 'host'" unless payload[ 'host' ]
|
@@ -91,7 +91,17 @@ class Symphony::Task::SSHScript < Symphony::Task
|
|
91
91
|
remote_filename = self.make_remote_filename( template, tempdir )
|
92
92
|
source = self.generate_script( template, attributes )
|
93
93
|
|
94
|
-
|
94
|
+
# Map any configuration parameters in the payload to ssh
|
95
|
+
# options, for potential per-message behavior overrides.
|
96
|
+
ssh_opts_override = payload.
|
97
|
+
slice( *DEFAULT_SSH_OPTIONS.keys.map( &:to_s ) ).
|
98
|
+
transform_keys{|k| k.to_sym }
|
99
|
+
|
100
|
+
ssh_options = DEFAULT_SSH_OPTIONS.dup.merge!(
|
101
|
+
ssh_opts_override,
|
102
|
+
port: payload[ 'port' ] || 22,
|
103
|
+
keys: Array( key )
|
104
|
+
)
|
95
105
|
ssh_options.merge!(
|
96
106
|
logger: Loggability[ Net::SSH ],
|
97
107
|
verbose: :debug
|
@@ -103,7 +113,7 @@ class Symphony::Task::SSHScript < Symphony::Task
|
|
103
113
|
self.upload_script( conn, source, remote_filename )
|
104
114
|
self.log.debug " done with the upload."
|
105
115
|
|
106
|
-
self.run_script( conn, remote_filename,
|
116
|
+
self.run_script( conn, remote_filename, payload )
|
107
117
|
self.log.debug "Output was:\n#{@output}"
|
108
118
|
end
|
109
119
|
|
@@ -118,9 +128,9 @@ class Symphony::Task::SSHScript < Symphony::Task
|
|
118
128
|
### Generate a unique filename for the script on the remote host,
|
119
129
|
### based on +template+ name.
|
120
130
|
###
|
121
|
-
def make_remote_filename( template, tempdir="/tmp" )
|
131
|
+
def make_remote_filename( template, tempdir="/tmp/" )
|
122
132
|
basename = File.basename( template, File.extname(template) )
|
123
|
-
tmpname = "%s
|
133
|
+
tmpname = "%s%s-%s" % [
|
124
134
|
tempdir,
|
125
135
|
basename,
|
126
136
|
SecureRandom.hex( 6 )
|
@@ -153,11 +163,16 @@ class Symphony::Task::SSHScript < Symphony::Task
|
|
153
163
|
|
154
164
|
|
155
165
|
### Run the +remote_filename+ via the ssh +conn+. The script
|
156
|
-
### will be deleted automatically unless +nocleanup+ is
|
166
|
+
### will be deleted automatically unless +nocleanup+ is set
|
167
|
+
### in the payload.
|
157
168
|
###
|
158
|
-
def run_script( conn, remote_filename,
|
159
|
-
|
160
|
-
|
169
|
+
def run_script( conn, remote_filename, payload )
|
170
|
+
delete_cmd = payload[ 'delete_cmd' ] || 'rm'
|
171
|
+
command = remote_filename
|
172
|
+
command = "%s %s" % [ payload['run_binary'], remote_filename ] if payload[ 'run_binary' ]
|
173
|
+
|
174
|
+
@output = conn.exec!( command )
|
175
|
+
conn.exec!( "#{delete_cmd} #{remote_filename}" ) unless payload[ 'nocleanup' ]
|
161
176
|
end
|
162
177
|
|
163
178
|
end # Symphony::Task::SSHScript
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symphony-ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mahlon E. Smith
|
@@ -11,9 +11,9 @@ bindir: bin
|
|
11
11
|
cert_chain:
|
12
12
|
- |
|
13
13
|
-----BEGIN CERTIFICATE-----
|
14
|
-
|
14
|
+
MIIDMDCCAhigAwIBAgIBAjANBgkqhkiG9w0BAQsFADA+MQ8wDQYDVQQDDAZtYWhs
|
15
15
|
b24xF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NzBUJ+Bq+qFOy7mVKNIfhXRRFYEy11y1712FsJXqUEku
|
29
|
+
qr3lnAEvEy9hQila4NoJT2+aQEKsjVON9D3a727naKDFUcKDg6P4KqS+yOKgR+QH
|
30
|
+
D8llK3JPaqKXuJkbd8jKchDk0Q+fA8Klan5SSnm7pMD51QM1mPsVPm5bEw5ib0bn
|
31
|
+
oR3hTQ==
|
33
32
|
-----END CERTIFICATE-----
|
34
|
-
date: 2020-07-
|
33
|
+
date: 2020-07-16 00:00:00.000000000 Z
|
35
34
|
dependencies:
|
36
35
|
- !ruby/object:Gem::Dependency
|
37
36
|
name: configurability
|
metadata.gz.sig
CHANGED
Binary file
|