class bitcoind( $daemon_args = lookup('bitcoind::daemon_args', undef, undef, '-daemon'), $rpcuser = lookup('bitcoind::rpcuser', undef, undef, ''), $rpcpassword = lookup('bitcoind::rpcpassword', undef, undef, ''), $ensure = lookup('bitcoind::ensure', undef, undef, 'running'), $maxconnections = lookup('bitcoind::maxconnections', undef, undef, 25) ) { case $rpcuser { '': { fail("You need to define etherpad database password! Please set bitcoind::rpcuser in your config") } } case $rpcpassword { '': { fail("You need to define etherpad database password! Please set bitcoind::rpcpassword in your config") } } package { 'bitcoind': ensure => latest, } group { "bitcoin": ensure => present, allowdupe => false, } user { "bitcoin": ensure => present, allowdupe => false, shell => '/bin/bash', gid => 'bitcoin', home => '/var/lib/bitcoin', require => Group['bitcoin'], } file { '/var/lib/bitcoin': ensure => directory, owner => 'bitcoin', group => 'bitcoin', mode => '0750', require => User['bitcoin'], } file { '/var/lib/bitcoin/.bitcoin': ensure => directory, owner => 'bitcoin', group => 'bitcoin', mode => '0750', require => File['/var/lib/bitcoin'], } file { '/var/lib/bitcoin/.bitcoin/bitcoin.conf': ensure => present, owner => 'bitcoin', group => 'bitcoin', mode => '0600', content => template('bitcoind/bitcoin.conf.erb'), require => File['/var/lib/bitcoin/.bitcoin'], notify => Service['bitcoind'], } file { '/etc/init.d/bitcoind': ensure => present, owner => root, group => root, mode => '0755', content => template('bitcoind/bitcoind-init.d.sh.erb'), notify => Service['bitcoind'], } $enable = $ensure ? { 'running' => true, default => false, } service { 'bitcoind': enable => $enable, ensure => $ensure, hasrestart => true, hasstatus => false, pattern => '/usr/bin/bitcoind', require => [ Package['bitcoind'], File['/var/lib/bitcoin/.bitcoin/bitcoin.conf', '/etc/init.d/bitcoind'] ], } }