aboutsummaryrefslogtreecommitdiff
path: root/app/jobs
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-05-03 21:44:06 +0100
committerChristopher Baines <mail@cbaines.net>2018-05-03 21:44:06 +0100
commitfc1e5260603ff0f6030c4aed7874c8ea3b532e5c (patch)
treef2ae0482f4d60bb0a76328cee0c03dece172bb9d /app/jobs
parent807c10c5652423be96d125a502be222aa8d80119 (diff)
downloadgovuk-mini-environment-admin-fc1e5260603ff0f6030c4aed7874c8ea3b532e5c.tar
govuk-mini-environment-admin-fc1e5260603ff0f6030c4aed7874c8ea3b532e5c.tar.gz
Improve the AWS backend
This gets the AWS backend to the point where you can deploy the backend, and then a mini environment without any actions outside of the govuk-mini-environment-admin.
Diffstat (limited to 'app/jobs')
-rw-r--r--app/jobs/govuk_guix/build_job.rb26
-rw-r--r--app/jobs/govuk_guix/job.rb8
2 files changed, 27 insertions, 7 deletions
diff --git a/app/jobs/govuk_guix/build_job.rb b/app/jobs/govuk_guix/build_job.rb
index a74b928..fb5e256 100644
--- a/app/jobs/govuk_guix/build_job.rb
+++ b/app/jobs/govuk_guix/build_job.rb
@@ -27,22 +27,40 @@ class GovukGuix::BuildJob < GovukGuix::Job
@retry_interval = 30
- def run(mini_environment_id, services, arguments)
+ def run(mini_environment_id, options)
logger.info(self.class) do
"Building mini environment #{mini_environment_id}"
end
mini_environment = MiniEnvironment.find(mini_environment_id)
+ remote_host = options[:run_remotely_on_host]
+
+ if remote_host
+ ssh_command = ['ssh', remote_host]
+
+ # Copy the revision to the remote host, to ensure it's available
+ # there
+ run_command(
+ 'guix',
+ 'copy',
+ "--to=#{remote_host}",
+ mini_environment.govuk_guix_revision.store_path
+ )
+ else
+ ssh_command = []
+ end
+
output = run_command(
+ *ssh_command,
"#{mini_environment.govuk_guix_revision.store_path}/bin/govuk",
'system',
'build',
*hash_to_arguments(
- DEFAULT_ARGUMENTS.merge(arguments)
+ DEFAULT_ARGUMENTS.merge(options[:arguments])
),
*signon_user_arguments(mini_environment.signon_users),
- *services
+ *options[:services]
)
build_output = output.last.strip
@@ -69,7 +87,7 @@ class GovukGuix::BuildJob < GovukGuix::Job
def signon_user_arguments(signon_users)
signon_users.map do |signon_user|
- "--signon-user=#{signon_user_to_sexp(signon_user)}"
+ "--signon-user='#{signon_user_to_sexp(signon_user)}'"
end
end
diff --git a/app/jobs/govuk_guix/job.rb b/app/jobs/govuk_guix/job.rb
index c20b9de..b79d380 100644
--- a/app/jobs/govuk_guix/job.rb
+++ b/app/jobs/govuk_guix/job.rb
@@ -46,12 +46,14 @@ class GovukGuix::Job < Que::Job
def hash_to_arguments(hash)
hash.map do |(key, value)|
- transfomed_key = key.tr('_', '-')
+ transformed_key = key.tr('_', '-')
if value == true
- "--#{transfomed_key}"
+ "--#{transformed_key}"
+ elsif value.include? ' '
+ "--#{transformed_key}='#{value}'"
else
- "--#{transfomed_key}=#{value}"
+ "--#{transformed_key}=#{value}"
end
end
end