X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fssl%2Fmanifests%2Fservice.pp;h=711f755b80a9ac9a2b3b0153d3e53785cc523d37;hb=1f1aa0ea7fee69c0fa68cd1150e5ccbbe25f1ead;hp=f0400525dd76313b9145e5911dacd9be03e0e67c;hpb=745714ee9bbb6fcbabbf46820358c1c4b7ee005d;p=mirror%2Fdsa-puppet.git diff --git a/modules/ssl/manifests/service.pp b/modules/ssl/manifests/service.pp index f0400525d..711f755b8 100644 --- a/modules/ssl/manifests/service.pp +++ b/modules/ssl/manifests/service.pp @@ -1,24 +1,47 @@ -define ssl::service($ensure = present, $tlsaport = 443, $notify = []) { - $link_target = $ensure ? { - present => link, - absent => absent, - default => fail ( "Unknown ensure value: '$ensure'" ), +define ssl::service($ensure = present, $tlsaport = 443, $notify = [], $key = false) { + $tlsaports = any2array($tlsaport) + + if ($ensure == "ifstatic") { + $ssl_ensure = has_static_component($name) ? { + true => "present", + false => "absent" + } + } else { + $ssl_ensure = $ensure } file { "/etc/ssl/debian/certs/$name.crt": - source => "puppet:///modules/ssl/servicecerts/${name}.crt", + ensure => $ssl_ensure, + source => [ "puppet:///modules/ssl/servicecerts/${name}.crt", "puppet:///modules/ssl/from-letsencrypt/${name}.crt" ], notify => [ Exec['refresh_debian_hashes'], $notify ], } file { "/etc/ssl/debian/certs/$name.crt-chain": - source => [ "puppet:///modules/ssl/chains/${name}.crt", "puppet:///modules/ssl/servicecerts/${name}.crt" ], - notify => [ Exec['refresh_debian_hashes'], $notify ], + ensure => $ssl_ensure, + source => [ "puppet:///modules/ssl/chains/${name}.crt", "puppet:///modules/ssl/servicecerts/${name}.crt", "puppet:///modules/ssl/from-letsencrypt/${name}.crt-chain" ], + notify => [ $notify ], links => follow, } + file { "/etc/ssl/debian/certs/$name.crt-chained": + ensure => $ssl_ensure, + content => template('ssl/chained.erb'), + notify => [ $notify ], + } + if $key { + file { "/etc/ssl/private/$name.key": + ensure => $ssl_ensure, + mode => '0440', + group => 'ssl-cert', + source => [ "puppet:///modules/ssl/keys/${name}.crt", "puppet:///modules/ssl/from-letsencrypt/${name}.key" ], + notify => [ $notify ], + links => follow, + } + } - if $tlsaport > 0 { - dnsextras::tlsa_record{ "tlsa-${name}-${tlsaport}": + if (size($tlsaports) > 0 and $ssl_ensure == "present") { + $portlist = join($tlsaports, "-") + dnsextras::tlsa_record{ "tlsa-${name}-${portlist}": zone => 'debian.org', - certfile => "/etc/puppet/modules/ssl/files/servicecerts/${name}.crt", + certfile => [ "/etc/puppet/modules/ssl/files/servicecerts/${name}.crt", "/etc/puppet/modules/ssl/files/from-letsencrypt/${name}.crt" ], port => $tlsaport, hostname => "$name", }