get debian mirror for apt from hiera (not yet doing that for schroot)
[mirror/dsa-puppet.git] / modules / onion / manifests / balance.pp
1 class onion::balance {
2         include onion
3
4         package { 'onionbalance':
5                 ensure => installed,
6         }
7         service { 'onionbalance':
8                 ensure => running,
9                 require => Package['onionbalance'],
10         }
11         dsa_systemd::override { 'onionbalance':
12                 ensure => $ensure,
13                 content => @(EOT)
14                         [Unit]
15                         BindsTo=tor.service
16                         | EOT
17         }
18
19         file { '/usr/local/bin/tor-onion-name':
20                 mode    => '0555',
21                 source  => 'puppet:///modules/onion/tor-onion-name',
22         }
23         file { '/usr/local/bin/create-onionbalance-config':
24                 mode    => '0555',
25                 source  => 'puppet:///modules/onion/create-onionbalance-config',
26                 notify  => Exec['create-onionbalance-config'],
27         }
28
29         concat::fragment { 'onion::torrc_control_header':
30                 target  => "/etc/tor/torrc",
31                 order   => '10',
32                 content => "ControlPort 9051\n\n",
33         }
34
35         @@concat::fragment { "onion::balance::onionbalance-services.yaml":
36                 target  => "/srv/puppet.debian.org/puppet-facts/onionbalance-services.yaml",
37                 content => "${onion_balance_service_hostname}\n",
38                 tag     => "onionbalance-services.yaml",
39         }
40
41         concat { '/etc/onionbalance/config-dsa-snippet.yaml':
42                 notify  => Exec['create-onionbalance-config'],
43                 require => File['/usr/local/bin/create-onionbalance-config']
44         }
45         Concat::Fragment <<| tag == "onion::balance::dsa-snippet" |>>
46
47         exec { "create-onionbalance-config":
48                 command => "/usr/local/bin/create-onionbalance-config",
49                 refreshonly => true,
50                 require => [ File['/usr/local/bin/create-onionbalance-config'], Package['onionbalance'] ],
51                 notify  => Service['onionbalance'],
52         }
53 }