Skip to content

Commit

Permalink
Changed to epp syntax and rearranged class variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoît Clouet authored and Benoît Clouet committed Jul 9, 2017
1 parent 9c4c52c commit c7d02f2
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 67 deletions.
5 changes: 4 additions & 1 deletion examples/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
# Learn more about module testing here:
# https://docs.puppet.com/guides/tests_smoke.html
#
include ::geth
#include ::geth

class { 'geth':
}
6 changes: 3 additions & 3 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -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' ],
}~>
Expand Down
34 changes: 17 additions & 17 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 18 additions & 16 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -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',
Expand Down
30 changes: 30 additions & 0 deletions templates/geth.service.epp
Original file line number Diff line number Diff line change
@@ -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
30 changes: 0 additions & 30 deletions templates/geth.service.erb

This file was deleted.

0 comments on commit c7d02f2

Please sign in to comment.