summaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: 6a95f5587c4f6e41cc6d2aed4de5ae7a802d7fcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class bitcoind(
  $daemon_args    = hiera('bitcoind::daemon_args',   '-daemon'),
  $rpcuser        = hiera('bitcoind::rpcuser',       ''),
  $rpcpassword    = hiera('bitcoind::rpcpassword',   ''),
  $ensure         = hiera('bitcoind::ensure',        'running'),
  $maxconnections = hiera('bitcoind::maxconnections', 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'] ],
  }
}