]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Disable xmr-stak if mining_pool is empty
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 14 Apr 2018 08:31:57 +0000 (10:31 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 14 Apr 2018 08:31:57 +0000 (10:31 +0200)
environments/global/common.yaml
environments/global/types/s1-2.yaml
modules/profile/manifests/xmr_stak.pp
modules/profile/templates/xmr_stak/xmr-stak.conf.erb

index 2dfe0aa562cb68b36d851c6485d2c9e0bb978fc8..3cc75fa561b1545bcf23a7c95d365f2a11f90e97 100644 (file)
@@ -33,8 +33,8 @@ base_installation::notify_xmpp: {}
 profile::fstab::mounts:
   - "%{facts.ldapvar.self.vars.mounts.0}"
   - "%{facts.ldapvar.self.vars.mounts.1}"
-profile::xmr_stak::mining_pool: "" # Fetched via ldap
-profile::xmr_stak::wallet: "" # Fetched via ldap
+profile::xmr_stak::mining_pool: ""
+profile::xmr_stak::wallet: ""
 profile::mail::mailhub: "" # Fetched via ldap
 role::backup::mailto: "" # Fetched via ldap
 role::backup::backups: [] # Fetched via ldap
index 5bfdf9ac0c2c8be169c140f04df1b2470ccfbe28..fb0d6634ab0917a9bf8badda9df0cacabf8db5f3 100644 (file)
@@ -7,4 +7,4 @@ base_installation::system_hostname: "%{ldapvar.self.vars.host.0}"
 base_installation::real_hostname: "%{facts.ec2_metadata.hostname}.v.immae.eu"
 base_installation::ldap_cert_path: "/etc/ssl/certs/ca-certificates.crt"
 letsencrypt::try_for_real_hostname: true
-profile::xmr_stak::cpulimit: "30"
+profile::xmr_stak::cpulimit: "0"
index ccb6baaf97028cec06840e95cfae882514a649f5..afa72a5dc37d0ad961c92ee9a99adea986c2231f 100644 (file)
@@ -4,56 +4,58 @@ class profile::xmr_stak (
   Optional[String] $cpulimit = "50",
   Optional[String] $password = "x",
 ) {
-  ensure_resource('exec', 'systemctl daemon-reload', {
-    command     => '/usr/bin/systemctl daemon-reload',
-    refreshonly =>  true
-  })
+  unless empty($mining_pool) or $cpulimit == "0" {
+    ensure_resource('exec', 'systemctl daemon-reload', {
+      command     => '/usr/bin/systemctl daemon-reload',
+      refreshonly =>  true
+    })
 
-  ensure_packages(["cpulimit"])
-  aur::package { "xmr-stak_cpu": }
+    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"],
-  }
+    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",
-    content => template("profile/xmr_stak/xmr-stak.service.erb"),
-    require => User["xmr_stak"],
-    notify  => Exec["systemctl daemon-reload"]
-  }
+    file { "/etc/systemd/system/xmr-stak.service":
+      mode    => "0644",
+      owner   => "root",
+      group   => "root",
+      content => template("profile/xmr_stak/xmr-stak.service.erb"),
+      require => User["xmr_stak"],
+      notify  => Exec["systemctl daemon-reload"]
+    }
 
-  $instance = regsubst(lookup("base_installation::ldap_cn"), '\.', "_", "G")
+    $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"],
-  }
+    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"]
-    ]
+    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"]
+      ]
+    }
   }
 }
 
index 0228eb61b78054ecd1cc043a936c036f474c6647..a1420f25117ed6038a451b5cc2f9904546a7fcde 100644 (file)
@@ -1,6 +1,6 @@
 "pool_list" :
 [
-{"pool_address" : "<%= @mining_pool %>", "wallet_address" : "<%= @wallet %>.<%= @instance %>", "rig_id": "", "pool_password" : "<%= @password %>", "use_nicehash" : false, "use_tls" : false, "tls_fingerprint" : "", "pool_weight" : 1 },
+{"pool_address" : "<%= @mining_pool %>", "wallet_address" : "<%= @wallet %>.<%= @instance %>", "rig_id": "", "pool_password" : "<%= @password %>", "use_nicehash" : false, "use_tls" : true, "tls_fingerprint" : "", "pool_weight" : 1 },
 ],
 
 "currency" : "monero7",