]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blob - modules/profile/manifests/xmr_stak.pp
afa72a5dc37d0ad961c92ee9a99adea986c2231f
[perso/Immae/Projets/Puppet.git] / modules / profile / manifests / xmr_stak.pp
1 class profile::xmr_stak (
2 String $mining_pool,
3 String $wallet,
4 Optional[String] $cpulimit = "50",
5 Optional[String] $password = "x",
6 ) {
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 })
12
13 ensure_packages(["cpulimit"])
14 aur::package { "xmr-stak_cpu": }
15
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 }
25
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 }
34
35 $instance = regsubst(lookup("base_installation::ldap_cn"), '\.', "_", "G")
36
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 }
44
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 }
59 }
60 }
61