summaryrefslogtreecommitdiff
path: root/modules/profiles/manifests/letsencrypt.pp
blob: 48aa3a8b287a8bf002e3199378dd1aba99254bf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class profiles::letsencrypt (
  String $certname,
  Array[String] $domains,
  Enum['nginx','apache'] $provider,
  Optional[String] $nginx_plugin = undef,
  Optional[String] $apache_plugin = undef,
) {

  include ::letsencrypt

  $plugin = $provider
  $post_hook = $provider ? {
    'nginx'  => 'systemctl restart nginx.service',
    'apache' => 'systemctl restart apache2.service',
  }

  case $provider {
    'apache': {
      ensure_packages ([$apache_plugin])
    }
    'nginx': {
      ensure_packages ([$nginx_plugin])
    }
  }

  letsencrypt::certonly { $certname:
    ensure             => present,
    domains            => $domains,
    manage_cron        => true,
    plugin             => $plugin,
    additional_args    => [ '--quiet', ],
    # pre_hook_commands  => [ 'systemctl stop nginx.service', ],
    post_hook_commands => [ $post_hook, ],
  }
}