Skip to content

Commit

Permalink
Added configuration options.
Browse files Browse the repository at this point in the history
  • Loading branch information
clouetb committed Jul 8, 2017
1 parent bc17bec commit b94cc13
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 22 deletions.
12 changes: 8 additions & 4 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# == Class: geth::config
class geth::config ($init_data, $account_password) inherits geth {
class geth::config (
$init_data = '/home/geth/data',
$account_password = 'P4ssw0rd!',
)
inherits geth {
exec { 'geth-init-data':
cwd => '/home/geth'
command => 'geth --datadir data init $init_data',
cwd => '/home/geth',
command => 'geth --datadir data init ${init_data}',
user => 'geth',
path => [ '/usr/bin', '/bin', '/usr/sbin' ],
}~>
Expand All @@ -13,7 +17,7 @@
mode => '0400',
}~>
exec { 'geth-create-account':
cwd => '/home/geth'
cwd => '/home/geth',
command => 'geth account new --password /home/geth/passfile',
user => 'geth',
path => [ '/usr/bin', '/bin', '/usr/sbin' ],
Expand Down
18 changes: 16 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,23 @@
#
# Copyright 2017 Your name here, unless otherwise noted.
#
class geth {
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,
String $init_data = $geth::config::init_data,
String $account_password = $geth::config::account_password,
)
{
include geth::install
include geth::config
include geth::service

}
38 changes: 30 additions & 8 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# == Class: geth::install
class geth::install inherits geth {
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,
)
inherits geth {

yumrepo { 'okay-repo':
baseurl => 'http://repo.okay.com.mx/centos/$releasever/$basearch/release',
Expand All @@ -23,13 +37,8 @@
managehome => true,
}

file { 'datadir':
path => '/home/geth/data',
ensure => 'directory',
owner => 'geth',
}

file { '/lib/systemd/system/geth.service':
file { 'geth.service':
path => '/lib/systemd/system/geth.service',
mode => '0644',
owner => 'root',
group => 'root',
Expand All @@ -40,6 +49,19 @@
path => [ '/usr/bin', '/bin', '/usr/sbin' ],
refreshonly => true,
}

file { 'datadir':
path => '/home/geth/data',
ensure => 'directory',
owner => 'geth',
mode => '0744',
}

file { 'logdir':
path => '/var/log/geth',
ensure => 'directory',
owner => 'geth',
mode => '0755',
}
}

8 changes: 1 addition & 7 deletions manifests/service.pp
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# == Class: geth::service
class geth::service inherits geth {
file { 'logdir':
path => '/var/log/geth',
ensure => 'directory',
owner => 'geth',
mode => '0755',
}~>
service { 'geth':
ensure => running,
ensure => stopped,
enable => true,
}
}
19 changes: 18 additions & 1 deletion templates/geth.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,24 @@ After=basic.target network.target
[Service]
WorkingDirectory=/home/geth
User=geth
ExecStart=/usr/bin/geth
ExecStart=nohup geth --datadir "<%= ${datadir} %>" \
--identity "<%= ${identity} %>" \
--networkid "<%= ${networkid} %>" \
--nodiscover \
--password <%= ${geth::config::passfile} %> \
--unlock "<%= ${unlock} %>" \
--port "<%= ${port} %>" \
--rpc \
--rpcaddr "<%= ${rpcaddr} %>" \
--rpcport "<%= ${rpcport} %>" \
--rpcapi "<%= ${rpcapi} %>" \
--rpccorsdomain "<%= ${rpccorsdomain} %>" \
--mine \
--minerthreads "<%= ${minerthreads} %>" \
--autodag \
--nat "<%= ${nat} %>" \
--maxpeers "<%= ${maxpeers} %>" \
2>> <%= ${geth::config::logdir} %>/geth.log
Type=simple

[Install]
Expand Down

0 comments on commit b94cc13

Please sign in to comment.