Defined Type: cfssl::signer

Defined in:
modules/cfssl/manifests/signer.pp

Summary

configure cfssl api service

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • ca_key_content (Optional[Sensitive[String]]) (defaults to: undef)

    content of the CA private key

  • ca_cert_content (Optional[String]) (defaults to: undef)

    content of the CA public key

  • listen_addr (Stdlib::Host) (defaults to: $facts['networking']['fqdn'])

    hostname of the cfssl server

  • listen_port (Stdlib::Port) (defaults to: 8888)

    port of the cfssl server

  • log_level (Cfssl::Loglevel) (defaults to: 'info')

    the logging level

  • default_auth_key (String) (defaults to: 'default_auth')

    the default authentication key

  • default_expiry (Cfssl::Expiry) (defaults to: '672h')

    the default signing expiry time

  • default_usages (Array[Cfssl::Usage]) (defaults to: ['signing', 'key encipherment', 'client auth'])

    the default signing usages

  • default_crl_url (Stdlib::HTTPUrl) (defaults to: "http://${listen_addr}/crl")

    the URL of the CRL

  • default_ocsp_url (Stdlib::HTTPUrl) (defaults to: "http://${listen_addr}/ocsp")

    the URL of the OCSP responder

  • serve_ensure (Wmflib::Ensure) (defaults to: 'absent')

    ensurable paramter for local serve service

  • manage_db (Boolean) (defaults to: true)

    boolean to manage the db

  • manage_services (Boolean) (defaults to: true)

    boolean to manage the services

  • db_driver (Cfssl::DB_driver) (defaults to: 'sqlite3')

    DB Driver

  • db_user (String) (defaults to: 'cfssl')

    DB user

  • db_pass (Sensitive[String[1]]) (defaults to: Sensitive('changeme'))

    DB pass

  • db_name (String) (defaults to: 'cfssl')

    DB name

  • db_host (Stdlib::Host) (defaults to: 'localhost')

    DB host

  • profiles (Hash[String, Cfssl::Profile]) (defaults to: {})

    A hash of signing profiles

  • auth_keys (Hash[String, Cfssl::Auth_key]) (defaults to: {})

    A hash of authentication keys, this must contain an entry for the default_auth_key

  • serve_service (Optional[String]) (defaults to: undef)

    Name of the service seving this signer e.g. the multirootca

  • db_conf_file (Optional[Stdlib::Unixpath]) (defaults to: undef)

    database config file location

  • ca_key_file (Optional[Stdlib::Unixpath]) (defaults to: undef)

    CA private key file location

  • ca_file (Optional[Stdlib::Unixpath]) (defaults to: undef)

    CA public key file location

  • ca_bundle_file (Optional[Stdlib::Unixpath]) (defaults to: undef)

    CA chain file including the root ca



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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'modules/cfssl/manifests/signer.pp', line 28

define cfssl::signer (
    Stdlib::Host                  $listen_addr      = $facts['networking']['fqdn'],
    Stdlib::Port                  $listen_port      = 8888,
    Cfssl::Loglevel               $log_level        = 'info',
    String                        $default_auth_key = 'default_auth',
    Cfssl::Expiry                 $default_expiry   = '672h',  # 28days
    Array[Cfssl::Usage]           $default_usages   = ['signing', 'key encipherment', 'client auth'],
    Stdlib::HTTPUrl               $default_crl_url  = "http://${listen_addr}/crl",
    Stdlib::HTTPUrl               $default_ocsp_url = "http://${listen_addr}/ocsp",
    Wmflib::Ensure                $serve_ensure     = 'absent',
    Boolean                       $manage_db        = true,
    Boolean                       $manage_services  = true,
    Cfssl::DB_driver              $db_driver        = 'sqlite3',
    String                        $db_user          = 'cfssl',
    Sensitive[String[1]]          $db_pass          = Sensitive('changeme'),
    String                        $db_name          = 'cfssl',
    Stdlib::Host                  $db_host          = 'localhost',
    Hash[String, Cfssl::Profile]  $profiles         = {},
    Hash[String, Cfssl::Auth_key] $auth_keys        = {},
    Optional[String]              $serve_service    = undef,
    Optional[Stdlib::Unixpath]    $db_conf_file     = undef,
    Optional[Stdlib::Unixpath]    $ca_key_file      = undef,
    Optional[Stdlib::Unixpath]    $ca_file          = undef,
    Optional[Stdlib::Unixpath]    $ca_bundle_file   = undef,
    Optional[Sensitive[String]]   $ca_key_content   = undef,
    Optional[String]              $ca_cert_content  = undef,
) {
    include cfssl

    $safe_title  = $title.regsubst('\W', '_', 'G')
    $conf_dir    = "${cfssl::signer_dir}/${safe_title}"
    $conf_file   = "${cfssl::signer_dir}/${safe_title}/cfssl.conf"
    $ca_dir      = "${conf_dir}/ca"
    $sqlite_path = "${conf_dir}/cfssl.db"

    $_db_conf_file  = pick($db_conf_file, "${conf_dir}/db.conf")
    $_ca_key_file   = pick($ca_key_file, "${ca_dir}/ca_key.pem")
    $_ca_file       = pick($ca_file, "${ca_dir}/ca.pem")

    # We only want to set up a notify if we are managing services
    # Or we are explicitly passing a service name to notify
    if $manage_services or $serve_service {
      $_serve_service = pick($serve_service, "cfssl-serve@${safe_title}")
      $notify_service = Service[$_serve_service]
    } else {
      $_serve_service = undef
      $notify_service = undef
    }


    cfssl::config{$safe_title:
        default_auth_key => $default_auth_key,
        default_expiry   => $default_expiry,
        default_usages   => $default_usages,
        default_crl_url  => $default_crl_url,
        default_ocsp_url => $default_ocsp_url,
        auth_keys        => $auth_keys,
        profiles         => $profiles,
        path             => $conf_file,
        notify           => $notify_service,
    }
    if $manage_db {
        cfssl::db {$safe_title:
            driver         => $db_driver,
            username       => $db_user,
            password       => $db_pass,
            dbname         => $db_name,
            host           => $db_host,
            notify_service => $_serve_service,
            sqlite_path    => $sqlite_path,
            conf_file      => $_db_conf_file,
        }
    }


    file{[$conf_dir, $ca_dir]:
        ensure  => directory,
        mode    => '0550',
        owner   => 'root',
        group   => 'root',
        require => Package[$cfssl::packages];

    }
    if $ca_key_content and $ca_cert_content {
        file {
            default:
                ensure => file,
                owner  => 'root',
                group  => 'root',
                mode   => '0400',
                notify => $notify_service;
            $_ca_key_file:
                show_diff => false,
                content   => $ca_key_content;
            $_ca_file:
                content => $ca_cert_content,
                mode    => '0444';
        }
    }
    if $manage_services {
        systemd::service {$_serve_service:
            ensure  => $serve_ensure,
            content => template('cfssl/cfssl.service.erb'),
            restart => true,
        }
    }
}