5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 16:21:41 +00:00

feat: separar la creación de DP de njalla

This commit is contained in:
f 2023-03-17 17:39:41 -03:00
parent 2b340a4488
commit 29e1d09986

View file

@ -15,7 +15,7 @@ require 'njalla/v1'
class DeployDistributedPress < Deploy
store :values, accessors: %i[hostname remote_site_id remote_info], coder: JSON
before_create :create_remote_site!
before_create :create_remote_site!, :create_njalla_records!
# Actualiza la información y luego envía los cambios
#
@ -27,10 +27,9 @@ class DeployDistributedPress < Deploy
time_start
if remote_site_id.blank? || remote_info['njalla'].blank?
create_remote_site!
save
end
create_remote_site! if remote_site_id.blank?
create_njalla_records! if remote_info['njalla'].blank?
save
site_client.tap do |c|
stdout = Thread.new(publisher.logger_out) do |io|
@ -115,7 +114,16 @@ class DeployDistributedPress < Deploy
self.remote_site_id = created_site[:id]
self.remote_info = created_site.to_h
rescue DistributedPress::V1::Error
ExceptionNotifier.notify_exception(e, data: { site: site.name })
ensure
nil
end
# Crea los registros en Njalla
#
# @return [nil]
def create_njalla_records!
# XXX: Esto depende de nuestro DNS actual, cuando lo migremos hay
# que eliminarlo.
unless site.name.end_with? '.'
@ -123,7 +131,7 @@ class DeployDistributedPress < Deploy
self.remote_info['njalla']['a'] = njalla.add_record(name: site.name, type: 'CNAME', content: "#{Site.domain}.").to_h
self.remote_info['njalla']['ns'] = njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h
end
rescue DistributedPress::V1::Error, HTTParty::Error => e
rescue HTTParty::Error => e
ExceptionNotifier.notify_exception(e, data: { site: site.name })
ensure
nil