From c7d02f266e4c8fcf207ee4f5ffe4dbd0732c430f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Clouet?= Date: Sun, 9 Jul 2017 12:34:54 -0400 Subject: [PATCH] Changed to epp syntax and rearranged class variables. --- examples/init.pp | 5 ++++- manifests/config.pp | 6 +++--- manifests/init.pp | 34 +++++++++++++++++----------------- manifests/install.pp | 34 ++++++++++++++++++---------------- templates/geth.service.epp | 30 ++++++++++++++++++++++++++++++ templates/geth.service.erb | 30 ------------------------------ 6 files changed, 72 insertions(+), 67 deletions(-) create mode 100644 templates/geth.service.epp delete mode 100644 templates/geth.service.erb diff --git a/examples/init.pp b/examples/init.pp index 5268cd0..aa19653 100644 --- a/examples/init.pp +++ b/examples/init.pp @@ -9,4 +9,7 @@ # Learn more about module testing here: # https://docs.puppet.com/guides/tests_smoke.html # -include ::geth +#include ::geth + +class { 'geth': +} diff --git a/manifests/config.pp b/manifests/config.pp index 17887ad..f440743 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,12 +1,12 @@ # == Class: geth::config class geth::config ( - $init_data = '/home/geth/data', - $account_password = 'P4ssw0rd!', + String $init_data = $geth::init_data, + String $account_password = $geth::account_password, ) inherits geth { exec { 'geth-init-data': cwd => '/home/geth', - command => 'geth --datadir data init ${init_data}', + command => "geth data init --datadir $init_data", user => 'geth', path => [ '/usr/bin', '/bin', '/usr/sbin' ], }~> diff --git a/manifests/init.pp b/manifests/init.pp index de09bcb..b479104 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -43,23 +43,23 @@ # Copyright 2017 Your name here, unless otherwise noted. # class geth ( - String $identity = $geth::install::identity, - String $networkid = $geth::install::networkid, - Integer $unlock = $geth::install::unlock, - Integer $port = $geth::install::port, - String $rpcaddr = $geth::install::rpcaddr, - Integer $rpcport = $geth::install::rpcport, - String $rpcapi = $geth::install::rpcapi, - String $rpccorsdomain = $geth::install::rpccorsdomain, - Integer $minerthreads = $geth::install::minerthreads, - String $nat = $geth::install::nat, - Integer $maxpeers = $geth::install::maxpeers, - Boolean $nodiscover = $geth::install::nodiscover, - Boolean $rpc = $geth::install::rpc, - Boolean $mine = $geth::install::mine, - Boolean $autodag = $geth::install::autodag, - String $init_data = $geth::config::init_data, - String $account_password = $geth::config::account_password, + String $identity = 'Participant1', + String $networkid = '1234321', + Integer $unlock = 0, + Integer $port = 30999, + String $rpcaddr = 'localhost', + Integer $rpcport = 8545, + String $rpcapi = 'admin,eth,net,web3', + String $rpccorsdomain = '*', + Integer $minerthreads = 1, + String $nat = 'any', + Integer $maxpeers = 0, + Boolean $nodiscover = true, + Boolean $rpc = true, + Boolean $mine = true, + Boolean $autodag = true, + String $init_data = '/home/geth/data', + String $account_password = 'P4ssw0rd!', ) { include geth::install diff --git a/manifests/install.pp b/manifests/install.pp index 7182bc5..189c5d7 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,21 +1,23 @@ # == Class: geth::install class geth::install ( - String $identity = 'Participant1', - String $networkid = '1234321', - Integer $unlock = 0, - Integer $port = 30999, - String $rpcaddr = 'localhost', - Integer $rpcport = 8545, - String $rpcapi = 'admin,eth,net,web3', - String $rpccorsdomain = '*', - Integer $minerthreads = 1, - String $nat = 'any', - Integer $maxpeers = 0, - Boolean $nodiscover = true, - Boolean $rpc = true, - Boolean $mine = true, - Boolean $autodag = true, + String $identity = $geth::identity, + String $networkid = $geth::networkid, + Integer $unlock = $geth::unlock, + Integer $port = $geth::port, + String $rpcaddr = $geth::rpcaddr, + Integer $rpcport = $geth::rpcport, + String $rpcapi = $geth::rpcapi, + String $rpccorsdomain = $geth::rpccorsdomain, + Integer $minerthreads = $geth::minerthreads, + String $nat = $geth::nat, + Integer $maxpeers = $geth::maxpeers, + Boolean $nodiscover = $geth::nodiscover, + Boolean $rpc = $geth::rpc, + Boolean $mine = $geth::mine, + Boolean $autodag = $geth::autodag, + String $init_data = $geth::init_data, + String $account_password = $geth::account_password, ) inherits geth { @@ -46,7 +48,7 @@ mode => '0644', owner => 'root', group => 'root', - content => template('geth/geth.service.erb'), + content => epp('geth/geth.service.erb'), }~> exec { 'geth-systemd-reload': command => 'systemctl daemon-reload', diff --git a/templates/geth.service.epp b/templates/geth.service.epp new file mode 100644 index 0000000..842ba4e --- /dev/null +++ b/templates/geth.service.epp @@ -0,0 +1,30 @@ +[Unit] +Description=Go Ethereum client +Wants=basic.target +After=basic.target network.target + +[Service] +WorkingDirectory=/home/geth +User=geth +ExecStart=nohup geth --datadir "<%= $init_data %>" \ + --identity "<%= $identity %>" \ + --networkid "<%= $networkid %>" \ + <% if $nodiscover == true %>--nodiscover<% end %> \ + --password <%= $passfile %> \ + --unlock "<%= $unlock %>" \ + --port "<%= $port %>" \ + <% if $rpc == true %>--rpc \ + --rpcaddr "<%= $rpcaddr %>" \ + --rpcport "<%= $rpcport %>" \ + --rpcapi "<%= $rpcapi %>" \ + --rpccorsdomain "<%= $rpccorsdomain %>"<% end %> \ + <% if $mine == true %>--mine \ + --minerthreads "<%= $minerthreads %>"<% end %> \ + <% if $autodag %>--autodag<% end %> \ + --nat "<%= $nat %>" \ + --maxpeers "<%= $maxpeers %>" \ + 2>> <%= $logdir %>/geth.log +Type=simple + +[Install] +WantedBy=default.target diff --git a/templates/geth.service.erb b/templates/geth.service.erb deleted file mode 100644 index 9e06dd8..0000000 --- a/templates/geth.service.erb +++ /dev/null @@ -1,30 +0,0 @@ -[Unit] -Description=Go Ethereum client -Wants=basic.target -After=basic.target network.target - -[Service] -WorkingDirectory=/home/geth -User=geth -ExecStart=nohup geth --datadir "<%= datadir %>" \ - --identity "<%= identity %>" \ - --networkid "<%= networkid %>" \ - <% if nodiscover %> --nodiscover <% end %> \ - --password <%= geth::config::passfile %> \ - --unlock "<%= unlock %>" \ - --port "<%= port %>" \ - <%= if rpc %> --rpc <% end %> \ - --rpcaddr "<%= rpcaddr %>" \ - --rpcport "<%= rpcport %>" \ - --rpcapi "<%= rpcapi %>" \ - --rpccorsdomain "<%= rpccorsdomain %>" \ - <% if mine %> --mine <% end %>\ - --minerthreads "<%= minerthreads %>" \ - <% if autodag %> --autodag <% end %> \ - --nat "<%= nat %>" \ - --maxpeers "<%= maxpeers %>" \ - 2>> <%= geth::config::logdir %>/geth.log -Type=simple - -[Install] -WantedBy=default.target