Puppet Class: ledgerdb

Defined in:
manifests/init.pp

Summary

Configure Ledger DB instance

Overview

Parameters:

  • datadir (String)

    sets where the data is persisted

  • hostname (String)

    sets the hostname for influxdb

  • aws_access_key_id (String)

    sets the AWS key to use for Route53 challenge

  • aws_secret_access_key (String)

    sets the AWS secret key to use for the Route53 challenge

  • email (String)

    sets the contact address for the certificate

  • 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.0.13')

    sets the ledgerdb tag to use

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

    sets the user to run ledgerdb 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



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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'manifests/init.pp', line 15

class ledgerdb (
  String $datadir,
  String $hostname,
  String $aws_access_key_id,
  String $aws_secret_access_key,
  String $email,
  String $ledger_repo,
  String $ledger_ssh_key,
  String $ledger_file = 'core.ldg',
  String $version = 'v0.0.13',
  String $user = 'ledgerdb',
  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('ledgerdb/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/ledgerdb'
  $filename = "ledgerdb_${downcase($facts['kernel'])}_${arch}"
  $url = "https://github.com/akerl/ledgerdb/releases/download/${version}/${filename}"

  exec { 'download ledgerdb':
    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/ledgerdb.service':
    ensure  => file,
    content => template('ledgerdb/ledgerdb.service.erb'),
  }

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

  ~> service { 'ledgerdb.timer':
    ensure => running,
    enable => true,
  }

  class { 'influxdb':
    hostname              => $hostname,
    datadir               => "${datadir}/influxdb",
    aws_access_key_id     => $aws_access_key_id,
    aws_secret_access_key => $aws_secret_access_key,
    email                 => $email,
  }
}