diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-14 10:31:57 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-14 10:31:57 +0200 |
commit | c2f33e53cf694819878f95b7200c3a3abebe52dc (patch) | |
tree | 256552636edfd276fa10c07693a7e81817721799 | |
parent | 196688a659d2748b644176cbc16cf565c274330f (diff) | |
download | Puppet-c2f33e53cf694819878f95b7200c3a3abebe52dc.tar.gz Puppet-c2f33e53cf694819878f95b7200c3a3abebe52dc.tar.zst Puppet-c2f33e53cf694819878f95b7200c3a3abebe52dc.zip |
Disable xmr-stak if mining_pool is empty
-rw-r--r-- | environments/global/common.yaml | 4 | ||||
-rw-r--r-- | environments/global/types/s1-2.yaml | 2 | ||||
-rw-r--r-- | modules/profile/manifests/xmr_stak.pp | 90 | ||||
-rw-r--r-- | modules/profile/templates/xmr_stak/xmr-stak.conf.erb | 2 |
4 files changed, 50 insertions, 48 deletions
diff --git a/environments/global/common.yaml b/environments/global/common.yaml index 2dfe0aa..3cc75fa 100644 --- a/environments/global/common.yaml +++ b/environments/global/common.yaml | |||
@@ -33,8 +33,8 @@ base_installation::notify_xmpp: {} | |||
33 | profile::fstab::mounts: | 33 | profile::fstab::mounts: |
34 | - "%{facts.ldapvar.self.vars.mounts.0}" | 34 | - "%{facts.ldapvar.self.vars.mounts.0}" |
35 | - "%{facts.ldapvar.self.vars.mounts.1}" | 35 | - "%{facts.ldapvar.self.vars.mounts.1}" |
36 | profile::xmr_stak::mining_pool: "" # Fetched via ldap | 36 | profile::xmr_stak::mining_pool: "" |
37 | profile::xmr_stak::wallet: "" # Fetched via ldap | 37 | profile::xmr_stak::wallet: "" |
38 | profile::mail::mailhub: "" # Fetched via ldap | 38 | profile::mail::mailhub: "" # Fetched via ldap |
39 | role::backup::mailto: "" # Fetched via ldap | 39 | role::backup::mailto: "" # Fetched via ldap |
40 | role::backup::backups: [] # Fetched via ldap | 40 | role::backup::backups: [] # Fetched via ldap |
diff --git a/environments/global/types/s1-2.yaml b/environments/global/types/s1-2.yaml index 5bfdf9a..fb0d663 100644 --- a/environments/global/types/s1-2.yaml +++ b/environments/global/types/s1-2.yaml | |||
@@ -7,4 +7,4 @@ base_installation::system_hostname: "%{ldapvar.self.vars.host.0}" | |||
7 | base_installation::real_hostname: "%{facts.ec2_metadata.hostname}.v.immae.eu" | 7 | base_installation::real_hostname: "%{facts.ec2_metadata.hostname}.v.immae.eu" |
8 | base_installation::ldap_cert_path: "/etc/ssl/certs/ca-certificates.crt" | 8 | base_installation::ldap_cert_path: "/etc/ssl/certs/ca-certificates.crt" |
9 | letsencrypt::try_for_real_hostname: true | 9 | letsencrypt::try_for_real_hostname: true |
10 | profile::xmr_stak::cpulimit: "30" | 10 | profile::xmr_stak::cpulimit: "0" |
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", |