summaryrefslogtreecommitdiff
path: root/manifests/letsencrypt.pp
blob: b04072430a53e06f527baf42ea9ba9c13a088e74 (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
36
37
38
39
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])
    }
  }

  # TODO this requires that we have the webserver in question started.
  # TODO we also have the bootstrap problem, which I should find a
  # common solution for

  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, ],
  }
}