From e3d4e2e7bf93356fafaff2398cec60d65d6b3873 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 14 Oct 2018 16:26:34 -0400 Subject: try to fix initial certbot provisioning --- modules/certbot/files/bootstrap-certbot | 50 +++++++++++++++++++++++++++++++++ modules/certbot/manifests/init.pp | 10 ++++--- 2 files changed, 56 insertions(+), 4 deletions(-) create mode 100755 modules/certbot/files/bootstrap-certbot (limited to 'modules/certbot') diff --git a/modules/certbot/files/bootstrap-certbot b/modules/certbot/files/bootstrap-certbot new file mode 100755 index 0000000..cb496f8 --- /dev/null +++ b/modules/certbot/files/bootstrap-certbot @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +set -eu +set -o pipefail + +# XXX update to real domain name + +config_dir="$1" +if systemctl is-active -q nginx; then + is_running=1 +else + is_running= +fi + +cleanup() { + if [ -z "$is_running" ]; then + systemctl stop nginx + fi + + if [ -e /etc/nginx/nginx.conf.backup ]; then + mv /etc/nginx/nginx.conf.backup /etc/nginx.conf + fi +} +trap cleanup EXIT + +mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup +cat > /etc/nginx/nginx.conf < 'puppet:///modules/certbot/reload-cert', require => File["${_config_dir}/renewal-hooks/deploy"]; + "/usr/local/bin/bootstrap-certbot": + source => 'puppet:///modules/certbot/bootstrap-certbot', + mode => '0755'; } exec { "initial certbot run": - # XXX update to real domain name - command => "/usr/bin/certbot -n --agree-tos -m doy@tozt.net --nginx -d new.tozt.net${config_dir_opts}", + provider => shell, + command => "/usr/local/bin/bootstrap-certbot ${config_dir}", creates => "${_config_dir}/live", require => [ Package["certbot"], # not Class["nginx"], because of circular dependencies with nginx::site Package["nginx"], Package["certbot-nginx"], + File['/usr/local/bin/bootstrap-certbot'], ], } } -- cgit v1.2.3-54-g00ecf