Puppet Class: letsencrypt::config

Defined in:
manifests/config.pp

Summary

Configures the Let's Encrypt client.

Overview

Parameters:

  • config_dir (Stdlib::Absolutepath) (defaults to: $letsencrypt::config_dir)
  • config_file (Stdlib::Absolutepath) (defaults to: $letsencrypt::config_file)
  • config (Hash) (defaults to: $letsencrypt::config)
  • email (Optional[String[1]]) (defaults to: $letsencrypt::email)
  • unsafe_registration (Boolean) (defaults to: $letsencrypt::unsafe_registration)
  • agree_tos (Boolean) (defaults to: $letsencrypt::agree_tos)


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
# File 'manifests/config.pp', line 5

class letsencrypt::config (
  Stdlib::Absolutepath $config_dir = $letsencrypt::config_dir,
  Stdlib::Absolutepath $config_file = $letsencrypt::config_file,
  Hash $config = $letsencrypt::config,
  Optional[String[1]] $email = $letsencrypt::email,
  Boolean $unsafe_registration = $letsencrypt::unsafe_registration,
  Boolean $agree_tos = $letsencrypt::agree_tos,
) {
  assert_private()

  unless $agree_tos {
    fail("You must agree to the Let's Encrypt Terms of Service! See: https://letsencrypt.org/repository for more information." )
  }

  file { $config_dir: ensure => directory }

  file { $letsencrypt::cron_scripts_path:
    ensure => directory,
    purge  => true,
  }

  if $email {
    $_config = merge($config, { 'email' => $email })
  } else {
    $_config = $config
  }

  ini_setting { "${config_file} register-unsafely-without-email true":
    ensure  => bool2str($unsafe_registration, 'present', 'absent'),
    path    => $config_file,
    section => '',
    setting => 'register-unsafely-without-email',
    value   => true,
  }

  unless 'email' in $_config {
    if $unsafe_registration {
      warning('No email address specified for the letsencrypt class! Registering unsafely!')
    } else {
      fail("Please specify an email address to register with Let's Encrypt using the \$email parameter on the letsencrypt class")
    }
  }

  $_config.each |$key,$value| {
    ini_setting { "${config_file} ${key} ${value}":
      ensure  => present,
      path    => $config_file,
      section => '',
      setting => $key,
      value   => $value,
      require => File[$config_dir],
    }
  }
}