aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-06-03 13:08:11 +0100
committerChristopher Baines <mail@cbaines.net>2018-06-03 14:09:13 +0100
commitf7642828314a5accf4221e0ebf0deb18ae6173e2 (patch)
tree07eb94c5e1f027024ac81dbd5f773f736307daa0
parent93c1c6e5b76ed712f6c5107c6a124025279996d6 (diff)
downloadgovuk-mini-environment-admin-f7642828314a5accf4221e0ebf0deb18ae6173e2.tar
govuk-mini-environment-admin-f7642828314a5accf4221e0ebf0deb18ae6173e2.tar.gz
Enhance run_command in GovukGuix::Job to handle remote hosts
-rw-r--r--app/jobs/govuk_guix/job.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/app/jobs/govuk_guix/job.rb b/app/jobs/govuk_guix/job.rb
index 342eb9d..a48ce02 100644
--- a/app/jobs/govuk_guix/job.rb
+++ b/app/jobs/govuk_guix/job.rb
@@ -19,9 +19,22 @@
# <http://www.gnu.org/licenses/>.
require 'open3'
+require 'shellwords'
class GovukGuix::Job < Que::Job
- def run_command(*command)
+ def run_command(*command, run_remotely_on_host: nil)
+ if run_remotely_on_host
+ command = command.map do |arg|
+ Shellwords.escape(arg)
+ end
+
+ command = [
+ 'ssh',
+ run_remotely_on_host,
+ *command
+ ]
+ end
+
logger.debug("#{self.class}: Running command #{command.join(' ')}")
Open3.popen2e(*command) do |_stdin, stdout_and_stderr, wait_thr|