symphony-ssh 0.2.1 → 0.3.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: 887495520934221996a536e10f063f35fc50d7c22a5abe19a336a035af459453
4
- data.tar.gz: 72f3f4863fc6fadae251d5f1676ffb0a22cfc99f0d2d5a3089d196588f322274
3
+ metadata.gz: 051cdb537eac2fcc9d75f9f3c710a698e9aa719488cf70eb08754700bd76bb96
4
+ data.tar.gz: d3e9a47c6af77ac7b537f5ca3ef1927f786c1dc191e048716f641e78e546c8b4
5
5
  SHA512:
6
- metadata.gz: 0f5d164ea4685fdbb739bbd6e08fe21fd2f031f976cafc41dd38ef4952c417810dc85fad86343776b32be4bf2309a0b2a800bd4eb7fb806a59d79df2b02e7798
7
- data.tar.gz: d6bf38d3a5835c6fa66309763138b5472fa32536dae3406230d51d358ec65d7b14a328f71c4caf671a75abfa69d375643989b614987e58f540b6b95d39343d6d
6
+ metadata.gz: 45fc21828ed7e87666a90ca5c8cbd43ef145b0fe4d213d130cf3f804da85029aff96677a588994f1c6966b6718e5e3b59a30af816d1b49a18516b25dcab56482
7
+ data.tar.gz: d8129926634371f20491d07b28e3ff8d426d60c1e89aeea7d5ddc991eb9ea6d5d435be1643254025ec6ed756414e224bd8089c53b0fc0a994b97c486513d1612
Binary file
Binary file
@@ -19,6 +19,7 @@ require 'symphony/task' unless defined?( Symphony::Task )
19
19
  ### command: (required) The command to run on the remote host
20
20
  ### port: (optional) The port to connect to (defaults to 22)
21
21
  ### opts: (optional) Explicit SSH client options
22
+ ### env: (optional) A hash of environment vars to set for the connection.
22
23
  ### user: (optional) The user to connect as (defaults to root)
23
24
  ### key: (optional) The path to an SSH private key
24
25
  ###
@@ -86,17 +87,16 @@ class Symphony::Task::SSH < Symphony::Task
86
87
  end
87
88
 
88
89
 
89
- ### Perform the ssh connection, passing the command to the pipe
90
- ### and retreiving any output from the remote end.
90
+ ### Perform the ssh connection in 'exec' mode, and retrieve any
91
+ ### output from the remote end.
91
92
  ###
92
93
  def work( payload, metadata )
93
- command = payload[ 'command' ]
94
- raise ArgumentError, "Missing required option 'command'" unless command
94
+ raise ArgumentError, "Missing required option 'command'" unless payload[ 'command' ]
95
95
  raise ArgumentError, "Missing required option 'host'" unless payload[ 'host' ]
96
96
 
97
97
  exitcode = self.open_connection( payload, metadata ) do |reader, writer|
98
- self.log.debug "Writing command #{command}..."
99
- writer.puts( command )
98
+ #self.log.debug "Writing command #{command}..."
99
+ #writer.puts( command )
100
100
  self.log.debug " closing child's writer."
101
101
  writer.close
102
102
  self.log.debug " reading from child."
@@ -123,6 +123,7 @@ class Symphony::Task::SSH < Symphony::Task
123
123
  opts = payload[ 'opts' ] || Symphony::Task::SSH.opts
124
124
  user = payload[ 'user' ] || Symphony::Task::SSH.user
125
125
  key = payload[ 'key' ] || Symphony::Task::SSH.key
126
+ env = payload[ 'env' ] || {}
126
127
 
127
128
  cmd = []
128
129
  cmd << Symphony::Task::SSH.path
@@ -132,23 +133,30 @@ class Symphony::Task::SSH < Symphony::Task
132
133
  cmd << '-i' << key if key
133
134
  cmd << '-l' << user
134
135
  cmd << payload[ 'host' ]
136
+ cmd << payload[ 'command' ]
135
137
  cmd.flatten!
136
138
  self.log.debug "Running SSH command with: %p" % [ Shellwords.shelljoin(cmd) ]
137
139
 
138
140
  parent_reader, child_writer = IO.pipe
139
141
  child_reader, parent_writer = IO.pipe
140
142
 
