Defined Type: tlsproxy::localssl

Defined in:
modules/tlsproxy/manifests/localssl.pp

Overview

Parameters:

  • certs (Array) (defaults to: [])
  • certs_active (Array) (defaults to: [])
  • acme_chief (Boolean) (defaults to: false)
  • acme_certname (String[1]) (defaults to: $title)
  • server_name (Stdlib::Host) (defaults to: $::fqdn)
  • server_aliases (Array[Stdlib::Host]) (defaults to: [])
  • default_server (Boolean) (defaults to: false)
  • upstream_ip (Stdlib::IP::Address) (defaults to: $::ipaddress)
  • upstream_ports (Array[Stdlib::Port]) (defaults to: [80])
  • tls_port (Stdlib::Port) (defaults to: 443)
  • redir_port (Optional[Stdlib::Port]) (defaults to: undef)
  • skip_private (Boolean) (defaults to: false)
  • access_log (Boolean) (defaults to: false)
  • keepalive_timeout (Integer) (defaults to: 60)
  • keepalive_requests (Integer) (defaults to: 100)
  • read_timeout (Integer) (defaults to: 180)
  • only_get_requests (Boolean) (defaults to: false)
  • enable_http2 (Boolean) (defaults to: false)
  • cfssl_paths (Hash[String[1], Stdlib::Unixpath]) (defaults to: {})


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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'modules/tlsproxy/manifests/localssl.pp', line 82

define tlsproxy::localssl(
    Array                             $certs              = [],
    Array                             $certs_active       = [],
    Boolean                           $acme_chief         = false,
    String[1]                         $acme_certname      = $title,
    Stdlib::Host                      $server_name        = $::fqdn,
    Array[Stdlib::Host]               $server_aliases     = [],
    Boolean                           $default_server     = false,
    Stdlib::IP::Address               $upstream_ip        = $::ipaddress,
    Array[Stdlib::Port]               $upstream_ports     = [80],
    Stdlib::Port                      $tls_port           = 443,
    Optional[Stdlib::Port]            $redir_port         = undef,
    Boolean                           $skip_private       = false,
    Boolean                           $access_log         = false,
    Integer                           $keepalive_timeout  = 60,
    Integer                           $keepalive_requests = 100,
    Integer                           $read_timeout       = 180,
    Boolean                           $only_get_requests  = false,
    Boolean                           $enable_http2       = false,
    Hash[String[1], Stdlib::Unixpath] $cfssl_paths        = {}
) {
    if $cfssl_paths.empty and $certs.empty and !acme_chief {
        fail('Must provide exactly one of certs, cfssl_paths or acme_chief')
    }

    if $redir_port != undef and $tls_port != 443 {
        fail('http -> https redirect only works with default 443 HTTPS port.')
    }

    # TODO: move this define to the profile module too?
    require ::profile::tlsproxy::instance

    $nginx_proxy_request_buffering = lookup('tlsproxy::localssl::proxy_request_buffering', {'default_value' => 'on'})
    # Maximum number of pending TCP Fast Open requests before falling back to
    # regular 3WHS. https://tools.ietf.org/html/rfc7413#section-5.1
    $fastopen_pending_max = lookup('tlsproxy::localssl::fastopen_pending_max', {'default_value' => 150})

    # Ensure that exactly one definition exists with default_server = true
    # for a given port. If multiple defines on the same port have default_server
    # set to true this resource will conflict.
    # we configure this resource as an exec which does nothing and should
    # never trigger.  We define the resource so it still allows us to catch multiple
    # definitions of default_server but shouldn't show as a change in puppet reporting
    if $default_server {
        exec { "tlsproxy localssl default_server on port ${tls_port}":
            command     => '/bin/true',
            onlyif      => '/bin/false',
            refreshonly => true,
        }
    }

    if !empty($certs) and !empty($certs_active) {
        # Ideally, we'd sanity-check that active is a subset of certs, too
        $certs_nginx = $certs_active
    } else {
        $certs_nginx = $certs
    }

    $certs.each |String $cert| {
        if !defined(Sslcert::Certificate[$cert]) {
            sslcert::certificate { $cert:
                skip_private => $skip_private,
                before       => Service['nginx'],
            }
        }
    }

    if $acme_chief {
        if !defined(Acme_chief::Cert[$acme_certname]) {
            acme_chief::cert { $acme_certname:
                puppet_svc => 'nginx',
            }
        }
    }
    unless $cfssl_paths.empty {
        File[$cfssl_paths.values] ~> Exec['nginx-reload']

        # the certificate renewal does not trigger any of the File
        # resources to get refreshed, so ensure we pick up the new
        # certs whenever the chain gets updated
        $chain_path = $cfssl_paths['chain']
        Exec["create chained cert ${chain_path}"] ~> Exec['nginx-reload']
    }

    # used in localssl.erb to template upstream definition name
    $basename = regsubst($title, '[\W_]', '-', 'G')

    nginx::site { $name:
        require => Exec["tlsproxy localssl default_server on port ${tls_port}"],    # Ensure a default_server has been defined
        content => template('tlsproxy/localssl.erb')
    }
}