Bitcoin (Core) cookbook #121
|
@ -95,7 +95,8 @@ Vagrant.configure(2) do |config|
|
|||
chef.environment = 'development'
|
||||
chef.add_recipe 'kosmos-base'
|
||||
chef.add_recipe 'kosmos_encfs'
|
||||
# chef.add_recipe 'kosmos-postgresql::default'
|
||||
# chef.add_recipe 'kosmos-bitcoin::source'
|
||||
|
||||
# chef.add_recipe 'kosmos-mediawiki'
|
||||
# chef.add_recipe 'kosmos-wordpress'
|
||||
# chef.add_recipe 'kosmos-ejabberd'
|
||||
# chef.add_recipe 'kosmos-hubot::botka_freenode'
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"id": "bitcoin",
|
||||
"rpcpassword": {
|
||||
"encrypted_data": "dBXJXEYJIoWzo+TPg8CzaKfTo94SdowFDdQKVL/njQ==\n",
|
||||
"iv": "UNragm2xuewXZu0v\n",
|
||||
"auth_tag": "tfjO8qfvti3k5L3Ms2jPLw==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
}
|
||||
}
|
|
@ -16,6 +16,28 @@
|
|||
},
|
||||
"kosmos-dirsrv": {
|
||||
"master_hostname": "localhost"
|
||||
},
|
||||
"bitcoin": {
|
||||
"conf": {
|
||||
"testnet": 1,
|
||||
"irc": 1,
|
||||
"dnsseed": 1,
|
||||
"upnp": 1,
|
||||
"checkblocks": 10,
|
||||
"checklevel": 1,
|
||||
"txindex": 1,
|
||||
"whitelist": "127.0.0.1",
|
||||
"listen": 1,
|
||||
"server": 1,
|
||||
"rpcport": 8332,
|
||||
"rpcssl": 0,
|
||||
"rpcuser": "bitcoind",
|
||||
"rpcbind": "127.0.0.1:8336",
|
||||
"port": 8335,
|
||||
"gen": 0,
|
||||
"zmqpubrawblock": "tcp://127.0.0.1:8337",
|
||||
"zmqpubrawtx": "tcp://127.0.0.1:8338"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"automatic": {
|
||||
"fqdn": "draco.kosmos.org",
|
||||
"os": "linux",
|
||||
"os_version": "5.4.0-37-generic",
|
||||
"os_version": "5.4.0-42-generic",
|
||||
"hostname": "draco",
|
||||
"ipaddress": "148.251.237.73",
|
||||
"roles": [
|
||||
|
@ -20,6 +20,7 @@
|
|||
"kosmos_encfs",
|
||||
"kosmos_encfs::default",
|
||||
"kosmos-postgresql::replica",
|
||||
"kosmos-bitcoin::source",
|
||||
"apt::default",
|
||||
"timezone_iii::default",
|
||||
"timezone_iii::debian",
|
||||
|
@ -35,6 +36,7 @@
|
|||
"hostname::default",
|
||||
"firewall::default",
|
||||
"chef-sugar::default",
|
||||
"ark::default",
|
||||
"build-essential::default"
|
||||
],
|
||||
"platform": "ubuntu",
|
||||
|
@ -54,6 +56,7 @@
|
|||
"run_list": [
|
||||
"recipe[kosmos-base]",
|
||||
"recipe[kosmos_encfs]",
|
||||
"role[postgresql_replica]"
|
||||
"role[postgresql_replica]",
|
||||
"recipe[kosmos-bitcoin::source]"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
# Delivery for Local Phases Execution
|
||||
#
|
||||
# This file allows you to execute test phases locally on a workstation or
|
||||
# in a CI pipeline. The delivery-cli will read this file and execute the
|
||||
# command(s) that are configured for each phase. You can customize them
|
||||
# by just modifying the phase key on this file.
|
||||
#
|
||||
# By default these phases are configured for Cookbook Workflow only
|
||||
#
|
||||
|
||||
[local_phases]
|
||||
unit = "chef exec rspec spec/"
|
||||
lint = "chef exec cookstyle"
|
||||
# Foodcritic includes rules only appropriate for community cookbooks
|
||||
# uploaded to Supermarket. We turn off any rules tagged "supermarket"
|
||||
# by default. If you plan to share this cookbook you should remove
|
||||
# '-t ~supermarket' below to enable supermarket rules.
|
||||
syntax = "chef exec foodcritic . -t ~supermarket"
|
||||
provision = "chef exec kitchen create"
|
||||
deploy = "chef exec kitchen converge"
|
||||
smoke = "chef exec kitchen verify"
|
||||
# The functional phase is optional, you can define it by uncommenting
|
||||
# the line below and running the command: `delivery local functional`
|
||||
# functional = ""
|
||||
cleanup = "chef exec kitchen destroy"
|
||||
|
||||
# Remote project.toml file
|
||||
#
|
||||
# Instead of the local phases above, you may specify a remote URI location for
|
||||
# the `project.toml` file. This is useful for teams that wish to centrally
|
||||
# manage the behavior of the `delivery local` command across many different
|
||||
# projects.
|
||||
#
|
||||
# remote_file = "https://url/project.toml"
|
|
@ -0,0 +1,22 @@
|
|||
.vagrant
|
||||
*~
|
||||
*#
|
||||
.#*
|
||||
\#*#
|
||||
.*.sw[a-z]
|
||||
*.un~
|
||||
|
||||
# Bundler
|
||||
Gemfile.lock
|
||||
gems.locked
|
||||
bin/*
|
||||
.bundle/*
|
||||
|
||||
# test kitchen
|
||||
.kitchen/
|
||||
kitchen.local.yml
|
||||
|
||||
# Chef
|
||||
Berksfile.lock
|
||||
.zero-knife.rb
|
||||
Policyfile.lock.json
|
|
@ -0,0 +1,11 @@
|
|||
# kosmos-bitcoin CHANGELOG
|
||||
|
||||
This file is used to list changes made in each version of the kosmos-bitcoin cookbook.
|
||||
|
||||
# 0.1.0
|
||||
|
||||
Initial release.
|
||||
|
||||
- change 0
|
||||
- change 1
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2020 Kosmos Developers
|
||||
raucao marked this conversation as resolved
Outdated
greg
commented
The license should be MIT like the other kosmos cookbooks The license should be MIT like the other kosmos cookbooks
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,16 @@
|
|||
# Policyfile.rb - Describe how you want Chef Infra Client to build your system.
|
||||
#
|
||||
# For more information on the Policyfile feature, visit
|
||||
# https://docs.chef.io/policyfile.html
|
||||
|
||||
# A name that describes what the system you're building with Chef does.
|
||||
name 'kosmos-bitcoin'
|
||||
|
||||
# Where to find external cookbooks:
|
||||
default_source :supermarket
|
||||
|
||||
# run_list: chef-client will run these recipes in the order specified.
|
||||
run_list 'kosmos-bitcoin::default'
|
||||
|
||||
# Specify a custom source for a single cookbook:
|
||||
cookbook 'kosmos-bitcoin', path: '.'
|
|
@ -0,0 +1,3 @@
|
|||
# kosmos-bitcoin
|
||||
|
||||
Installs/configures bitcoin core node
|
|
@ -0,0 +1,25 @@
|
|||
node.default['bitcoin']['version'] = '0.20.1'
|
||||
node.default['bitcoin']['checksum'] = '4bbd62fd6acfa5e9864ebf37a24a04bc2dcfe3e3222f056056288d854c53b978'
|
||||
node.default['bitcoin']['username'] = 'satoshi'
|
||||
node.default['bitcoin']['usergroup'] = 'bitcoin'
|
||||
node.default['bitcoin']['network'] = 'mainnet'
|
||||
node.default['bitcoin']['datadir'] = '/home/satoshi/.bitcoin'
|
||||
node.default['bitcoin']['walletdir'] = '/mnt/data/bitcoin'
|
||||
|
||||
node.default['bitcoin']['conf'] = {
|
||||
irc: 1,
|
||||
dnsseed: 1,
|
||||
upnp: 1,
|
||||
checkblocks: 10,
|
||||
checklevel: 1,
|
||||
txindex: 1,
|
||||
whitelist: '127.0.0.1',
|
||||
listen: 1,
|
||||
server: 1,
|
||||
rpcssl: 0,
|
||||
rpcuser: 'satoshi',
|
||||
rpcbind: "127.0.0.1:8332",
|
||||
gen: 0,
|
||||
zmqpubrawblock: 'tcp://127.0.0.1:8337',
|
||||
zmqpubrawtx: 'tcp://127.0.0.1:8338'
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
# Put files/directories that should be ignored in this file when uploading
|
||||
# to a Chef Infra Server or Supermarket.
|
||||
# Lines that start with '# ' are comments.
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store
|
||||
ehthumbs.db
|
||||
Icon?
|
||||
nohup.out
|
||||
Thumbs.db
|
||||
|
||||
# SASS #
|
||||
########
|
||||
.sass-cache
|
||||
|
||||
# EDITORS #
|
||||
###########
|
||||
.#*
|
||||
.project
|
||||
.settings
|
||||
*_flymake
|
||||
*_flymake.*
|
||||
*.bak
|
||||
*.sw[a-z]
|
||||
*.tmproj
|
||||
*~
|
||||
\#*
|
||||
mkmf.log
|
||||
REVISION
|
||||
TAGS*
|
||||
tmtags
|
||||
|
||||
## COMPILED ##
|
||||
##############
|
||||
*.class
|
||||
*.com
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.pyc
|
||||
*.so
|
||||
*/rdoc/
|
||||
a.out
|
||||
|
||||
# Testing #
|
||||
###########
|
||||
.circleci/*
|
||||
.codeclimate.yml
|
||||
.foodcritic
|
||||
.kitchen*
|
||||
.rspec
|
||||
.rubocop.yml
|
||||
.travis.yml
|
||||
.watchr
|
||||
azure-pipelines.yml
|
||||
examples/*
|
||||
features/*
|
||||
Guardfile
|
||||
kitchen.yml*
|
||||
Procfile
|
||||
Rakefile
|
||||
spec/*
|
||||
spec/*
|
||||
spec/fixtures/*
|
||||
test/*
|
||||
|
||||
# SCM #
|
||||
#######
|
||||
.git
|
||||
.gitattributes
|
||||
.gitconfig
|
||||
.github/*
|
||||
.gitignore
|
||||
.gitmodules
|
||||
.svn
|
||||
*/.bzr/*
|
||||
*/.git
|
||||
*/.hg/*
|
||||
*/.svn/*
|
||||
|
||||
# Berkshelf #
|
||||
#############
|
||||
Berksfile
|
||||
Berksfile.lock
|
||||
cookbooks/*
|
||||
tmp
|
||||
|
||||
# Bundler #
|
||||
###########
|
||||
vendor/*
|
||||
Gemfile
|
||||
Gemfile.lock
|
||||
|
||||
# Policyfile #
|
||||
##############
|
||||
Policyfile.rb
|
||||
Policyfile.lock.json
|
||||
|
||||
# Cookbooks #
|
||||
#############
|
||||
CHANGELOG*
|
||||
CONTRIBUTING*
|
||||
TESTING*
|
||||
CODE_OF_CONDUCT*
|
||||
|
||||
# Vagrant #
|
||||
###########
|
||||
.vagrant
|
||||
Vagrantfile
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
driver:
|
||||
name: vagrant
|
||||
|
||||
## The forwarded_port port feature lets you connect to ports on the VM guest via
|
||||
## localhost on the host.
|
||||
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports.html
|
||||
|
||||
# network:
|
||||
# - ["forwarded_port", {guest: 80, host: 8080}]
|
||||
|
||||
provisioner:
|
||||
name: chef_zero
|
||||
|
||||
## product_name and product_version specifies a specific Chef product and version to install.
|
||||
## see the Chef documentation for more details: https://docs.chef.io/config_yml_kitchen.html
|
||||
# product_name: chef
|
||||
# product_version: 15
|
||||
|
||||
verifier:
|
||||
name: inspec
|
||||
|
||||
platforms:
|
||||
- name: ubuntu-18.04
|
||||
- name: centos-7
|
||||
|
||||
suites:
|
||||
- name: default
|
||||
verifier:
|
||||
inspec_tests:
|
||||
- test/integration/default
|
||||
attributes:
|
|
@ -0,0 +1,23 @@
|
|||
name 'kosmos-bitcoin'
|
||||
maintainer 'Kosmos Developers'
|
||||
maintainer_email 'mail@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/Configures Bitcoin Core'
|
||||
long_description 'Installs/Configures Bitcoin Core'
|
||||
version '0.1.0'
|
||||
chef_version '>= 14.0'
|
||||
|
||||
# The `issues_url` points to the location where issues for this cookbook are
|
||||
# tracked. A `View Issues` link will be displayed on this cookbook's page when
|
||||
# uploaded to a Supermarket.
|
||||
#
|
||||
# issues_url 'https://github.com/<insert_org_here>/kosmos-bitcoin/issues'
|
||||
|
||||
# The `source_url` points to the development repository for this cookbook. A
|
||||
# `View Source` link will be displayed on this cookbook's page when uploaded to
|
||||
# a Supermarket.
|
||||
#
|
||||
# source_url 'https://github.com/<insert_org_here>/kosmos-bitcoin'
|
||||
|
||||
depends "ark"
|
||||
depends "kosmos_encfs"
|
|
@ -0,0 +1,103 @@
|
|||
#
|
||||
# Cookbook:: kosmos-bitcoin
|
||||
# Recipe:: snapd
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright:: 2020, Kosmos Developers
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
|
||||
# FIXME: Switch to the snap_package resource when it gets fixed:
|
||||
# https://github.com/chef/chef/issues/8827
|
||||
execute "snap install bitcoin-core --channel=latest/stable"
|
||||
|
||||
bitcoin_user = node['bitcoin']['username']
|
||||
bitcoin_group = node['bitcoin']['usergroup']
|
||||
bitcoin_datadir = node['bitcoin']['datadir']
|
||||
bitcoin_snapdir = "/home/#{bitcoin_user}/snap/bitcoin-core/common/.bitcoin"
|
||||
|
||||
user bitcoin_user do
|
||||
manage_home true
|
||||
shell "/bin/bash"
|
||||
end
|
||||
|
||||
directory bitcoin_datadir do
|
||||
owner bitcoin_user
|
||||
group bitcoin_group
|
||||
mode '0755'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
|
||||
bitcoin_config = node['bitcoin']['conf'].merge({
|
||||
rpcpassword: credentials["rpcpassword"]
|
||||
})
|
||||
|
||||
template "#{bitcoin_datadir}/bitcoin.conf" do
|
||||
owner bitcoin_user
|
||||
group bitcoin_group
|
||||
variables conf: bitcoin_config,
|
||||
mainnet_conf: node['bitcoin']['mainnet_conf'],
|
||||
testnet_conf: node['bitcoin']['testnet_conf'],
|
||||
regtest_conf: node['bitcoin']['regtest_conf']
|
||||
action :create
|
||||
notifies :restart, "systemd_unit[bitcoind.service]", :delayed
|
||||
end
|
||||
|
||||
directory bitcoin_snapdir do
|
||||
owner bitcoin_user
|
||||
group bitcoin_group
|
||||
mode '0750'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
|
||||
execute "chown -R #{bitcoin_user}:#{bitcoin_group} /home/#{bitcoin_user}/snap"
|
||||
|
||||
mount bitcoin_snapdir do
|
||||
device bitcoin_datadir
|
||||
fstype 'none'
|
||||
options 'bind'
|
||||
action [:mount]
|
||||
end
|
||||
|
||||
systemd_unit 'bitcoind.service' do
|
||||
content({
|
||||
Unit: {
|
||||
Description: 'Bitcoin Core daemon',
|
||||
Documentation: ['https://bitcoincore.org'],
|
||||
After: 'network.target'
|
||||
},
|
||||
Service: {
|
||||
User: bitcoin_user,
|
||||
Type: 'exec',
|
||||
ExecStart: '/snap/bin/bitcoin-core.daemon',
|
||||
PIDFile: "#{bitcoin_snapdir}/bitcoind.pid",
|
||||
Restart: 'on-failure',
|
||||
},
|
||||
Install: {
|
||||
WantedBy: 'multi-user.target'
|
||||
}
|
||||
})
|
||||
verify false
|
||||
triggers_reload true
|
||||
action [:create, :enable, :start]
|
||||
end
|
|
@ -0,0 +1,151 @@
|
|||
#
|
||||
# Cookbook:: kosmos-bitcoin
|
||||
# Recipe:: source
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright:: 2020, Kosmos Developers
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
|
||||
include_recipe 'ark'
|
||||
|
||||
build_essential
|
||||
|
||||
%w{ libtool autotools-dev make automake cmake curl g++-multilib libtool
|
||||
binutils-gold bsdmainutils pkg-config python3 patch }.each do |pkg|
|
||||
apt_package pkg
|
||||
end
|
||||
|
||||
ark 'bitcoind' do
|
||||
url "https://bitcoincore.org/bin/bitcoin-core-#{node['bitcoin']['version']}/bitcoin-#{node['bitcoin']['version']}.tar.gz"
|
||||
checksum node['bitcoin']['checksum']
|
||||
action :put
|
||||
end
|
||||
|
||||
execute "Compile bitcoin-core dependencies" do
|
||||
cwd "/usr/local/bitcoind/depends"
|
||||
command "make NO_QT=1"
|
||||
not_if { ::File.directory?("/usr/local/bitcoind/depends/x86_64-pc-linux-gnu") }
|
||||
end
|
||||
|
||||
execute "Configure bitcoin-core" do
|
||||
cwd "/usr/local/bitcoind"
|
||||
command [
|
||||
"./autogen.sh",
|
||||
"./configure --prefix=$PWD/depends/x86_64-pc-linux-gnu"
|
||||
]
|
||||
not_if { ::File.exist?("/usr/local/bitcoind/src/bitcoind") }
|
||||
end
|
||||
|
||||
execute "Compile bitcoin-core" do
|
||||
cwd "/usr/local/bitcoind"
|
||||
command "make"
|
||||
not_if { ::File.exist?("/usr/local/bitcoind/src/bitcoind") }
|
||||
end
|
||||
|
||||
link "/usr/local/bin/bitcoind" do
|
||||
to "/usr/local/bitcoind/src/bitcoind"
|
||||
end
|
||||
|
||||
link "/usr/local/bin/bitcoin-cli" do
|
||||
to "/usr/local/bitcoind/src/bitcoin-cli"
|
||||
end
|
||||
|
||||
bitcoin_user = node['bitcoin']['username']
|
||||
bitcoin_group = node['bitcoin']['usergroup']
|
||||
bitcoin_datadir = node['bitcoin']['datadir']
|
||||
bitcoin_walletdir = node['bitcoin']['walletdir']
|
||||
credentials = Chef::EncryptedDataBagItem.load('credentials', 'bitcoin')
|
||||
|
||||
group bitcoin_group
|
||||
|
||||
user bitcoin_user do
|
||||
manage_home true
|
||||
gid bitcoin_group
|
||||
shell "/bin/bash"
|
||||
end
|
||||
|
||||
[bitcoin_datadir, bitcoin_walletdir].each do |path|
|
||||
directory path do
|
||||
owner bitcoin_user
|
||||
group bitcoin_group
|
||||
mode '0750'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
bitcoin_config = node['bitcoin']['conf'].merge({
|
||||
rpcpassword: credentials["rpcpassword"]
|
||||
})
|
||||
|
||||
template "#{bitcoin_datadir}/bitcoin.conf" do
|
||||
owner bitcoin_user
|
||||
group bitcoin_group
|
||||
mode '0640'
|
||||
variables conf: bitcoin_config,
|
||||
mainnet_conf: node['bitcoin']['mainnet_conf'],
|
||||
testnet_conf: node['bitcoin']['testnet_conf'],
|
||||
regtest_conf: node['bitcoin']['regtest_conf']
|
||||
action :create
|
||||
notifies :restart, "systemd_unit[bitcoind.service]", :delayed
|
||||
end
|
||||
|
||||
systemd_unit 'bitcoind.service' do
|
||||
content({
|
||||
Unit: {
|
||||
Description: 'Bitcoin Core daemon',
|
||||
Documentation: ['https://bitcoincore.org'],
|
||||
After: 'network.target'
|
||||
},
|
||||
Service: {
|
||||
User: bitcoin_user,
|
||||
Type: 'simple',
|
||||
ExecStart: "bitcoind -datadir=#{bitcoin_datadir} -walletdir=#{bitcoin_walletdir} -pid=#{bitcoin_datadir}/bitcoind.pid",
|
||||
PIDFile: "#{bitcoin_datadir}/bitcoind.pid",
|
||||
Restart: 'always',
|
||||
PrivateTmp: true,
|
||||
LimitNOFILE: 'infinity',
|
||||
TimeoutStopSec: '60s',
|
||||
TimeoutStartSec: '20s',
|
||||
StartLimitInterval: '60s',
|
||||
StartLimitBurst: '2'
|
||||
},
|
||||
Install: {
|
||||
WantedBy: 'multi-user.target'
|
||||
}
|
||||
})
|
||||
verify false
|
||||
triggers_reload true
|
||||
action [:create, :start]
|
||||
end
|
||||
|
||||
# Creates/starts a Path unit which starts the bitcoind service when the
|
||||
# encrypted data directory is mounted
|
||||
# TODO move to custom kosmos cookbook before publishing bitcoin cookbook
|
||||
encfs_path_activation_unit 'bitcoind.service'
|
||||
|
||||
# TODO move to custom kosmos cookbook before publishing bitcoin cookbook
|
||||
firewall_rule 'bitcoind' do
|
||||
port [8333] # TODO adjust for testnet
|
||||
protocol :tcp
|
||||
command :allow
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
require 'chefspec'
|
||||
require 'chefspec/policyfile'
|
|
@ -0,0 +1,29 @@
|
|||
#
|
||||
# Cookbook:: kosmos-bitcoin
|
||||
# Spec:: default
|
||||
#
|
||||
# Copyright:: 2019, The Authors, All Rights Reserved.
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'kosmos-bitcoin::default' do
|
||||
context 'When all attributes are default, on Ubuntu 18.04' do
|
||||
# for a complete list of available platforms and versions see:
|
||||
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
|
||||
platform 'ubuntu', '18.04'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { chef_run }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context 'When all attributes are default, on CentOS 7' do
|
||||
# for a complete list of available platforms and versions see:
|
||||
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
|
||||
platform 'centos', '7'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { chef_run }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,34 @@
|
|||
##
|
||||
## bitcoin.conf configuration file. Lines beginning with # are comments.
|
||||
##
|
||||
## Generated by Chef. Do not edit directly, or your changes will be overwritten
|
||||
## during the next Chef run!
|
||||
##
|
||||
|
||||
<% @conf.sort.each do |key, value| %>
|
||||
<%= "#{key}=#{value}" %>
|
||||
<% end %>
|
||||
|
||||
<% if @mainnet_conf %>
|
||||
# Options only for mainnet
|
||||
[main]
|
||||
<% @mainnet_conf.sort.each do |key, value| %>
|
||||
<%= "#{key}=#{value}" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @testnet_conf %>
|
||||
# Options only for testnet
|
||||
[test]
|
||||
<% @testnet_conf.sort.each do |key, value| %>
|
||||
<%= "#{key}=#{value}" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @regtest_conf %>
|
||||
# Options only for regtest
|
||||
[regtest]
|
||||
<% @regtest_conf.sort.each do |key, value| %>
|
||||
<%= "#{key}=#{value}" %>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -0,0 +1,16 @@
|
|||
# InSpec test for recipe kosmos-bitcoin::default
|
||||
|
||||
# The InSpec reference, with examples and extensive documentation, can be
|
||||
# found at https://www.inspec.io/docs/reference/resources/
|
||||
|
||||
unless os.windows?
|
||||
# This is an example test, replace with your own test.
|
||||
describe user('root'), :skip do
|
||||
it { should exist }
|
||||
end
|
||||
end
|
||||
|
||||
# This is an example test, replace it with your own test.
|
||||
describe port(80), :skip do
|
||||
it { should_not be_listening }
|
||||
end
|
Loading…
Reference in New Issue
I don't think that should have been checked in
Why not? It's commented, so you can uncomment it to easily run the recipe locally. Same as all the other commented recipes.