Better docs and cleanup.

master
Manager Bot 3 years ago
parent fe5f5269fe
commit 417952fae4
  1. 13
      Web/lib/MJB/Web/Task/CreateSSLCert.pm
  2. 13
      Web/lib/MJB/Web/Task/SyncSSLCerts.pm
  3. 13
      Web/lib/MJB/Web/Task/WildCardSSL.pm

@ -2,8 +2,15 @@ package MJB::Web::Task::CreateSSLCert;
use Mojo::Base 'MJB::Web::Task', -signatures; use Mojo::Base 'MJB::Web::Task', -signatures;
use IPC::Run3; use IPC::Run3;
#==
# This task creates SSL certificates on the certbot server, and then syncs them
# with the webservers.
#
# Certs are created with HTTP challenges.
#==
sub run ( $job, $blog_id ) { sub run ( $job, $blog_id ) {
$job->note( _mds_template => 'build_static' ); $job->note( _mds_template => 'create_ssl_cert' );
my $blog = $job->app->db->blog( $blog_id ); my $blog = $job->app->db->blog( $blog_id );
@ -12,10 +19,14 @@ sub run ( $job, $blog_id ) {
qw(sudo certbot certonly --standalone -d), $blog->domain->name, qw(--agree-tos --register-unsafely-without-email) qw(sudo certbot certonly --standalone -d), $blog->domain->name, qw(--agree-tos --register-unsafely-without-email)
]); ]);
$job->note( is_create_done => 1 );
# Push the SSL Certs to all hosts # Push the SSL Certs to all hosts
my $result_sync = $job->system_command( [ my $result_sync = $job->system_command( [
qw(sudo letsencrypt-cert-push) qw(sudo letsencrypt-cert-push)
]); ]);
$job->note( is_sync_done => 1 );
$job->finish(); $job->finish();
} }

@ -2,12 +2,23 @@ package MJB::Web::Task::SyncSSLCerts;
use Mojo::Base 'MJB::Web::Task', -signatures; use Mojo::Base 'MJB::Web::Task', -signatures;
use IPC::Run3; use IPC::Run3;
#==
# This task pushes all of the let's encrypt ssl certs from certbot to
# the webservers. It can be used after certificates have been renewed
# to ensure they are on the webservers.
#
# It should be in the certbot queue.
#==
sub run ( $job ) { sub run ( $job ) {
$job->note( _mds_template => 'build_static' ); $job->note( _mds_template => 'sync_ssl_certs' );
# Push the SSL Certificates # Push the SSL Certificates
my $result = $job->system_command( [ 'sudo', 'letsencrypt-cert-push' ] ); my $result = $job->system_command( [ 'sudo', 'letsencrypt-cert-push' ] );
$job->note( is_sync_done => 1 );
$job->finish(); $job->finish();
} }

@ -2,8 +2,15 @@ package MJB::Web::Task::WildCardSSL;
use Mojo::Base 'MJB::Web::Task', -signatures; use Mojo::Base 'MJB::Web::Task', -signatures;
use IPC::Run3; use IPC::Run3;
#==
# This task creates a wildcard ssl certificate for a hosted domain.
#
# It is currently limited to supporting only linode for dns challenges, but should be
# easy to expand to support other --dns- plugins.
#==
sub run ( $job, $hosted_domain_id ) { sub run ( $job, $hosted_domain_id ) {
$job->note( _mds_template => 'build_static' ); $job->note( _mds_template => 'wildcard_ssl' );
my $domain = $job->app->db->hosted_domain( $hosted_domain_id ); my $domain = $job->app->db->hosted_domain( $hosted_domain_id );
@ -12,10 +19,14 @@ sub run ( $job, $hosted_domain_id ) {
qw(sudo certbot certonly --dns-linode --dns-linode-credentials /etc/letsencrypt/.secrets/linode.ini -d ), '*.' . $domain->name, qw(--agree-tos --register-unsafely-without-email) qw(sudo certbot certonly --dns-linode --dns-linode-credentials /etc/letsencrypt/.secrets/linode.ini -d ), '*.' . $domain->name, qw(--agree-tos --register-unsafely-without-email)
]); ]);
$job->note( is_create_done => 1 );
# Push the SSL Certs to all hosts # Push the SSL Certs to all hosts
my $result_sync = $job->system_command( [ my $result_sync = $job->system_command( [
qw(sudo letsencrypt-cert-push) qw(sudo letsencrypt-cert-push)
]); ]);
$job->note( is_sync_done => 1 );
$job->finish(); $job->finish();
} }

Loading…
Cancel
Save