From 55f5c3e37782c39212493fd00937ff59d14cbef5 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Tue, 11 Aug 2020 11:14:38 -0400 Subject: [PATCH] Implement script-based restart method --- manifests/deploy.pp | 17 +++++------------ manifests/params.pp | 17 +++++++---------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/manifests/deploy.pp b/manifests/deploy.pp index 34ac066..df0ae4c 100644 --- a/manifests/deploy.pp +++ b/manifests/deploy.pp @@ -8,8 +8,8 @@ class acme_vault::deploy( $domains = $::acme_vault::common::domains, $cert_destination_path = $::acme_vault::params::cert_destination_path, - $restart = $::acme_vault::params::restart, - $restart_command = $::acme_vault::params::restart_command, + $deploy_scripts = $::acme_vault::params::deploy_scripts, + $restart_method = $::acme_vault::params::restart_method, ) inherits acme_vault::params { include acme_vault::common @@ -23,25 +23,18 @@ class acme_vault::deploy( source => 'puppet:///modules/acme_vault/check_cert.sh', } - # ensure destination path exists - file {$cert_destination_path: + # ensure destination paths exist + file {[$cert_destination_path, $deploy_scripts]: ensure => directory, owner => $user, group => $group, mode => '0750', } - # cron job for deploy - if $restart { - $restart_suffix = "&& ${restart_command}" - } else { - $restart_suffix = '' - } - # go through each domain, setup cron, and ensure the destination dir exists $domains.each |$domain, $d_list| { cron { "${domain}_deploy": - command => ". \$HOME/.bashrc && ${home_dir}/check_cert.sh ${domain} ${cert_destination_path} ${restart_suffix}", + command => ". \$HOME/.bashrc && ${home_dir}/check_cert.sh ${domain} ${cert_destination_path} && ${restart_method}", user => $user, weekday => 2, hour => 11, diff --git a/manifests/params.pp b/manifests/params.pp index 82ac7d0..c82955d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -26,16 +26,13 @@ class acme_vault::params { $acme_repo_path = "${home_dir}/acme.sh" $acme_script = "${acme_repo_path}/acme.sh" - # lexicon - $lexicon_provider = undef - $lexicon_username = undef - $lexicon_token = undef + # lexicon + $lexicon_provider = undef + $lexicon_username = undef + $lexicon_token = undef # settings for deploy - - $cert_destination_path = '/etc/acme/' - - $restart = false - $restart_command = 'echo restart!' - + $cert_destination_path = '/etc/acme' + $deploy_scripts = "${cert_destination_path}/deploy.d" + $restart_method = "for f in ${deploy_scripts}/*.sh; do \"\$f\"; done" }