summaryrefslogtreecommitdiffstats
path: root/modules/certbot/manifests/init.pp
blob: 917e8a65e24825c0c3684d4623dba8921d59142b (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
class certbot($config_dir=undef) {
  if $config_dir {
    $_config_dir = $config_dir
  }
  else {
    $_config_dir = "/etc/letsencrypt"
  }

  include cron
  include nginx

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

  file {
    '/etc/cron.daily/certbot':
      content => template('certbot/certbot'),
      mode => '0755',
      require => [
        Package['certbot'],
        Class['cron'],
      ];
    "${_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/bootstrap-certbot":
      source => 'puppet:///modules/certbot/bootstrap-certbot',
      mode => '0755';
  }

  exec { "initial certbot run":
    provider => shell,
    command => "/usr/local/bin/bootstrap-certbot ${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/bootstrap-certbot'],
    ],
  }
}