1
0
mirror of https://github.com/krislamo/puppet-acme_vault synced 2024-09-19 20:40:36 +00:00
puppet-acme_vault/manifests/deploy.pp
Kris Lamoureux 8d80daa9a7
Improve docs, scripts, and source .bashrc in cron
- Added comprehensive documentation for all Puppet classes
- Applied bash linting and made minor improvements to check_cert.sh
- Updated domain issue cron to source the .bashrc file
- Implemented small changes to address Puppet linting issues
2023-04-12 14:51:15 -04:00

68 lines
2.3 KiB
Puppet

# acme_vault::deploy
#
# This class configures the deployment of certificates from HashiCorp Vault
# to the filesystem. It sets up the necessary directory structure, scripts,
# and cron jobs to periodically check for and deploy updated certificates
# for the specified domains.
#
# @param user The system user for the acme_vault module.
# @param group The system group for the acme_vault module.
# @param home_dir The home directory for the acme_vault user.
# @param domains The list of domain names for which certificates will be deployed.
#
# @param cert_destination_path The directory where certificates will be deployed on the filesystem.
# @param deploy_scripts The directory where deployment scripts will be stored.
# @param restart_method The command to run after certificate deployment (e.g., to restart dependent services).
#
class acme_vault::deploy(
$user = $::acme_vault::common::user,
$group = $::acme_vault::common::group,
$home_dir = $::acme_vault::common::home_dir,
$domains = $::acme_vault::common::domains,
$cert_destination_path = $::acme_vault::params::cert_destination_path,
$deploy_scripts = $::acme_vault::params::deploy_scripts,
$restart_method = $::acme_vault::params::restart_method,
) inherits acme_vault::params {
include acme_vault::common
# copy down cert check script
file {"${home_dir}/check_cert.sh":
ensure => present,
owner => $user,
group => $group,
mode => '0750',
source => 'puppet:///modules/acme_vault/check_cert.sh',
}
# ensure destination paths exist
file {[$cert_destination_path, $deploy_scripts]:
ensure => directory,
owner => $user,
group => $group,
mode => '0750',
}
# 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_method}",
user => $user,
weekday => ['2-4'],
hour => ['11-16'],
minute => 30,
}
file {"${cert_destination_path}/${domain}":
ensure => directory,
owner => $user,
group => $group,
mode => '0750',
}
}
}