X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fprofile%2Fmanifests%2Fxmr_stak.pp;h=93aa37d185fa675d18d5427b5b02a0503644de4c;hb=42c7bdd646cc90d156a2f02176a539540ffaaf48;hp=20d2c08baebdfb1e33c8a6896e639aadeab5edfd;hpb=68bbff6199a64dd32739487334260962261f7195;p=perso%2FImmae%2FProjets%2FPuppet.git diff --git a/modules/profile/manifests/xmr_stak.pp b/modules/profile/manifests/xmr_stak.pp index 20d2c08..93aa37d 100644 --- a/modules/profile/manifests/xmr_stak.pp +++ b/modules/profile/manifests/xmr_stak.pp @@ -1,57 +1,70 @@ -class profile::xmr_stak { - ensure_resource('exec', 'systemctl daemon-reload', { - command => '/usr/bin/systemctl daemon-reload', - refreshonly => true - }) +class profile::xmr_stak ( + String $mining_pool, + String $wallet, + Optional[String] $cpulimit = "50", + Optional[String] $password = "x", +) { + 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": + ensure => "absent" + } -> + aur::package { "xmr-stak": } + ~> + exec { "remove cpu.txt": + command => "/usr/bin/rm /var/lib/xmr_stak/cpu.txt", + refreshonly => true, + before => Service["xmr-stak"], + } - 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"], + } - 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"] - } + 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"] + } - $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") + $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"], + File["/var/lib/xmr_stak/xmr-stak.conf"], + File["/etc/systemd/system/xmr-stak.service"] + ], + require => [ + Aur::Package["xmr-stak"], + File["/var/lib/xmr_stak/xmr-stak.conf"], + File["/etc/systemd/system/xmr-stak.service"] + ] + } } }