]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blame - modules/profile/manifests/xmr_stak.pp
Disable xmr-stak if mining_pool is empty
[perso/Immae/Projets/Puppet.git] / modules / profile / manifests / xmr_stak.pp
CommitLineData
a045b9dc
IB
1class profile::xmr_stak (
2 String $mining_pool,
3 String $wallet,
62fe8998 4 Optional[String] $cpulimit = "50",
a045b9dc
IB
5 Optional[String] $password = "x",
6) {
c2f33e53
IB
7 unless empty($mining_pool) or $cpulimit == "0" {
8 ensure_resource('exec', 'systemctl daemon-reload', {
9 command => '/usr/bin/systemctl daemon-reload',
10 refreshonly => true
11 })
68bbff61 12
c2f33e53
IB
13 ensure_packages(["cpulimit"])
14 aur::package { "xmr-stak_cpu": }
68bbff61 15
c2f33e53
IB
16 user { "xmr_stak":
17 name => "xmr_stak",
18 ensure => "present",
19 managehome => true,
20 home => "/var/lib/xmr_stak",
21 system => true,
22 password => "!!",
23 require => Aur::Package["xmr-stak_cpu"],
24 }
68bbff61 25
c2f33e53
IB
26 file { "/etc/systemd/system/xmr-stak.service":
27 mode => "0644",
28 owner => "root",
29 group => "root",
30 content => template("profile/xmr_stak/xmr-stak.service.erb"),
31 require => User["xmr_stak"],
32 notify => Exec["systemctl daemon-reload"]
33 }
68bbff61 34
c2f33e53 35 $instance = regsubst(lookup("base_installation::ldap_cn"), '\.', "_", "G")
68bbff61 36
c2f33e53
IB
37 file { "/var/lib/xmr_stak/xmr-stak.conf":
38 mode => "0644",
39 owner => "root",
40 group => "root",
41 content => template("profile/xmr_stak/xmr-stak.conf.erb"),
42 require => User["xmr_stak"],
43 }
68bbff61 44
c2f33e53
IB
45 service { "xmr-stak":
46 enable => true,
47 ensure => "running",
48 subscribe => [
49 Aur::Package["xmr-stak_cpu"],
50 File["/var/lib/xmr_stak/xmr-stak.conf"],
51 File["/etc/systemd/system/xmr-stak.service"]
52 ],
53 require => [
54 Aur::Package["xmr-stak_cpu"],
55 File["/var/lib/xmr_stak/xmr-stak.conf"],
56 File["/etc/systemd/system/xmr-stak.service"]
57 ]
58 }
68bbff61
IB
59 }
60}
61