Generate the config files using a TOML parser

Now we don't need to change both the template and the resources to add
options
This commit is contained in:
Greg 2017-05-03 09:53:45 +02:00
parent 462e7ff858
commit e2b483eb3f
4 changed files with 52 additions and 31 deletions

View File

@ -6,4 +6,6 @@ description 'Installs/Configures kosmos-parity'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
gem 'toml'
depends 'ark'

View File

@ -33,25 +33,55 @@ dpkg_package "parity" do
end
parity_node "dev" do
config chain: "dev",
network_port: 30303,
json_rpc_port: 8545,
dapps_port: 8090,
ui_port: 8180
config parity: {
chain: "dev",
},
network: {
port: 30303,
},
rpc: {
port: 8545,
},
dapps: {
port: 8090,
},
ui: {
port: 8180,
}
end
parity_node "testnet" do
config chain: "ropsten",
network_port: 30304,
json_rpc_port: 8546,
dapps_port: 8091,
ui_port: 8181
config parity: {
chain: "ropsten",
},
network: {
port: 30304,
},
rpc: {
port: 8546,
},
dapps: {
port: 8091,
},
ui: {
port: 8181,
}
end
parity_node "mainnet" do
config chain: "homestead",
network_port: 30305,
json_rpc_port: 8547,
dapps_port: 8092,
ui_port: 8182
config parity: {
chain: "homestead",
},
network: {
port: 30305,
},
rpc: {
port: 8547,
},
dapps: {
port: 8092,
},
ui: {
port: 8182,
}
end

View File

@ -1,3 +1,5 @@
require 'toml'
provides :parity_node
property :name, String, name_property: true
@ -7,6 +9,7 @@ action :enable do
node_name = name
base_path = "#{node['kosmos-parity']['home_path']}/.local/share/io.parity.ethereum/#{name}"
config[:parity][:base_path] = base_path
directory base_path do
recursive true
@ -24,11 +27,10 @@ action :enable do
config_file = "#{base_path}/config.toml"
template config_file do
source "config.toml.erb"
file config_file do
content TOML::Generator.new(config).body
owner "parity"
group "parity"
variables config.merge(base_path: base_path)
end
execute "systemctl daemon-reload" do

View File

@ -1,13 +0,0 @@
[parity]
chain = "<%= @chain %>"
base_path = "<%= @base_path %>"
[network]
port = <%= @network_port %>
[rpc]
# JSON-RPC over HTTP
port = <%= @json_rpc_port %>
[dapps]
# Dapps Server
port = <%= @dapps_port %>
[ui]
port = <%= @ui_port %>