diff options
-rw-r--r-- | app/jobs/govuk_guix/create_data_snapshot_job.rb | 23 | ||||
-rw-r--r-- | app/models/backends/terraform_aws/backend_methods.rb | 1 |
2 files changed, 7 insertions, 17 deletions
diff --git a/app/jobs/govuk_guix/create_data_snapshot_job.rb b/app/jobs/govuk_guix/create_data_snapshot_job.rb index 91f3904..d6345a0 100644 --- a/app/jobs/govuk_guix/create_data_snapshot_job.rb +++ b/app/jobs/govuk_guix/create_data_snapshot_job.rb @@ -24,20 +24,6 @@ class GovukGuix::CreateDataSnapshotJob < Que::Job @retry_interval = 30 - def enqueue(options = {}) - backend_type = options[:backend_type] - backend_id = options[:backend_id] - - remote_host = options[:run_remotely_on_host] - - if remote_host - raise 'backend_type missing' unless backend_type - raise 'backend_id missing' unless backend_id - end - - super(options) - end - def run(options = {}) data_snapshot_fields = {} @@ -46,6 +32,8 @@ class GovukGuix::CreateDataSnapshotJob < Que::Job if backend_type backend = Backends.find_by_type_and_id(backend_type, backend_id) data_snapshot_fields[:backend] = backend + + remote_host = backend.build_remote_host end revision_id = options[:revision_id] @@ -56,19 +44,22 @@ class GovukGuix::CreateDataSnapshotJob < Que::Job end data_snapshot_fields[:govuk_guix_revision] = revision - remote_host = options[:run_remotely_on_host] logger.info(self.class) do 'Creating new data snapshot' end if remote_host + # TODO: This doesn't use the private key specified by the + # backend, so it'll only work when the default SSH key has + # access to the remote host. + # Copy the revision to the remote host, to ensure it's available # there run_command( 'guix', 'copy', - "--to=#{remote_host}", + "--to=#{remote_host.user_at_address}", revision.store_path ) end diff --git a/app/models/backends/terraform_aws/backend_methods.rb b/app/models/backends/terraform_aws/backend_methods.rb index f069d77..5ade46c 100644 --- a/app/models/backends/terraform_aws/backend_methods.rb +++ b/app/models/backends/terraform_aws/backend_methods.rb @@ -21,7 +21,6 @@ module Backends::TerraformAws::BackendMethods def create_data_snapshot GovukGuix::CreateDataSnapshotJob.enqueue( - run_remotely_on_host: build_remote_host, backend_type: self.class.name, backend_id: id ) |