X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fssl%2Fmanifests%2Fservice.pp;h=f01a75c5ed86249efe50786b4a81d11ed32f2a97;hb=3aa5ba8d9a9d12e3d8fe34e4bf897897a4dedf36;hp=a9d4fd45b1bddba88e3cff4e2ce0496138a79d4b;hpb=6e6ef69a87a73384f1032efba8a82f684961504a;p=mirror%2Fdsa-puppet.git diff --git a/modules/ssl/manifests/service.pp b/modules/ssl/manifests/service.pp index a9d4fd45b..f01a75c5e 100644 --- a/modules/ssl/manifests/service.pp +++ b/modules/ssl/manifests/service.pp @@ -1,35 +1,54 @@ define ssl::service($ensure = present, $tlsaport = 443, $notify = [], $key = false) { - $link_target = $ensure ? { - present => link, - absent => absent, - default => fail ( "Unknown ensure value: '$ensure'" ), + $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": + 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": + 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, } + + file { "/etc/ssl/private/$name.key-certchain": + ensure => $ssl_ensure, + mode => '0440', + group => 'ssl-cert', + content => template('ssl/key-chained.erb'), + 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", "/etc/puppet/modules/ssl/files/from-letsencrypt/${name}.crt" ], port => $tlsaport,