2018-02-27 18:58:42 +00:00
|
|
|
# Configuration for requesting a cert from letsencrypt, and storing it in vault.
|
|
|
|
#
|
|
|
|
|
2018-02-28 18:46:41 +00:00
|
|
|
class acme_vault::request (
|
2018-02-27 15:32:51 +00:00
|
|
|
$user = $::acme_vault::common::user,
|
|
|
|
$group = $::acme_vault::common::group,
|
|
|
|
$home_dir = $::acme_vault::common::home_dir,
|
|
|
|
$contact_email = $::acme_vault::common::contact_email,
|
|
|
|
$domains = $::acme_vault::common::domains,
|
2019-08-08 16:01:55 +00:00
|
|
|
$overrides = $::acme_vault::common::overrides,
|
2018-02-22 19:46:51 +00:00
|
|
|
|
|
|
|
$staging = $::acme_vault::params::staging,
|
|
|
|
$staging_url = $::acme_vault::params::staging_url,
|
|
|
|
$prod_url = $::acme_vault::params::prod_url,
|
|
|
|
|
|
|
|
$acme_revision = $::acme_vault::params::acme_revision,
|
|
|
|
$acme_repo_path = $::acme_vault::params::acme_repo_path,
|
|
|
|
$acme_script = $::acme_vault::params::acme_script,
|
2018-02-22 20:50:27 +00:00
|
|
|
|
2021-04-20 17:11:05 +00:00
|
|
|
$namecheap_username = $::acme_vault::params::namecheap_username,
|
|
|
|
$namecheap_api_key = $::acme_vault::params::namecheap_api_key,
|
|
|
|
$namecheap_sourceip = $::acme_vault::params::namecheap_sourceip,
|
2018-02-22 19:46:51 +00:00
|
|
|
|
|
|
|
) inherits acme_vault::params {
|
|
|
|
|
2018-02-22 20:50:27 +00:00
|
|
|
include acme_vault::common
|
2018-02-22 19:46:51 +00:00
|
|
|
|
2018-02-28 18:46:41 +00:00
|
|
|
$request_bashrc_template = @(END)
|
2018-02-23 15:03:41 +00:00
|
|
|
export TLDEXTRACT_CACHE=$HOME/.tld_set
|
2021-04-20 17:11:05 +00:00
|
|
|
export NAMECHEAP_USERNAME=<%= @namecheap_username %>
|
|
|
|
export NAMECHEAP_API_KEY=<%= @namecheap_api_key %>
|
|
|
|
export NAMECHEAP_SOURCEIP=<%= @namecheap_sourceip %>
|
2018-02-22 20:50:27 +00:00
|
|
|
END
|
2018-02-22 19:46:51 +00:00
|
|
|
|
2018-02-23 15:03:41 +00:00
|
|
|
# variables in bashrc
|
2018-02-28 18:46:41 +00:00
|
|
|
concat::fragment { 'request_bashrc':
|
2018-02-22 20:50:27 +00:00
|
|
|
target => "${home_dir}/.bashrc",
|
2018-02-28 18:46:41 +00:00
|
|
|
content => inline_template($request_bashrc_template),
|
2018-02-26 19:54:07 +00:00
|
|
|
order => '02',
|
2018-02-22 19:46:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# checkout acme repo
|
|
|
|
vcsrepo { $acme_repo_path:
|
|
|
|
ensure => present,
|
|
|
|
provider => git,
|
2018-02-26 19:54:07 +00:00
|
|
|
source => 'https://github.com/Neilpang/acme.sh.git',
|
2018-02-22 19:46:51 +00:00
|
|
|
revision => $acme_revision,
|
|
|
|
}
|
|
|
|
|
2018-02-28 18:46:41 +00:00
|
|
|
file { "${home_dir}/.acme.sh":
|
|
|
|
ensure => directory,
|
|
|
|
owner => $user,
|
|
|
|
group => $group,
|
|
|
|
mode => '0700',
|
|
|
|
} ->
|
|
|
|
file { "${home_dir}/.acme.sh/account.conf":
|
|
|
|
ensure => present,
|
|
|
|
owner => $user,
|
|
|
|
group => $group,
|
|
|
|
mode => '0600',
|
|
|
|
} ->
|
|
|
|
file_line { ' add email to acme conf':
|
|
|
|
path => "${home_dir}/.acme.sh/account.conf",
|
2018-03-02 15:28:15 +00:00
|
|
|
line => "ACCOUNT_EMAIL='${contact_email}'",
|
2018-02-28 18:46:41 +00:00
|
|
|
match => '^ACCOUNT_EMAIL=.*$',
|
|
|
|
}
|
|
|
|
|
2018-02-22 20:50:27 +00:00
|
|
|
# create issue scripts
|
2018-02-22 19:46:51 +00:00
|
|
|
$domains.each |$domain, $d_list| {
|
|
|
|
file {"/${home_dir}/${domain}.sh":
|
2018-02-26 19:54:07 +00:00
|
|
|
ensure => present,
|
|
|
|
mode => '0700',
|
|
|
|
owner => $user,
|
|
|
|
group => $group,
|
2018-02-22 19:46:51 +00:00
|
|
|
|
2018-02-26 19:54:07 +00:00
|
|
|
content => epp('acme_vault/domain.epp', {
|
|
|
|
acme_script => $acme_script,
|
2018-02-22 19:46:51 +00:00
|
|
|
domain => $domain,
|
|
|
|
domains => $d_list,
|
|
|
|
staging => $staging,
|
|
|
|
staging_url => $staging_url,
|
|
|
|
prod_url => $prod_url,
|
2019-08-08 16:01:55 +00:00
|
|
|
overrides => $overrides,
|
2018-02-26 19:54:07 +00:00
|
|
|
}
|
2018-02-22 20:50:27 +00:00
|
|
|
)
|
2018-02-22 19:46:51 +00:00
|
|
|
}
|
2018-02-23 15:03:41 +00:00
|
|
|
cron { "${domain}_issue":
|
2018-02-26 19:54:07 +00:00
|
|
|
command => "${home_dir}/${domain}.sh",
|
|
|
|
user => $user,
|
|
|
|
weekday => 1,
|
2018-03-05 18:23:44 +00:00
|
|
|
hour => 11,
|
|
|
|
minute => 28,
|
2018-02-23 15:03:41 +00:00
|
|
|
}
|
2018-02-22 19:46:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|