141
- pid = Process.spawn( *cmd, :out => child_writer, :in => child_reader, :close_others => true )
143
+ pid = Process.spawn( env, *cmd,
144
+ out: child_writer,
145
+ in: child_reader,
146
+ close_others: true,
147
+ unsetenv_others: true
148
+ )
149
+
142
150
  child_writer.close
143
151
  child_reader.close
144
152
 
145
153
  self.log.debug "Yielding back to the run block."
146
154
  @output = yield( parent_reader, parent_writer )
147
- @output = @output.split("\n").reject{|l| l =~ SSH_CLEANUP }.join
155
+ @output = @output.split( /\r?\n/ ).reject{|l| l =~ SSH_CLEANUP }.join
148
156
  self.log.debug " run block done."
149
157
 
150
- status = nil
151
-
158
+ rescue => err
159
+ self.log.error( err.message )
152
160
  ensure
153
161
  if pid
154
162
  active = Process.kill( 0, pid ) rescue false
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.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mahlon E. Smith
@@ -11,31 +11,27 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIENDCCApygAwIBAgIBATANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdtYWhs
15
- b24vREM9bWFydGluaS9EQz1udTAeFw0yMDAyMTkyMTU4NDBaFw0yMTAyMTgyMTU4
16
- NDBaMCIxIDAeBgNVBAMMF21haGxvbi9EQz1tYXJ0aW5pL0RDPW51MIIBojANBgkq
17
- hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA3cz7ILM8n+Y5nvz7mVRVqE8LusWdT8NX
18
- nlnETynDndenI+a2S3j22DR+U4ooGUjuCHE3iR1CVmTDGbxFfNRfmnC1AN9Hybat
19
- ewW+onvMBye7yfO0bJB5vkqaW5vd35rzquOffgBtJMo7rPRu6pX8RkL34Wnew4J7
20
- POooUcYbWSAO934HSCUC8wVm6b4v/ejVF1Lk44Dz45jtMqtR7KTAtpipdbTXAarO
21
- HQy3eVes/0oTqhk4CP50r1KP09nUHTn2lzVaCN9vmNE/Jwe0AuQ9ImvZXPpCsMMl
22
- V03/tuJ++48sVmOIusJkASPupXcdI6zqsjYw2vLMFtuYNskRSvwbn6Wm6x9hLWWj
23
- IRp5FvHPORLRCHFizXRmXZ3PyFHqbv6m4yG0SyfMzOXPk3Hn5dqqmK+BFCihTZIN
24
- fqpBmuxyNEE21fSO9ALLlWeW9ffg9Ye5Sc1n3yEyv8rPb9VDvi1B5N6xIcDF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+ ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDpXGN0YbMVpYv4EoiCxpQw
19
+ sxKdyhlkvpvENUkpEhbpnEuMKXgUfRHO4T/vBZf0h8eYgwnrHCRhAeIqesFKfoj9
20
+ mpEJk5JUuADOAz18aT+v24UqAtJdiwBJLuqhslSNB6CFXZv3OOMny9bjoJegz0hI
21
+ Fht9ppCuNmxJNd+L3zAX8lD01RUWNRC+8L5QLCjViJtjFDDCFfh9NCirs+XnTCzo
22
+ AJgFbsZIzFJtSiXUtFgscKr4Ik8ruhRbPbYbmx9rf6W74aTMPxggq/d3gj0Eh32y
23
+ WsXsQ5giVnmkbsRkBNu3QyZ8Xr5+7mvy5AWyqXKOrcW7lnYaob6Z9x/MGXGNeD6j
24
+ AgMBAAGjdTBzMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBRY8ea6
25
+ +6kAaW7ukKph2/4MTAD8/TAcBgNVHREEFTATgRFtYWhsb25AbWFydGluaS5udTAc
26
+ BgNVHRIEFTATgRFtYWhsb25AbWFydGluaS5udTANBgkqhkiG9w0BAQUFAAOCAQEA
27
+ 00FljTeSNaYUqJ59yLRA+i43wVNiO4ETQQu6fYQCPns12Sm90spOJb3SmTDkJ7CY
28
+ dixOQg5A3Et1LVS+Z/YfH1TAbb50oTWbZbTW2JknHS0hohq3UF1pvbkk1niZ26er
29
+ skJ352MUfcyaUkQyMmCjL/BpkDutYH5OCGh+FmK8+mH7SoC9Nr48WwH2prVdHs3y
30
+ OMWFgB33sXdj1XqOd2Rw1WPgAeMeDqWeIrRMpUhNZOwroaA1MAr60f9NIYxua/vx
31
+ n0YyneERGuHPSRZFgo72tGOqLpAlWnhPxRNqnayZmsg3hPPI87B6MTUI2UQ7VUdh
32
+ UrSf3b+cPoC8PNfjp8zsdw==
37
33
  -----END CERTIFICATE-----
