class profiles::transmission ( Optional[String] $nginx_server = undef, Enum['None', 'Error', 'Info', 'Debug'] $msg_level = 'Error', ) { $transmission_url = '/transmission' $transmission_port = 9091 if ($nginx_server) { require ::nginx nginx::resource::location { $transmission_url: proxy => "http://localhost:${transmission_port}${transmission_url}", proxy_set_header => [], server => $nginx_server, ssl => true, ssl_only => true, } } ensure_packages(['transmission-cli'], { ensure => installed }) systemd::dropin_file { 'transmission-after.conf': unit => 'transmission.service', content => @(EOF) [Unit] After=network-online.target | EOF } systemd::dropin_file { 'transmission-flags.conf': unit => 'transmission.service', content => @(EOF) [Service] ExecStart= ExecStart=/usr/bin/transmission-daemon -f | EOF } # TODO whitelists are currently disabled, since they don't seem to # work. Possibly turn them on again some day. # https://github.com/transmission/transmission/wiki/Editing-Configuration-File file { '/var/lib/transmission/.config/transmission-daemon/settings.json': content => epp('profiles/transmission.json.epp', { rpc_username => 'hugo', # '{' + sha1(password + salt) # But I don't know how I managed to generate it, since # transmission rolls its own crypto rpc_password => '{eb43101d3b9aa02223466d7f98c5329c841c7967/Zr2tFpn', download_dir => '/usr/net/', rpc_whitelist => ['127.0.0.1', '::1'], rpc_port => $transmission_port, rpc_url => "${transmission_url}/", msg_level => case $msg_level { 'None': { 0 } 'Error': { 1 } 'Info': { 2 } 'Debug': { 3 } }, }), } ~> exec { '/bin/systemctl reload transmission': refreshonly => true, } service { 'transmission': ensure => 'running', enable => true, } }