summaryrefslogtreecommitdiffstats
path: root/modules/certbot/manifests/init.pp
blob: 27d59a6f5df011bf2c210f0adc1d05f1ac2c9515 (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
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/reload-cert":
      source => 'puppet:///modules/certbot/reload-cert',
      require => File["${_config_dir}/renewal-hooks/deploy"];
    "/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'],
    ],
  }
}