Skip to content

Commit

Permalink
Some cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoît Clouet authored and Benoît Clouet committed Jul 10, 2017
1 parent bc2841e commit 90591ea
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 45 deletions.
34 changes: 16 additions & 18 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# == Class: geth::config
class geth::config (
String $user = $geth::user,
String $datadir = $geth::datadir,
String $init_data = $geth::init_data,
String $account_password = $geth::account_password,
String $passfile = $geth::passfile,
String $logdir = $geth::logdir,
)
inherits geth {
exec { 'geth-init-data':
cwd => '/home/geth',
command => "geth data init --datadir ${datadir} ${init_data} 2>> ${logdir}/init-data.log",
user => 'geth',
# Command is so long ?!?
timeout => 1800,
path => [ '/usr/bin', '/bin', '/usr/sbin' ],
}
~> file { 'passfile':
path => "${passfile}",
content => "${account_password}",
owner => 'geth',
mode => '0400',
}
~> exec { 'geth-create-account':
cwd => '/home/geth',
command => "geth account new --password ${passfile} 2>> ${logdir}/create-account.log",
{
exec { "geth --datadir ${datadir} init ${init_data} >> ${logdir}/init-data.log 2>&1":
cwd => "/home/${user}",
user => 'geth',
path => [ '/usr/bin', '/bin', '/usr/sbin' ],
}

~> file { $passfile:
content => $account_password,
owner => $user,
mode => '0400',
}

~> exec { "geth --datadir ${datadir} --password ${passfile} account new >> ${logdir}/create-account.log 2>&1":
cwd => "/home/${user}",
user => $user,
path => [ '/usr/bin', '/bin', '/usr/sbin' ],
}
}

17 changes: 7 additions & 10 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
# Copyright 2017 Your name here, unless otherwise noted.
#
class geth(
String $identity = 'Participant1',
String $networkid = '1234321',
String $user = 'geth',
String $identity = 'geth_identity',
String $networkid = '1234567890',
Integer $unlock = 0,
Integer $port = 30999,
String $rpcaddr = 'localhost',
Expand All @@ -58,14 +59,10 @@
Boolean $rpc = true,
Boolean $mine = true,
Boolean $autodag = true,
String $datadir = '/home/geth/data',
String $init_data = '/home/geth/data/customGENESIS.json',
String $passfile = '/home/geth/passfile',
String $datadir = "/home/${user}/data",
String $init_data = "/home/${user}/genesis.json",
String $passfile = "/home/${user}/passfile",
String $logdir = '/var/log/geth',
String $account_password = 'P4ssw0rd!',
)
{
include geth::install
include geth::config
include geth::service
}
{}
39 changes: 23 additions & 16 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# == Class: geth::install
class geth::install
(
String $user = $geth::user,
String $identity = $geth::identity,
String $networkid = $geth::networkid,
Integer $unlock = $geth::unlock,
Expand All @@ -21,7 +22,7 @@
String $passfile = $geth::passfile,
String $logdir = $geth::logdir,
)
inherits geth {
{

yumrepo { 'okay-repo':
baseurl => 'http://repo.okay.com.mx/centos/$releasever/$basearch/release',
Expand All @@ -35,18 +36,26 @@
require => Yumrepo['okay-repo'],
}

group { 'geth':
ensure => 'present',
# Proper time synchronization is needed for connecting to the blockchain
package { 'ntp':
ensure => installed,
}
~> service { 'ntpd':
ensure => running,
enable => true,
}

group { $user:
ensure => present,
}

user { 'geth':
ensure => 'present',
groups => 'geth',
user { $user:
ensure => present,
groups => $user,
managehome => true,
}

file { 'geth.service':
path => '/lib/systemd/system/geth.service',
file { '/lib/systemd/system/geth.service':
mode => '0644',
owner => 'root',
group => 'root',
Expand All @@ -58,17 +67,15 @@
refreshonly => true,
}

file { 'datadir':
ensure => 'directory',
path => "${datadir}",
owner => 'geth',
file { $datadir:
ensure => directory,
owner => $user,
mode => '0744',
}

file { 'logdir':
ensure => 'directory',
path => "${logdir}",
owner => 'geth',
file { $logdir:
ensure => directory,
owner => $user,
mode => '0755',
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Class: geth::service
class geth::service inherits geth{
class geth::service {
service { 'geth':
ensure => stopped,
enable => true,
Expand Down

0 comments on commit 90591ea

Please sign in to comment.