Initial parity cookbook

Supports installing multiple instances of Parity on the same machine,
running on different ports

Refs #15
This commit is contained in:
Greg Karékinian 2017-05-02 17:43:02 +02:00
parent ccbf11a407
commit 2f8de91008
8 changed files with 202 additions and 0 deletions

View File

@ -0,0 +1,9 @@
# kosmos-parity CHANGELOG
## 0.1.0
- [Greg Karékinian] - Initial release of kosmos-parity
- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.

View File

@ -0,0 +1,53 @@
# kosmos-parity Cookbook
This cookbook installs [Parity](https://parity.io/) nodes
## Requirements
### Platforms
- Ubuntu
### Chef
- Chef 12.1 or later
## Attributes
### kosmos-parity::default
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['kosmos-parity']['home_path']</tt></td>
<td>String</td>
<td>The parity user's home path</td>
<td><tt>/home/parity</tt></td>
</tr>
</table>
## Usage
### kosmos-parity::default
Just include `kosmos-parity` in your node's `run_list`:
```json
{
"name":"my_node",
"run_list": [
"recipe[kosmos-parity]"
]
}
```
## License and Authors
Authors:
* Greg Karékinian

View File

@ -0,0 +1 @@
node.default['kosmos-parity']['home_path'] = "/home/parity"

View File

@ -0,0 +1,9 @@
name 'kosmos-parity'
maintainer 'Kosmos'
maintainer_email 'mail@kosmos.org'
license 'All rights reserved'
description 'Installs/Configures kosmos-parity'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'ark'

View File

@ -0,0 +1,56 @@
#
# Cookbook Name:: kosmos-parity
# Recipe:: default
#
# Copyright 2017, Kosmos
#
# All rights reserved - Do Not Redistribute
#
group "parity" do
gid 72748
end
user "parity" do
system true
manage_home true
comment "parity user"
uid 72748
gid 72748
end
parity_version = "1.6.6"
parity_package_path = "#{Chef::Config[:file_cache_path]}/parity_#{parity_version}_amd64.deb"
remote_file parity_package_path do
source "https://d1h4xl4cr1h0mo.cloudfront.net/v#{parity_version}/x86_64-unknown-linux-gnu/parity_#{parity_version}_amd64.deb"
mode 0750
notifies :install, "dpkg_package[parity]", :immediately
end
dpkg_package "parity" do
source parity_package_path
end
parity_node "dev" do
config chain: "dev",
network_port: 30303,
json_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
end
parity_node "mainnet" do
config chain: "homestead",
network_port: 30305,
json_rpc_port: 8547,
dapps_port: 8092,
ui_port: 8182
end

View File

@ -0,0 +1,50 @@
provides :parity_node
property :name, String, name_property: true
property :config, Hash
action :enable do
node_name = name
base_path = "#{node['kosmos-parity']['home_path']}/.local/share/io.parity.ethereum/#{name}"
directory base_path do
recursive true
owner "parity"
group "parity"
end
%w(chains keys).each do |subfolder|
directory "#{base_path}/#{subfolder}" do
recursive true
owner "parity"
group "parity"
end
end
config_file = "#{base_path}/config.toml"
template config_file do
source "config.toml.erb"
owner "parity"
group "parity"
variables config.merge(base_path: base_path)
end
execute "systemctl daemon-reload" do
command "systemctl daemon-reload"
action :nothing
end
parity_service = "parity_#{node_name}"
template "/lib/systemd/system/#{parity_service}.service" do
source "parity.systemd.service.erb"
variables config_file: config_file
notifies :run, "execute[systemctl daemon-reload]", :delayed
notifies :restart, "service[#{parity_service}]", :delayed
end
service parity_service do
action [:enable, :start]
end
end

View File

@ -0,0 +1,13 @@
[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 %>

View File

@ -0,0 +1,11 @@
[Unit]
Description=Parity Daemon (<%= @environment %>)
After=network.target
[Service]
ExecStart=/usr/bin/parity --config <%= @config_file %> $ARGS
User=parity
Group=parity
[Install]
WantedBy=default.target