38
- date: 2020-04-07 00:00:00.000000000 Z
34
+ date: 2020-07-09 00:00:00.000000000 Z
39
35
  dependencies:
40
36
  - !ruby/object:Gem::Dependency
41
37
  name: configurability
@@ -77,70 +73,70 @@ dependencies:
77
73
  requirements:
78
74
  - - "~>"
79
75
  - !ruby/object:Gem::Version
80
- version: '1.2'
76
+ version: '1.3'
81
77
  type: :runtime
82
78
  prerelease: false
83
79
  version_requirements: !ruby/object:Gem::Requirement
84
80
  requirements:
85
81
  - - "~>"
86
82
  - !ruby/object:Gem::Version
87
- version: '1.2'
83
+ version: '1.3'
88
84
  - !ruby/object:Gem::Dependency
89
85
  name: net-ssh
90
86
  requirement: !ruby/object:Gem::Requirement
91
87
  requirements:
92
88
  - - "~>"
93
89
  - !ruby/object:Gem::Version
94
- version: '5.0'
90
+ version: '6.0'
95
91
  type: :runtime
96
92
  prerelease: false
97
93
  version_requirements: !ruby/object:Gem::Requirement
98
94
  requirements:
99
95
  - - "~>"
100
96
  - !ruby/object:Gem::Version
101
- version: '5.0'
97
+ version: '6.0'
102
98
  - !ruby/object:Gem::Dependency
103
99
  name: net-sftp
104
100
  requirement: !ruby/object:Gem::Requirement
105
101
  requirements:
106
102
  - - "~>"
107
103
  - !ruby/object:Gem::Version
108
- version: '2.1'
104
+ version: '3.0'
109
105
  type: :runtime
110
106
  prerelease: false
111
107
  version_requirements: !ruby/object:Gem::Requirement
112
108
  requirements:
113
109
  - - "~>"
114
110
  - !ruby/object:Gem::Version
115
- version: '2.1'
111
+ version: '3.0'
116
112
  - !ruby/object:Gem::Dependency
117
113
  name: rspec
118
114
  requirement: !ruby/object:Gem::Requirement
119
115
  requirements:
120
116
  - - "~>"
121
117
  - !ruby/object:Gem::Version
122
- version: '3.7'
118
+ version: '3.9'
123
119
  type: :development
124
120
  prerelease: false
125
121
  version_requirements: !ruby/object:Gem::Requirement
126
122
  requirements:
127
123
  - - "~>"
128
124
  - !ruby/object:Gem::Version
129
- version: '3.7'
125
+ version: '3.9'
130
126
  - !ruby/object:Gem::Dependency
131
127
  name: simplecov
132
128
  requirement: !ruby/object:Gem::Requirement
133
129
  requirements:
134
130
  - - "~>"
135
131
  - !ruby/object:Gem::Version
136
- version: '0.16'
132
+ version: '0.18'
137
133
  type: :development
138
134
  prerelease: false
139
135
  version_requirements: !ruby/object:Gem::Requirement
140
136
  requirements:
141
137
  - - "~>"
142
138
  - !ruby/object:Gem::Version
143
- version: '0.16'
139
+ version: '0.18'
144
140
  description: |
145
141
  A small collection of base classes used for interacting with remote
146
142
  machines over ssh. With them, you can use AMQP (via Symphony) to
@@ -175,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
171
  - !ruby/object:Gem::Version
176
172
  version: '0'
177
173
  requirements: []
178
- rubygems_version: 3.0.6
174
+ rubygems_version: 3.1.2
179
175
  signing_key:
180
176
  specification_version: 4
181
177
  summary: Base classes for using Symphony with ssh.
Binary file