X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fssl%2Fmanifests%2Fservice.pp;h=711f755b80a9ac9a2b3b0153d3e53785cc523d37;hb=cb8d6a31d7e7faf6c3e0b37049ab22a6cb19cf25;hp=5c2509af1e82cfac6ed384916f69fa8210b3be3b;hpb=d49c5681d5da614ccc27ff96e91e9aa2bcee20c1;p=mirror%2Fdsa-puppet.git diff --git a/modules/ssl/manifests/service.pp b/modules/ssl/manifests/service.pp index 5c2509af1..711f755b8 100644 --- a/modules/ssl/manifests/service.pp +++ b/modules/ssl/manifests/service.pp @@ -1,28 +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 => [ Exec['refresh_debian_hashes'], $notify ], + 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", }