aboutsummaryrefslogtreecommitdiff
path: root/modules/profile/manifests/xmr_stak.pp
blob: c8bbcdd39c26bfd5081aae5003f9a3c26ffdfbd4 (plain) (blame)
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
class profile::xmr_stak (
  String           $mining_pool,
  String           $wallet,
  Optional[String] $password = "x",
) {
  ensure_resource('exec', 'systemctl daemon-reload', {
    command     => '/usr/bin/systemctl daemon-reload',
    refreshonly =>  true
  })

  ensure_packages(["cpulimit"])
  aur::package { "xmr-stak_cpu": }

  user { "xmr_stak":
    name       => "xmr_stak",
    ensure     => "present",
    managehome => true,
    home       => "/var/lib/xmr_stak",
    system     => true,
    password   => "!!",
    require    => Aur::Package["xmr-stak_cpu"],
  }

  file { "/etc/systemd/system/xmr-stak.service":
    mode    => "0644",
    owner   => "root",
    group   => "root",
    source  => "puppet:///modules/profile/xmr_stak/xmr-stak.service",
    require => User["xmr_stak"],
    notify  => Exec["systemctl daemon-reload"]
  }

  $instance = regsubst(lookup("base_installation::ldap_cn"), '\.', "_", "G")

  file { "/var/lib/xmr_stak/xmr-stak.conf":
    mode    => "0644",
    owner   => "root",
    group   => "root",
    content => template("profile/xmr_stak/xmr-stak.conf.erb"),
    require => User["xmr_stak"],
  }

  service { "xmr-stak":
    enable    => true,
    ensure    => "running",
    subscribe => [
      Aur::Package["xmr-stak_cpu"],
      File["/var/lib/xmr_stak/xmr-stak.conf"],
      File["/etc/systemd/system/xmr-stak.service"]
    ],
    require   => [
      Aur::Package["xmr-stak_cpu"],
      File["/var/lib/xmr_stak/xmr-stak.conf"],
      File["/etc/systemd/system/xmr-stak.service"]
    ]
  }
}