Move block data files to CIFS share
This is the vast majority of disk space used on the host currently.
This commit is contained in:
parent
458558fb26
commit
756382ec9f
@ -1,9 +1,30 @@
|
|||||||
{
|
{
|
||||||
"id": "bitcoin",
|
"id": "bitcoin",
|
||||||
"rpcpassword": {
|
"rpcpassword": {
|
||||||
"encrypted_data": "dBXJXEYJIoWzo+TPg8CzaKfTo94SdowFDdQKVL/njQ==\n",
|
"encrypted_data": "nxeli1CRJM0gdTM2VFjW16Ppf6L6YoE+OtpHfUahnA==\n",
|
||||||
"iv": "UNragm2xuewXZu0v\n",
|
"iv": "ZIlp+3rJEtkgphz/\n",
|
||||||
"auth_tag": "tfjO8qfvti3k5L3Ms2jPLw==\n",
|
"auth_tag": "+HJlC9VRedwCpUN69gwkJQ==\n",
|
||||||
|
"version": 3,
|
||||||
|
"cipher": "aes-256-gcm"
|
||||||
|
},
|
||||||
|
"blocksdir_cifs_share": {
|
||||||
|
"encrypted_data": "csJVGkvRoqbEqBnULyfvbf29vYWGKqJdCyV71x5No2otJdtKCl6JYDTQCkPc\nJ15f8PKLSgdyy22BmJvslg==\n",
|
||||||
|
"iv": "ov6OGMuAl6pVxXnj\n",
|
||||||
|
"auth_tag": "e+/RV87T1Wv/JgU9AQKMnQ==\n",
|
||||||
|
"version": 3,
|
||||||
|
"cipher": "aes-256-gcm"
|
||||||
|
},
|
||||||
|
"blocksdir_cifs_user": {
|
||||||
|
"encrypted_data": "cZhyF8q/cc9mlVBpNK84QnHslndXdR8SNXiImBkD3g==\n",
|
||||||
|
"iv": "E7FdytrPzEp8yjDW\n",
|
||||||
|
"auth_tag": "MluvP85h1dMHLlGE1SVApw==\n",
|
||||||
|
"version": 3,
|
||||||
|
"cipher": "aes-256-gcm"
|
||||||
|
},
|
||||||
|
"blocksdir_cifs_password": {
|
||||||
|
"encrypted_data": "MWuPvyIyBggWT9tM64OBg3QrFqfAIBUQH0HxEx1zujCcykg=\n",
|
||||||
|
"iv": "A7xdthaeDHAMBZrf\n",
|
||||||
|
"auth_tag": "vtbgB9WJ57sV74kTWeuVpg==\n",
|
||||||
"version": 3,
|
"version": 3,
|
||||||
"cipher": "aes-256-gcm"
|
"cipher": "aes-256-gcm"
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@
|
|||||||
"postfix::sasl_auth",
|
"postfix::sasl_auth",
|
||||||
"hostname::default",
|
"hostname::default",
|
||||||
"ark::default",
|
"ark::default",
|
||||||
|
"kosmos-bitcoin::user",
|
||||||
|
"kosmos-bitcoin::blocksdir-mount",
|
||||||
"kosmos-bitcoin::firewall",
|
"kosmos-bitcoin::firewall",
|
||||||
"git::default",
|
"git::default",
|
||||||
"git::package",
|
"git::package",
|
||||||
|
@ -6,6 +6,8 @@ node.default['bitcoin']['network'] = 'mainnet'
|
|||||||
node.default['bitcoin']['conf_path'] = '/home/satoshi/.bitcoin/bitcoin.conf'
|
node.default['bitcoin']['conf_path'] = '/home/satoshi/.bitcoin/bitcoin.conf'
|
||||||
node.default['bitcoin']['walletdir'] = '/home/satoshi/.bitcoin'
|
node.default['bitcoin']['walletdir'] = '/home/satoshi/.bitcoin'
|
||||||
node.default['bitcoin']['datadir'] = '/mnt/data/bitcoin'
|
node.default['bitcoin']['datadir'] = '/mnt/data/bitcoin'
|
||||||
|
node.default['bitcoin']['blocksdir'] = '/mnt/data/blocks'
|
||||||
|
node.default['bitcoin']['blocksdir_mount_type'] = 'cifs'
|
||||||
|
|
||||||
node.default['bitcoin']['conf'] = {
|
node.default['bitcoin']['conf'] = {
|
||||||
irc: 1,
|
irc: 1,
|
||||||
|
46
site-cookbooks/kosmos-bitcoin/recipes/blocksdir-mount.rb
Normal file
46
site-cookbooks/kosmos-bitcoin/recipes/blocksdir-mount.rb
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: kosmos-bitcoin
|
||||||
|
# Recipe:: blocksdir-mount
|
||||||
|
#
|
||||||
|
|
||||||
|
include_recipe 'kosmos-bitcoin::user'
|
||||||
|
|
||||||
|
bitcoin_user = node['bitcoin']['username']
|
||||||
|
bitcoin_group = node['bitcoin']['usergroup']
|
||||||
|
bitcoin_blocksdir = node['bitcoin']['blocksdir']
|
||||||
|
credentials = Chef::EncryptedDataBagItem.load('credentials', 'bitcoin')
|
||||||
|
|
||||||
|
directory bitcoin_blocksdir do
|
||||||
|
owner bitcoin_user
|
||||||
|
group bitcoin_group
|
||||||
|
mode '0750'
|
||||||
|
recursive true
|
||||||
|
action :create
|
||||||
|
end
|
||||||
|
|
||||||
|
case node["bitcoin"]["blocksdir_mount_type"]
|
||||||
|
when "cifs"
|
||||||
|
apt_package "cifs-utils"
|
||||||
|
|
||||||
|
systemd_unit "mnt-data-blocks.mount" do
|
||||||
|
content({
|
||||||
|
Unit: {
|
||||||
|
Description: 'Bitcoin Core blocks directory',
|
||||||
|
Requires: 'network-online.target',
|
||||||
|
After: 'network-online.service'
|
||||||
|
},
|
||||||
|
Mount: {
|
||||||
|
What: credentials["blocksdir_cifs_share"],
|
||||||
|
Where: bitcoin_blocksdir,
|
||||||
|
Type: 'cifs',
|
||||||
|
Options: "user=#{credentials["blocksdir_cifs_user"]},password=#{credentials["blocksdir_cifs_password"]},uid=#{bitcoin_user},gid=#{bitcoin_group},rw,vers=1.0"
|
||||||
|
},
|
||||||
|
Install: {
|
||||||
|
WantedBy: 'multi-user.target'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
verify false
|
||||||
|
triggers_reload true
|
||||||
|
action [:create, :enable, :start]
|
||||||
|
end
|
||||||
|
end
|
@ -3,7 +3,7 @@
|
|||||||
# Recipe:: source
|
# Recipe:: source
|
||||||
#
|
#
|
||||||
|
|
||||||
# TODO move to custom kosmos cookbook before publshing bitcoin cookbook
|
# TODO move to custom kosmos cookbook before publishing bitcoin cookbook
|
||||||
systemd_unit "mnt-data-bitcoin.mount" do
|
systemd_unit "mnt-data-bitcoin.mount" do
|
||||||
content({
|
content({
|
||||||
Unit: {
|
Unit: {
|
||||||
@ -27,6 +27,12 @@ end
|
|||||||
build_essential
|
build_essential
|
||||||
include_recipe 'ark'
|
include_recipe 'ark'
|
||||||
|
|
||||||
|
include_recipe 'kosmos-bitcoin::user'
|
||||||
|
|
||||||
|
if node["bitcoin"]["blocksdir_mount_type"]
|
||||||
|
include_recipe "kosmos-bitcoin::blocksdir-mount"
|
||||||
|
end
|
||||||
|
|
||||||
%w{ libtool autotools-dev make automake cmake curl g++-multilib libtool
|
%w{ libtool autotools-dev make automake cmake curl g++-multilib libtool
|
||||||
binutils-gold bsdmainutils pkg-config python3 patch }.each do |pkg|
|
binutils-gold bsdmainutils pkg-config python3 patch }.each do |pkg|
|
||||||
apt_package pkg
|
apt_package pkg
|
||||||
@ -72,15 +78,6 @@ bitcoin_walletdir = node['bitcoin']['walletdir']
|
|||||||
bitcoin_conf_path = node['bitcoin']['conf_path']
|
bitcoin_conf_path = node['bitcoin']['conf_path']
|
||||||
credentials = Chef::EncryptedDataBagItem.load('credentials', 'bitcoin')
|
credentials = Chef::EncryptedDataBagItem.load('credentials', 'bitcoin')
|
||||||
|
|
||||||
group bitcoin_group
|
|
||||||
|
|
||||||
user bitcoin_user do
|
|
||||||
manage_home true
|
|
||||||
uid 1006
|
|
||||||
gid bitcoin_group
|
|
||||||
shell "/bin/bash"
|
|
||||||
end
|
|
||||||
|
|
||||||
if node['bitcoin']['tor_enabled']
|
if node['bitcoin']['tor_enabled']
|
||||||
group 'debian-tor' do
|
group 'debian-tor' do
|
||||||
action :modify
|
action :modify
|
||||||
@ -99,6 +96,10 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if bitcoin_blocksdir = node["bitcoin"]["blocksdir"]
|
||||||
|
bitcoind_blocksdir_argument = "-blocksdir=#{bitcoin_blocksdir}"
|
||||||
|
end
|
||||||
|
|
||||||
bitcoin_config = node['bitcoin']['conf'].merge({
|
bitcoin_config = node['bitcoin']['conf'].merge({
|
||||||
rpcpassword: credentials["rpcpassword"]
|
rpcpassword: credentials["rpcpassword"]
|
||||||
})
|
})
|
||||||
@ -125,7 +126,7 @@ systemd_unit 'bitcoind.service' do
|
|||||||
Service: {
|
Service: {
|
||||||
User: bitcoin_user,
|
User: bitcoin_user,
|
||||||
Type: 'simple',
|
Type: 'simple',
|
||||||
ExecStart: "bitcoind -conf=#{bitcoin_conf_path} -datadir=#{bitcoin_datadir} -walletdir=#{bitcoin_walletdir} -pid=#{bitcoin_datadir}/bitcoind.pid",
|
ExecStart: "bitcoind -conf=#{bitcoin_conf_path} -datadir=#{bitcoin_datadir} #{bitcoind_blocksdir_argument} -walletdir=#{bitcoin_walletdir} -pid=#{bitcoin_datadir}/bitcoind.pid",
|
||||||
PIDFile: "#{bitcoin_datadir}/bitcoind.pid",
|
PIDFile: "#{bitcoin_datadir}/bitcoind.pid",
|
||||||
Restart: 'always',
|
Restart: 'always',
|
||||||
PrivateTmp: true,
|
PrivateTmp: true,
|
||||||
|
18
site-cookbooks/kosmos-bitcoin/recipes/user.rb
Normal file
18
site-cookbooks/kosmos-bitcoin/recipes/user.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# Cookbook:: kosmos-bitcoin
|
||||||
|
# Recipe:: user
|
||||||
|
#
|
||||||
|
|
||||||
|
include_recipe 'kosmos-bitcoin::user'
|
||||||
|
|
||||||
|
bitcoin_user = node['bitcoin']['username']
|
||||||
|
bitcoin_group = node['bitcoin']['usergroup']
|
||||||
|
|
||||||
|
group bitcoin_group
|
||||||
|
|
||||||
|
user bitcoin_user do
|
||||||
|
manage_home true
|
||||||
|
uid 1006
|
||||||
|
gid bitcoin_group
|
||||||
|
shell "/bin/bash"
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user