Puppet Class: ledgergraph

Defined in:
manifests/init.pp

Summary

Configure Ledgergraph instance

Overview

Parameters:

  • datadir (String)

    sets where the data is persisted

  • ledger_repo (String)

    is the git repo for ledger data

  • ledger_ssh_key (String)

    is the ssh key to use to update the repo

  • ledger_file (String) (defaults to: 'core.ldg')

    is the main ledger file to load, relative to the repo root

  • version (String) (defaults to: 'v0.1.0')

    sets the ledgergraph tag to use

  • user (String) (defaults to: 'ledgergraph')

    sets the user to run ledgergraph as

  • bootdelay (String) (defaults to: '300')

    sets how long to wait before first run

  • frequency (String) (defaults to: '300')

    sets how often to run updates



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
83
84
85
86
87
88
89
90
# File 'manifests/init.pp', line 11

class ledgergraph (
  String $datadir,
  String $ledger_repo,
  String $ledger_ssh_key,
  String $ledger_file = 'core.ldg',
  String $version = 'v0.1.0',
  String $user = 'ledgergraph',
  String $bootdelay = '300',
  String $frequency = '300'
) {
  group { $user:
    ensure => present,
    system => true,
  }

  user { $user:
    ensure => present,
    system => true,
    gid    => $user,
    shell  => '/usr/bin/nologin',
    home   => $datadir,
  }

  file { [
      $datadir,
      "${datadir}/data",
    ]:
      ensure => directory,
  }

  file { "${datadir}/identity":
    ensure  => file,
    mode    => '0600',
    content => $ledger_ssh_key,
  }

  -> vcsrepo { "${datadir}/data":
    ensure   => latest,
    provider => git,
    source   => $ledger_repo,
    identity => "${datadir}/identity",
    revision => 'main',
  }

  package { 'ledger': }

  file { "${datadir}/config.yaml":
    ensure  => file,
    content => template('ledgergraph/config.yaml.erb'),
    group   => $user,
    mode    => '0640',
  }

  $arch = $facts['os']['architecture'] ? {
    'x86_64'  => 'amd64',
    'arm64'   => 'arm64',
    'aarch64' => 'arm64',
    'arm'     => 'arm',
    default   => 'error',
  }

  $binfile = '/usr/local/bin/ledgergraph'
  $filename = "ledgergraph_${downcase($facts['kernel'])}_${arch}"
  $url = "https://github.com/akerl/ledgergraph/releases/download/${version}/${filename}"

  exec { 'download ledgergraph':
    command => "/usr/bin/curl -sLo '${binfile}' '${url}' && chmod a+x '${binfile}'",
    unless  => "/usr/bin/test -f ${binfile} && ${binfile} version | grep '${version}'",
  }

  file { '/etc/systemd/system/ledgergraph.service':
    ensure  => file,
    content => template('ledgergraph/ledgergraph.service.erb'),
  }

  ~> service { 'ledgergraph':
    ensure => running,
    enable => true,
  }
}