89be79b52ff434c14da882835bffc727169ce714
[mirror/dsa-puppet.git] / modules / onion / manifests / balance_service.pp
1 define onion::balance_service (
2 ) {
3         include onion::balance
4
5         $onion_hn = onion_balance_service_hostname($name)
6         if ! $onion_hn {
7                 exec { "create-onionbalance-key-${name}":
8                         command => "/bin/true && umask 0027 && openssl genrsa -out /etc/onionbalance/private_keys/${name}.key 1024 && chgrp onionbalance /etc/onionbalance/private_keys/${name}.key",
9                         onlyif  => "/bin/true && ! [ -e /etc/onionbalance/private_keys/${name}.key ]",
10                         require => Package['onionbalance'],
11                 }
12         }
13
14         concat::fragment { "onion::balance::service_header::${name}":
15                 target  => "/etc/onionbalance/config.yaml",
16                 order   => "50-${name}-10",
17                 content => "  - # ${name} via ${onion_hn}\n    key: private_keys/${name}.key\n    instances:\n",
18         }
19
20         Concat::Fragment <<| tag == "onion::balance::${name}" |>>
21 }