Puppet Class: letsencrypt::plugin::dns_cloudflare

Defined in:
manifests/plugin/dns_cloudflare.pp

Summary

Installs and configures the dns-cloudflare plugin

Overview

This class installs and configures the Let’s Encrypt dns-cloudflare plugin. certbot-dns-cloudflare.readthedocs.io

Parameters:

  • package_name (Optional[String[1]]) (defaults to: undef)

    The name of the package to install when $manage_package is true.

  • api_key (Optional[String[1]]) (defaults to: undef)

    Optional string, cloudflare api key value for authentication.

  • api_token (Optional[String[1]]) (defaults to: undef)

    Optional string, cloudflare api token value for authentication.

  • email (Optional[String[1]]) (defaults to: undef)

    Optional string, cloudflare account email address, used in conjunction with api_key.

  • config_path (Stdlib::Absolutepath) (defaults to: "${letsencrypt::config_dir}/dns-cloudflare.ini")

    The path to the configuration directory.

  • manage_package (Boolean) (defaults to: true)

    Manage the plugin package.

  • propagation_seconds (Integer) (defaults to: 10)

    Number of seconds to wait for the DNS server to propagate the DNS-01 challenge.



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
# File 'manifests/plugin/dns_cloudflare.pp', line 17

class letsencrypt::plugin::dns_cloudflare (
  Optional[String[1]] $package_name = undef,
  Optional[String[1]] $api_key      = undef,
  Optional[String[1]] $api_token    = undef,
  Optional[String[1]] $email        = undef,
  Stdlib::Absolutepath $config_path = "${letsencrypt::config_dir}/dns-cloudflare.ini",
  Boolean $manage_package           = true,
  Integer $propagation_seconds      = 10,
) {
  require letsencrypt::install

  if ! $api_key and ! $api_token {
    fail('No authentication method provided, please specify either api_token or api_key and api_email.')
  }

  if $manage_package {
    if ! $package_name {
      fail('No package name provided for certbot dns cloudflare plugin.')
    }

    package { $package_name:
      ensure => installed,
    }
  }

  if $api_token {
    $ini_vars = {
      dns_cloudflare_api_token => $api_token,
    }
  }
  else {
    if ! $email {
      fail('Cloudflare email not provided for specified api_key.')
    }

    $ini_vars = {
      dns_cloudflare_api_key => $api_key,
      dns_cloudflare_email   => $email,
    }
  }

  file { $config_path:
    ensure  => file,
    owner   => 'root',
    group   => 'root',
    mode    => '0400',
    content => epp('letsencrypt/ini.epp', {
        vars => { '' => $ini_vars },
    }),
  }
}