diff --git a/site-cookbooks/kosmos-parity/CHANGELOG.md b/site-cookbooks/kosmos-parity/CHANGELOG.md new file mode 100644 index 0000000..fa0d873 --- /dev/null +++ b/site-cookbooks/kosmos-parity/CHANGELOG.md @@ -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. diff --git a/site-cookbooks/kosmos-parity/README.md b/site-cookbooks/kosmos-parity/README.md new file mode 100644 index 0000000..7357580 --- /dev/null +++ b/site-cookbooks/kosmos-parity/README.md @@ -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 + + + + + + + + + + + + + + +
KeyTypeDescriptionDefault
['kosmos-parity']['home_path']StringThe parity user's home path/home/parity
+ +## 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 diff --git a/site-cookbooks/kosmos-parity/attributes/default.rb b/site-cookbooks/kosmos-parity/attributes/default.rb new file mode 100644 index 0000000..6910075 --- /dev/null +++ b/site-cookbooks/kosmos-parity/attributes/default.rb @@ -0,0 +1 @@ +node.default['kosmos-parity']['home_path'] = "/home/parity" diff --git a/site-cookbooks/kosmos-parity/metadata.rb b/site-cookbooks/kosmos-parity/metadata.rb new file mode 100644 index 0000000..a29b08d --- /dev/null +++ b/site-cookbooks/kosmos-parity/metadata.rb @@ -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' diff --git a/site-cookbooks/kosmos-parity/recipes/default.rb b/site-cookbooks/kosmos-parity/recipes/default.rb new file mode 100644 index 0000000..674eb18 --- /dev/null +++ b/site-cookbooks/kosmos-parity/recipes/default.rb @@ -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 diff --git a/site-cookbooks/kosmos-parity/resources/node.rb b/site-cookbooks/kosmos-parity/resources/node.rb new file mode 100644 index 0000000..5301fc0 --- /dev/null +++ b/site-cookbooks/kosmos-parity/resources/node.rb @@ -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 diff --git a/site-cookbooks/kosmos-parity/templates/default/config.toml.erb b/site-cookbooks/kosmos-parity/templates/default/config.toml.erb new file mode 100644 index 0000000..034c2e3 --- /dev/null +++ b/site-cookbooks/kosmos-parity/templates/default/config.toml.erb @@ -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 %> diff --git a/site-cookbooks/kosmos-parity/templates/default/parity.systemd.service.erb b/site-cookbooks/kosmos-parity/templates/default/parity.systemd.service.erb new file mode 100644 index 0000000..073e82d --- /dev/null +++ b/site-cookbooks/kosmos-parity/templates/default/parity.systemd.service.erb @@ -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