summaryrefslogtreecommitdiffstats
path: root/modules/certbot/manifests/init.pp
blob: b2059a4be10d4a415328f41de532a3b0f8059212 (plain) (blame)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class certbot($config_dir=undef) {
  if $config_dir {
    $_config_dir = $config_dir
  }
  else {
    $_config_dir = "/etc/letsencrypt"
  }

  include nginx

  $primary_domain = "tozt.net"
  $secondary_domains = [
    "blog.tozt.net",
    "paste.tozt.net",
    "git.tozt.net",
    "rss.tozt.net",
    "metabase.tozt.net",
    "bitwarden.tozt.net",
    "prometheus.tozt.net",
    "grafana.tozt.net",
  ]

  package {
    [
      'certbot',
      'certbot-nginx',
    ]:
    ensure => installed;
  }

  file {
    "${_config_dir}/renewal-hooks":
      ensure => directory,
      require => Package['certbot'];
    "${_config_dir}/renewal-hooks/deploy":
      ensure => directory,
      require => File["${_config_dir}/renewal-hooks"];
    "${_config_dir}/renewal-hooks/deploy/00-generate-pfx":
      source => 'puppet:///modules/certbot/generate-pfx',
      mode => '0755',
      require => File["${_config_dir}/renewal-hooks/deploy"];
    "${_config_dir}/renewal-hooks/deploy/10-reload-cert":
      source => 'puppet:///modules/certbot/reload-cert',
      mode => '0755',
      require => File["${_config_dir}/renewal-hooks/deploy"];
    "${_config_dir}/renewal-hooks/deploy/reload-cert":
      ensure => absent;
    "/usr/local/bin/certbot-tozt":
      content => template('certbot/certbot-tozt'),
      mode => '0755';
  }

  cron::job { "certbot":
    frequency => "daily",
    content => template('certbot/certbot'),
    require => Package['certbot'];
  }

  exec { "initial certbot run":
    provider => shell,
    command => "/usr/local/bin/certbot-tozt ${config_dir}",
    creates => "${_config_dir}/live",
    require => [
      Package["certbot"],
      # not Class["nginx"], because of circular dependencies with nginx::site
      Package["nginx"],
      Package["certbot-nginx"],
      File['/usr/local/bin/certbot-tozt'],
    ],
  }
}