Split node config into separate recipes, support account creation
The account is automatically created and added to the list of accounts that are unlocked (can send without a password)
This commit is contained in:
parent
e2b483eb3f
commit
826b008fc0
@ -31,57 +31,3 @@ end
|
|||||||
dpkg_package "parity" do
|
dpkg_package "parity" do
|
||||||
source parity_package_path
|
source parity_package_path
|
||||||
end
|
end
|
||||||
|
|
||||||
parity_node "dev" do
|
|
||||||
config parity: {
|
|
||||||
chain: "dev",
|
|
||||||
},
|
|
||||||
network: {
|
|
||||||
port: 30303,
|
|
||||||
},
|
|
||||||
rpc: {
|
|
||||||
port: 8545,
|
|
||||||
},
|
|
||||||
dapps: {
|
|
||||||
port: 8090,
|
|
||||||
},
|
|
||||||
ui: {
|
|
||||||
port: 8180,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
parity_node "testnet" do
|
|
||||||
config parity: {
|
|
||||||
chain: "ropsten",
|
|
||||||
},
|
|
||||||
network: {
|
|
||||||
port: 30304,
|
|
||||||
},
|
|
||||||
rpc: {
|
|
||||||
port: 8546,
|
|
||||||
},
|
|
||||||
dapps: {
|
|
||||||
port: 8091,
|
|
||||||
},
|
|
||||||
ui: {
|
|
||||||
port: 8181,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
parity_node "mainnet" do
|
|
||||||
config parity: {
|
|
||||||
chain: "homestead",
|
|
||||||
},
|
|
||||||
network: {
|
|
||||||
port: 30305,
|
|
||||||
},
|
|
||||||
rpc: {
|
|
||||||
port: 8547,
|
|
||||||
},
|
|
||||||
dapps: {
|
|
||||||
port: 8092,
|
|
||||||
},
|
|
||||||
ui: {
|
|
||||||
port: 8182,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
34
site-cookbooks/kosmos-parity/recipes/node_dev.rb
Normal file
34
site-cookbooks/kosmos-parity/recipes/node_dev.rb
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#
|
||||||
|
# Cookbook Name:: kosmos-parity
|
||||||
|
# Recipe:: node_dev
|
||||||
|
#
|
||||||
|
# Copyright 2017, Kosmos
|
||||||
|
#
|
||||||
|
# All rights reserved - Do Not Redistribute
|
||||||
|
#
|
||||||
|
|
||||||
|
parity_node "dev" do
|
||||||
|
config parity: {
|
||||||
|
chain: "dev",
|
||||||
|
no_download: true, # Don't Download Updates
|
||||||
|
},
|
||||||
|
network: {
|
||||||
|
port: 30303,
|
||||||
|
warp: true,
|
||||||
|
},
|
||||||
|
rpc: {
|
||||||
|
port: 8545,
|
||||||
|
cors: "*",
|
||||||
|
},
|
||||||
|
dapps: {
|
||||||
|
port: 8090,
|
||||||
|
},
|
||||||
|
ui: {
|
||||||
|
port: 8180,
|
||||||
|
force: true,
|
||||||
|
},
|
||||||
|
mining: {
|
||||||
|
reseal_min_period: 0,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
26
site-cookbooks/kosmos-parity/recipes/node_mainnet.rb
Normal file
26
site-cookbooks/kosmos-parity/recipes/node_mainnet.rb
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#
|
||||||
|
# Cookbook Name:: kosmos-parity
|
||||||
|
# Recipe:: node_mainnet
|
||||||
|
#
|
||||||
|
# Copyright 2017, Kosmos
|
||||||
|
#
|
||||||
|
# All rights reserved - Do Not Redistribute
|
||||||
|
#
|
||||||
|
|
||||||
|
parity_node "mainnet" do
|
||||||
|
config parity: {
|
||||||
|
chain: "homestead",
|
||||||
|
},
|
||||||
|
network: {
|
||||||
|
port: 30305,
|
||||||
|
},
|
||||||
|
rpc: {
|
||||||
|
port: 8547,
|
||||||
|
},
|
||||||
|
dapps: {
|
||||||
|
port: 8092,
|
||||||
|
},
|
||||||
|
ui: {
|
||||||
|
port: 8182,
|
||||||
|
}
|
||||||
|
end
|
27
site-cookbooks/kosmos-parity/recipes/node_testnet.rb
Normal file
27
site-cookbooks/kosmos-parity/recipes/node_testnet.rb
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#
|
||||||
|
# Cookbook Name:: kosmos-parity
|
||||||
|
# Recipe:: node_testnet
|
||||||
|
#
|
||||||
|
# Copyright 2017, Kosmos
|
||||||
|
#
|
||||||
|
# All rights reserved - Do Not Redistribute
|
||||||
|
#
|
||||||
|
|
||||||
|
parity_node "testnet" do
|
||||||
|
config parity: {
|
||||||
|
chain: "ropsten",
|
||||||
|
},
|
||||||
|
network: {
|
||||||
|
port: 30304,
|
||||||
|
},
|
||||||
|
rpc: {
|
||||||
|
port: 8546,
|
||||||
|
},
|
||||||
|
dapps: {
|
||||||
|
port: 8091,
|
||||||
|
},
|
||||||
|
ui: {
|
||||||
|
port: 8181,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
@ -6,10 +6,16 @@ property :name, String, name_property: true
|
|||||||
property :config, Hash
|
property :config, Hash
|
||||||
|
|
||||||
action :enable do
|
action :enable do
|
||||||
node_name = name
|
include_recipe "kosmos-parity::default"
|
||||||
|
|
||||||
|
node_name = name
|
||||||
|
parity_service = "parity_#{node_name}"
|
||||||
base_path = "#{node['kosmos-parity']['home_path']}/.local/share/io.parity.ethereum/#{name}"
|
base_path = "#{node['kosmos-parity']['home_path']}/.local/share/io.parity.ethereum/#{name}"
|
||||||
|
config_path = "#{base_path}/config.toml"
|
||||||
|
|
||||||
config[:parity][:base_path] = base_path
|
config[:parity][:base_path] = base_path
|
||||||
|
config[:account] = {}
|
||||||
|
config[:account][:password] = ["#{base_path}/password"]
|
||||||
|
|
||||||
directory base_path do
|
directory base_path do
|
||||||
recursive true
|
recursive true
|
||||||
@ -25,12 +31,47 @@ action :enable do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config_file = "#{base_path}/config.toml"
|
node_path = "#{node['kosmos-parity']['home_path']}/.local/share/io.parity.ethereum/dev"
|
||||||
|
password_path = "#{node_path}/password"
|
||||||
|
|
||||||
file config_file do
|
file password_path do
|
||||||
|
content "parityparity"
|
||||||
|
owner "parity"
|
||||||
|
group "parity"
|
||||||
|
mode 0640
|
||||||
|
end
|
||||||
|
|
||||||
|
ruby_block "generate config" do
|
||||||
|
block do
|
||||||
|
parity_account_list = Mixlib::ShellOut.new(
|
||||||
|
"parity account list --chain #{config[:parity][:chain]} --base-path #{base_path}",
|
||||||
|
user: "parity"
|
||||||
|
)
|
||||||
|
parity_account_list.run_command
|
||||||
|
|
||||||
|
parity_account = parity_account_list.stdout.strip.gsub(/[(\[|\])]/, '')
|
||||||
|
|
||||||
|
if parity_account.empty?
|
||||||
|
parity_account_create = Mixlib::ShellOut.new(
|
||||||
|
"parity account new --chain #{config[:parity][:chain]} --base-path #{base_path} --password #{base_path}/password",
|
||||||
|
user: "parity"
|
||||||
|
)
|
||||||
|
parity_account_create.run_command
|
||||||
|
|
||||||
|
parity_account = parity_account_create.stdout.strip
|
||||||
|
end
|
||||||
|
|
||||||
|
config[:account][:unlock] = [parity_account]
|
||||||
|
|
||||||
|
file "config" do
|
||||||
|
path config_path
|
||||||
content TOML::Generator.new(config).body
|
content TOML::Generator.new(config).body
|
||||||
owner "parity"
|
owner "parity"
|
||||||
group "parity"
|
group "parity"
|
||||||
|
mode 0640
|
||||||
|
notifies :restart, "service[#{parity_service}]", :delayed
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
execute "systemctl daemon-reload" do
|
execute "systemctl daemon-reload" do
|
||||||
@ -38,10 +79,9 @@ action :enable do
|
|||||||
action :nothing
|
action :nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
parity_service = "parity_#{node_name}"
|
|
||||||
template "/lib/systemd/system/#{parity_service}.service" do
|
template "/lib/systemd/system/#{parity_service}.service" do
|
||||||
source "parity.systemd.service.erb"
|
source "parity.systemd.service.erb"
|
||||||
variables config_file: config_file
|
variables config_file: config_path
|
||||||
notifies :run, "execute[systemctl daemon-reload]", :delayed
|
notifies :run, "execute[systemctl daemon-reload]", :delayed
|
||||||
notifies :restart, "service[#{parity_service}]", :delayed
|
notifies :restart, "service[#{parity_service}]", :delayed
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user