aboutsummaryrefslogtreecommitdiff
path: root/modules/profile
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-04-14 10:31:57 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-04-14 10:31:57 +0200
commitc2f33e53cf694819878f95b7200c3a3abebe52dc (patch)
tree256552636edfd276fa10c07693a7e81817721799 /modules/profile
parent196688a659d2748b644176cbc16cf565c274330f (diff)
downloadPuppet-c2f33e53cf694819878f95b7200c3a3abebe52dc.tar.gz
Puppet-c2f33e53cf694819878f95b7200c3a3abebe52dc.tar.zst
Puppet-c2f33e53cf694819878f95b7200c3a3abebe52dc.zip
Disable xmr-stak if mining_pool is empty
Diffstat (limited to 'modules/profile')
-rw-r--r--modules/profile/manifests/xmr_stak.pp90
-rw-r--r--modules/profile/templates/xmr_stak/xmr-stak.conf.erb2
2 files changed, 47 insertions, 45 deletions
diff --git a/modules/profile/manifests/xmr_stak.pp b/modules/profile/manifests/xmr_stak.pp
index ccb6baa..afa72a5 100644
--- a/modules/profile/manifests/xmr_stak.pp
+++ b/modules/profile/manifests/xmr_stak.pp
@@ -4,56 +4,58 @@ class profile::xmr_stak (
4 Optional[String] $cpulimit = "50", 4 Optional[String] $cpulimit = "50",
5 Optional[String] $password = "x", 5 Optional[String] $password = "x",
6) { 6) {
7 ensure_resource('exec', 'systemctl daemon-reload', { 7 unless empty($mining_pool) or $cpulimit == "0" {
8 command => '/usr/bin/systemctl daemon-reload', 8 ensure_resource('exec', 'systemctl daemon-reload', {
9 refreshonly => true 9 command => '/usr/bin/systemctl daemon-reload',
10 }) 10 refreshonly => true
11 })
11 12
12 ensure_packages(["cpulimit"]) 13 ensure_packages(["cpulimit"])
13 aur::package { "xmr-stak_cpu": } 14 aur::package { "xmr-stak_cpu": }
14 15
15 user { "xmr_stak": 16 user { "xmr_stak":
16 name => "xmr_stak", 17 name => "xmr_stak",
17 ensure => "present", 18 ensure => "present",
18 managehome => true, 19 managehome => true,
19 home => "/var/lib/xmr_stak", 20 home => "/var/lib/xmr_stak",
20 system => true, 21 system => true,
21 password => "!!", 22 password => "!!",
22 require => Aur::Package["xmr-stak_cpu"], 23 require => Aur::Package["xmr-stak_cpu"],
23 } 24 }
24 25
25 file { "/etc/systemd/system/xmr-stak.service": 26 file { "/etc/systemd/system/xmr-stak.service":
26 mode => "0644", 27 mode => "0644",
27 owner => "root", 28 owner => "root",
28 group => "root", 29 group => "root",
29 content => template("profile/xmr_stak/xmr-stak.service.erb"), 30 content => template("profile/xmr_stak/xmr-stak.service.erb"),
30 require => User["xmr_stak"], 31 require => User["xmr_stak"],
31 notify => Exec["systemctl daemon-reload"] 32 notify => Exec["systemctl daemon-reload"]
32 } 33 }
33 34
34 $instance = regsubst(lookup("base_installation::ldap_cn"), '\.', "_", "G") 35 $instance = regsubst(lookup("base_installation::ldap_cn"), '\.', "_", "G")
35 36
36 file { "/var/lib/xmr_stak/xmr-stak.conf": 37 file { "/var/lib/xmr_stak/xmr-stak.conf":
37 mode => "0644", 38 mode => "0644",
38 owner => "root", 39 owner => "root",
39 group => "root", 40 group => "root",
40 content => template("profile/xmr_stak/xmr-stak.conf.erb"), 41 content => template("profile/xmr_stak/xmr-stak.conf.erb"),
41 require => User["xmr_stak"], 42 require => User["xmr_stak"],
42 } 43 }
43 44
44 service { "xmr-stak": 45 service { "xmr-stak":
45 enable => true, 46 enable => true,
46 ensure => "running", 47 ensure => "running",
47 subscribe => [ 48 subscribe => [
48 Aur::Package["xmr-stak_cpu"], 49 Aur::Package["xmr-stak_cpu"],
49 File["/var/lib/xmr_stak/xmr-stak.conf"], 50 File["/var/lib/xmr_stak/xmr-stak.conf"],
50 File["/etc/systemd/system/xmr-stak.service"] 51 File["/etc/systemd/system/xmr-stak.service"]
51 ], 52 ],
52 require => [ 53 require => [
53 Aur::Package["xmr-stak_cpu"], 54 Aur::Package["xmr-stak_cpu"],
54 File["/var/lib/xmr_stak/xmr-stak.conf"], 55 File["/var/lib/xmr_stak/xmr-stak.conf"],
55 File["/etc/systemd/system/xmr-stak.service"] 56 File["/etc/systemd/system/xmr-stak.service"]
56 ] 57 ]
58 }
57 } 59 }
58} 60}
59 61
diff --git a/modules/profile/templates/xmr_stak/xmr-stak.conf.erb b/modules/profile/templates/xmr_stak/xmr-stak.conf.erb
index 0228eb6..a1420f2 100644
--- a/modules/profile/templates/xmr_stak/xmr-stak.conf.erb
+++ b/modules/profile/templates/xmr_stak/xmr-stak.conf.erb
@@ -1,6 +1,6 @@
1"pool_list" : 1"pool_list" :
2[ 2[
3{"pool_address" : "<%= @mining_pool %>", "wallet_address" : "<%= @wallet %>.<%= @instance %>", "rig_id": "", "pool_password" : "<%= @password %>", "use_nicehash" : false, "use_tls" : false, "tls_fingerprint" : "", "pool_weight" : 1 }, 3{"pool_address" : "<%= @mining_pool %>", "wallet_address" : "<%= @wallet %>.<%= @instance %>", "rig_id": "", "pool_password" : "<%= @password %>", "use_nicehash" : false, "use_tls" : true, "tls_fingerprint" : "", "pool_weight" : 1 },
4], 4],
5 5
6"currency" : "monero7", 6"currency" : "monero7",