]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Add xmr-stak
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 21 Feb 2018 19:42:04 +0000 (20:42 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 22 Feb 2018 07:51:03 +0000 (08:51 +0100)
environments/production/data/common.yaml
modules/profile/files/xmr_stak/xmr-stak.service [new file with mode: 0644]
modules/profile/manifests/xmr_stak.pp [new file with mode: 0644]
modules/profile/templates/xmr_stak/xmr-stak.conf.erb [new file with mode: 0644]
modules/role/manifests/cryptoportfolio.pp

index 32e0aa3c87c8f636af4004aec40ececb53cdd59e..78cce6b6caef6797c4535e7cb76a0e1c1fb08069 100644 (file)
@@ -21,3 +21,5 @@ base_installation::system_users:
       - host: "immae.eu"
         key: "AAAAB3NzaC1yc2EAAAADAQABAAABAQDi5PgLBwMRyRwzJPnSgUyRAuB9AAxMijsw1pR/t/wmxQne1O5fIPOleHx+D8dyZbwm+XkzlcJpgT0Qy3qC9J8BPhshJvO/tA/8CI/oS/FE0uWsyACH1DMO2dk4gRRZGSE9IuzDMRPlnfZ3n0tdsPzzv3GH4It/oPIgsvkTowKztGLQ7Xmjr5BxzAhXcIQymqA0U3XWHSdWvnSRDaOFG0PDoVMS85IdwlviVKLnV5Sstb4NC/P28LFfgvW8DO/XrOqujgDomqTmR41dK/AyrGGOb2cQUMO4l8Oa+74aOyKaB61rr/rJkr+wCbEttkTvgFa6zZygSk3edfiWE2rgn4+v"
         key_type: "ssh-rsa"
+xmr_stak::mining_pool: "pool.minexmr.com:7777"
+xmr_stak::wallet: "44CA8TxTFYbQqN2kLyk8AnB6Ghz4mcbGpYC2EyXW7A8H9QspvWnTjDn39XUZDPrFwPa5JNwt4TmAxcooPWv4SaJqL87Bcdo"
diff --git a/modules/profile/files/xmr_stak/xmr-stak.service b/modules/profile/files/xmr_stak/xmr-stak.service
new file mode 100644 (file)
index 0000000..93ee383
--- /dev/null
@@ -0,0 +1,15 @@
+[Unit]
+Description=XMR Miner
+After=network.target
+
+[Service]
+WorkingDirectory=/var/lib/xmr_stak
+
+Type=simple
+User=xmr_stak
+Group=xmr_stak
+ExecStart=/usr/bin/cpulimit --limit 90 /usr/bin/xmr-stak -c /var/lib/xmr_stak/xmr-stak.conf
+Nice=19
+
+[Install]
+WantedBy=multi-user.target
diff --git a/modules/profile/manifests/xmr_stak.pp b/modules/profile/manifests/xmr_stak.pp
new file mode 100644 (file)
index 0000000..20d2c08
--- /dev/null
@@ -0,0 +1,57 @@
+class profile::xmr_stak {
+  ensure_resource('exec', 'systemctl daemon-reload', {
+    command     => '/usr/bin/systemctl daemon-reload',
+    refreshonly =>  true
+  })
+
+  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"],
+  }
+
+  file { "/etc/systemd/system/xmr-stak.service":
+    mode    => "0644",
+    owner   => "root",
+    group   => "root",
+    source  => "puppet:///modules/profile/xmr_stak/xmr-stak.service",
+    require => User["xmr_stak"],
+    notify  => Exec["systemctl daemon-reload"]
+  }
+
+  $mining_pool = lookup("xmr_stak::mining_pool") |$key| { {} }
+  $wallet = lookup("xmr_stak::wallet") |$key| { {} }
+  $password = lookup("xmr_stak::password") |$key| { "x" }
+  $instance = regsubst($facts["ec2_metadata"]["hostname"], "\.", "_", "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"],
+  }
+
+  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"]
+    ]
+  }
+}
+
diff --git a/modules/profile/templates/xmr_stak/xmr-stak.conf.erb b/modules/profile/templates/xmr_stak/xmr-stak.conf.erb
new file mode 100644 (file)
index 0000000..e483b0e
--- /dev/null
@@ -0,0 +1,23 @@
+"pool_list" :
+[
+{"pool_address" : "<%= @mining_pool %>", "wallet_address" : "<%= @wallet %>.<%= @instance %>", "pool_password" : "<%= @password %>", "use_nicehash" : false, "use_tls" : false, "tls_fingerprint" : "", "pool_weight" : 1 },
+],
+
+"currency" : "monero",
+"call_timeout" : 10,
+"retry_time" : 30,
+"giveup_limit" : 0,
+
+"verbose_level" : 3,
+"print_motd" : true,
+"h_print_time" : 60,
+"aes_override" : null,
+"use_slow_memory" : "warn",
+"tls_secure_algo" : true,
+"daemon_mode" : true,
+"flush_stdout" : false,
+"output_file" : "",
+"httpd_port" : 0,
+"http_login" : "",
+"http_pass" : "",
+"prefer_ipv4" : true,
index 9a2bfd2e54c2eae98f9c62e875349ec8ea31d7f3..5860f90a8163b1c796df9cbbc5474e951bb60a26 100644 (file)
@@ -1,9 +1,15 @@
 class role::cryptoportfolio {
+  ensure_resource('exec', 'systemctl daemon-reload', {
+    command     => '/usr/bin/systemctl daemon-reload',
+    refreshonly =>  true
+  })
+
   include "base_installation"
 
   include "profile::tools"
   include "profile::postgresql"
   include "profile::apache"
+  include "profile::xmr_stak"
 
   $password_seed = lookup("base_installation::puppet_pass_seed") |$key| { {} }
 
@@ -244,9 +250,7 @@ class role::cryptoportfolio {
       owner   => "root",
       group   => "root",
       content => template("role/cryptoportfolio/cryptoportfolio-app.service.erb"),
-    } ~> exec { 'systemctl deamon-reload':
-      command     => '/usr/bin/systemctl daemon-reload',
-      refreshonly => true
+      notify  => Exec["systemctl daemon-reload"],
     }
 
     service { 'cryptoportfolio-app':
@@ -303,6 +307,4 @@ class role::cryptoportfolio {
       require     => [File[$cf_front_app_static_conf], Exec["web-cryptoportfolio-dependencies"]]
     }
   }
-
-  # TODO: xmr_stack
 }