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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 051cdb537eac2fcc9d75f9f3c710a698e9aa719488cf70eb08754700bd76bb96
4
- data.tar.gz: d3e9a47c6af77ac7b537f5ca3ef1927f786c1dc191e048716f641e78e546c8b4
3
+ metadata.gz: f30fb65c28ed9ed46e7e4778e1a53ddc6a62e56c2d966ec51a7bf386bf111fb2
4
+ data.tar.gz: 8fb32494e41a1836deade9158906a803f16afa1b65baa350cf46936cec49525e
5
5
  SHA512:
6
- metadata.gz: 45fc21828ed7e87666a90ca5c8cbd43ef145b0fe4d213d130cf3f804da85029aff96677a588994f1c6966b6718e5e3b59a30af816d1b49a18516b25dcab56482
7
- data.tar.gz: d8129926634371f20491d07b28e3ff8d426d60c1e89aeea7d5ddc991eb9ea6d5d435be1643254025ec6ed756414e224bd8089c53b0fc0a994b97c486513d1612
6
+ metadata.gz: 73e175a3c18dfdcfd473d36ec4d2b8e47c4b613d7ceee7ef42dda2652a14f41c2fdc6e2c000fe13255115cb56cab582b235b30a4e5b780eae47fcf59b3304888
7
+ data.tar.gz: b2cbc3bbb891de3bc13d1623b2658b7dc6a0d7712135a11826a04a307d530e78d42ab751872e3c32647e4daec9a1629d7254a95aac517c733432b39168b94c3b
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
- ### tempdir: (optional) The destination temp directory. (defaults to /tmp)
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
- nocleanup = payload[ 'nocleanup' ]
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
- ssh_options = DEFAULT_SSH_OPTIONS.merge( port: port, keys: Array(key) )
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, nocleanup )
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/%s-%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 true.
166
+ ### will be deleted automatically unless +nocleanup+ is set
167
+ ### in the payload.
157
168
  ###
158
- def run_script( conn, remote_filename, nocleanup=false )
159
- @output = conn.exec!( remote_filename )
160
- conn.exec!( "rm #{remote_filename}" ) unless nocleanup
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.3.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
- MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQ8wDQYDVQQDDAZtYWhs
14
+ MIIDMDCCAhigAwIBAgIBAjANBgkqhkiG9w0BAQsFADA+MQ8wDQYDVQQDDAZtYWhs
15
15
  b24xFzAVBgoJkiaJk/IsZAEZFgdtYXJ0aW5pMRIwEAYKCZImi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Ar60f9NIYxua/vx
31
- n0YyneERGuHPSRZFgo72tGOqLpAlWnhPxRNqnayZmsg3hPPI87B6MTUI2UQ7VUdh
32
- UrSf3b+cPoC8PNfjp8zsdw==
24
+ AgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBRY8ea6
25
+ +6kAaW7ukKph2/4MTAD8/TANBgkqhkiG9w0BAQsFAAOCAQEAryZehbiEumHsUsce
26
+ FoBVuDoVdlJf8ae11G8IPXnEHCT8S5b+MBSYd55V3aGQm4bKoZA3GmmD8Y0a+oxt
27
+ l2kkTvE0r1bBb/qYQI97AjnqzHByseBRoaHtJ12JtrDEdi8y4jd5AJt4aW+G/roD
28
+ I2/ymUodKw9Cteom0RdJNzBUJ+Bq+qFOy7mVKNIfhXRRFYEy11y1712FsJXqUEku
29
+ qr3lnAEvEy9hQila4NoJT2+aQEKsjVON9D3a727naKDFUcKDg6P4KqS+yOKgR+QH
30
+ D8llK3JPaqKXuJkbd8jKchDk0Q+fA8Klan5SSnm7pMD51QM1mPsVPm5bEw5ib0bn
31
+ oR3hTQ==
33
32
  -----END CERTIFICATE-----
34
- date: 2020-07-09 00:00:00.000000000 Z
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