ship debtags key
[mirror/dsa-puppet.git] / modules / ssl / manifests / service.pp
1 define ssl::service($ensure = present, $tlsaport = 443, $notify = [], $key = false) {
2         $link_target = $ensure ? {
3                 present => link,
4                 absent  => absent,
5                 default => fail ( "Unknown ensure value: '$ensure'" ),
6         }
7
8         file { "/etc/ssl/debian/certs/$name.crt":
9                 source => [ "puppet:///modules/ssl/servicecerts/${name}.crt", "puppet:///modules/ssl/from-letsencrypt/${name}.crt" ],
10                 notify => [ Exec['refresh_debian_hashes'], $notify ],
11         }
12         file { "/etc/ssl/debian/certs/$name.crt-chain":
13                 source => [ "puppet:///modules/ssl/chains/${name}.crt", "puppet:///modules/ssl/servicecerts/${name}.crt", "puppet:///modules/ssl/from-letsencrypt/${name}.crt-chain" ],
14                 notify => [ $notify ],
15                 links  => follow,
16         }
17         file { "/etc/ssl/debian/certs/$name.crt-chained":
18                 content => template('ssl/chained.erb'),
19                 notify => [ $notify ],
20         }
21         if $key {
22                 file { "/etc/ssl/private/$name.key":
23                         mode   => '0440',
24                         group => 'ssl-cert',
25                         source => [ "puppet:///modules/ssl/keys/${name}.crt", "puppet:///modules/ssl/from-letsencrypt/${name}.key" ],
26                         notify => [ $notify ],
27                         links  => follow,
28                 }
29         }
30
31         if $tlsaport > 0 {
32                 dnsextras::tlsa_record{ "tlsa-${name}-${tlsaport}":
33                         zone     => 'debian.org',
34                         certfile => [ "/etc/puppet/modules/ssl/files/servicecerts/${name}.crt", "/etc/puppet/modules/ssl/files/from-letsencrypt/${name}.crt" ],
35                         port     => $tlsaport,
36                         hostname => "$name",
37                 }
38         }
39 }