Merge branch 'master' into feature/462_akkounts_config

This commit is contained in:
Greg 2023-02-14 13:04:00 +00:00
commit 7549164a2e
16 changed files with 104 additions and 26 deletions

View File

@ -0,0 +1,10 @@
{
"id": "nbxplorer",
"postgresql_password": {
"encrypted_data": "FhJPANkxVT08Xf/8SJEj/lilgebkXA4hH4QfDsDb7DX/\n",
"iv": "zyK2uS4Gz9NOkJBB\n",
"auth_tag": "MsybhzFGaOSm66clfoHDsw==\n",
"version": 3,
"cipher": "aes-256-gcm"
}
}

View File

@ -22,6 +22,7 @@
"kosmos_postgresql::primary", "kosmos_postgresql::primary",
"kosmos_postgresql::firewall", "kosmos_postgresql::firewall",
"kosmos-bitcoin::lndhub-go_pg_db", "kosmos-bitcoin::lndhub-go_pg_db",
"kosmos-bitcoin::nbxplorer_pg_db",
"kosmos_drone::pg_db", "kosmos_drone::pg_db",
"kosmos_gitea::pg_db", "kosmos_gitea::pg_db",
"kosmos-mastodon::pg_db", "kosmos-mastodon::pg_db",

View File

@ -8,19 +8,19 @@
"automatic": { "automatic": {
"fqdn": "rsk-mainnet-2", "fqdn": "rsk-mainnet-2",
"os": "linux", "os": "linux",
"os_version": "5.4.0-1075-kvm", "os_version": "5.4.0-1084-kvm",
"hostname": "rsk-mainnet-2", "hostname": "rsk-mainnet-2",
"ipaddress": "192.168.122.208", "ipaddress": "192.168.122.208",
"roles": [ "roles": [
"rskj_mainnet", "kvm_guest",
"kvm_guest" "rskj_mainnet"
], ],
"recipes": [ "recipes": [
"kosmos-base", "kosmos-base",
"kosmos-base::default", "kosmos-base::default",
"kosmos_kvm::guest",
"kosmos_rsk::rskj", "kosmos_rsk::rskj",
"kosmos_rsk::nginx", "kosmos_rsk::nginx",
"kosmos_kvm::guest",
"apt::default", "apt::default",
"timezone_iii::default", "timezone_iii::default",
"timezone_iii::debian", "timezone_iii::debian",

View File

@ -8,19 +8,19 @@
"automatic": { "automatic": {
"fqdn": "rsk-testnet-3", "fqdn": "rsk-testnet-3",
"os": "linux", "os": "linux",
"os_version": "5.4.0-1075-kvm", "os_version": "5.4.0-1084-kvm",
"hostname": "rsk-testnet-3", "hostname": "rsk-testnet-3",
"ipaddress": "192.168.122.231", "ipaddress": "192.168.122.231",
"roles": [ "roles": [
"rskj_testnet", "kvm_guest",
"kvm_guest" "rskj_testnet"
], ],
"recipes": [ "recipes": [
"kosmos-base", "kosmos-base",
"kosmos-base::default", "kosmos-base::default",
"kosmos_kvm::guest",
"kosmos_rsk::rskj", "kosmos_rsk::rskj",
"kosmos_rsk::nginx", "kosmos_rsk::nginx",
"kosmos_kvm::guest",
"apt::default", "apt::default",
"timezone_iii::default", "timezone_iii::default",
"timezone_iii::debian", "timezone_iii::debian",

View File

@ -4,6 +4,7 @@ run_list %w(
kosmos_postgresql::primary kosmos_postgresql::primary
kosmos_postgresql::firewall kosmos_postgresql::firewall
kosmos-bitcoin::lndhub-go_pg_db kosmos-bitcoin::lndhub-go_pg_db
kosmos-bitcoin::nbxplorer_pg_db
kosmos_drone::pg_db kosmos_drone::pg_db
kosmos_gitea::pg_db kosmos_gitea::pg_db
kosmos-mastodon::pg_db kosmos-mastodon::pg_db

View File

@ -103,10 +103,12 @@ node.default['dotnet']['ms_packages_src_url'] = "https://packages.microsoft.com/
node.default['dotnet']['ms_packages_src_checksum'] = "4df5811c41fdded83eb9e2da9336a8dfa5594a79dc8a80133bd815f4f85b9991" node.default['dotnet']['ms_packages_src_checksum'] = "4df5811c41fdded83eb9e2da9336a8dfa5594a79dc8a80133bd815f4f85b9991"
node.default['nbxplorer']['repo'] = 'https://github.com/dgarage/NBXplorer' node.default['nbxplorer']['repo'] = 'https://github.com/dgarage/NBXplorer'
node.default['nbxplorer']['revision'] = 'v2.3.58' node.default['nbxplorer']['revision'] = 'v2.3.60'
node.default['nbxplorer']['source_dir'] = '/opt/nbxplorer' node.default['nbxplorer']['source_dir'] = '/opt/nbxplorer'
node.default['nbxplorer']['config_path'] = "/home/#{node['bitcoin']['username']}/.nbxplorer/Main/settings.config" node.default['nbxplorer']['config_path'] = "/home/#{node['bitcoin']['username']}/.nbxplorer/Main/settings.config"
node.default['nbxplorer']['port'] = '24445' node.default['nbxplorer']['port'] = '24445'
node.default['nbxplorer']['postgres']['database'] = 'nbxplorer'
node.default['nbxplorer']['postgres']['user'] = 'nbxplorer'
node.default['btcpay']['repo'] = 'https://github.com/btcpayserver/btcpayserver' node.default['btcpay']['repo'] = 'https://github.com/btcpayserver/btcpayserver'
node.default['btcpay']['revision'] = 'v1.7.5' node.default['btcpay']['revision'] = 'v1.7.5'

View File

@ -11,7 +11,7 @@ git node['btcpay']['source_dir'] do
repository node['btcpay']['repo'] repository node['btcpay']['repo']
revision node['btcpay']['revision'] revision node['btcpay']['revision']
action :sync action :sync
notifies :stop, "systemd_unit[btcpayserver.service]", :immediately notifies :stop, "service[btcpayserver]", :immediately
notifies :run, 'bash[build_btcpay]', :immediately notifies :run, 'bash[build_btcpay]', :immediately
end end
@ -22,7 +22,7 @@ bash 'build_btcpay' do
./build.sh ./build.sh
EOH EOH
action :nothing action :nothing
notifies :restart, "systemd_unit[btcpayserver.service]", :delayed notifies :restart, "service[btcpayserver]", :delayed
end end
directory "/home/#{node['bitcoin']['username']}/.btcpayserver" do directory "/home/#{node['bitcoin']['username']}/.btcpayserver" do
@ -58,7 +58,7 @@ template node['btcpay']['config_path'] do
postgres_user: node['btcpay']['postgres']['user'], postgres_user: node['btcpay']['postgres']['user'],
postgres_password: credentials['postgres_password'], postgres_password: credentials['postgres_password'],
lnd_admin_macaroon_path: lnd_admin_macaroon_path lnd_admin_macaroon_path: lnd_admin_macaroon_path
notifies :restart, "systemd_unit[btcpayserver.service]", :delayed notifies :restart, "service[btcpayserver]", :delayed
end end
directory '/run/btcpayserver' do directory '/run/btcpayserver' do
@ -67,6 +67,13 @@ directory '/run/btcpayserver' do
mode '0640' mode '0640'
end end
if node["nbxplorer"]["postgres"]
nbxplorer_credentials = Chef::EncryptedDataBagItem.load('credentials', 'nbxplorer')
nbxpg_user = node["nbxplorer"]["postgres"]["user"]
nbxpg_database = node["nbxplorer"]["postgres"]["database"]
nbxpg_connect = "User ID=#{nbxpg_user};Password=#{nbxplorer_credentials['postgresql_password']};Database=#{nbxpg_database};Host=pg.kosmos.local;Port=5432;Application Name=btcpayserver;MaxPoolSize=80"
end
systemd_unit 'btcpayserver.service' do systemd_unit 'btcpayserver.service' do
content({ content({
Unit: { Unit: {
@ -80,6 +87,7 @@ systemd_unit 'btcpayserver.service' do
Group: node['bitcoin']['usergroup'], Group: node['bitcoin']['usergroup'],
Type: 'simple', Type: 'simple',
WorkingDirectory: node['btcpay']['source_dir'], WorkingDirectory: node['btcpay']['source_dir'],
Environment: defined?(nbxpg_connect) ? "'BTCPAY_EXPLORERPOSTGRES=#{nbxpg_connect}'" : '',
ExecStart: "#{node['btcpay']['source_dir']}/run.sh --conf=#{node['btcpay']['config_path']}", ExecStart: "#{node['btcpay']['source_dir']}/run.sh --conf=#{node['btcpay']['config_path']}",
PIDFile: '/run/btcpayserver/btcpayserver.pid', PIDFile: '/run/btcpayserver/btcpayserver.pid',
Restart: 'on-failure', Restart: 'on-failure',
@ -94,7 +102,11 @@ systemd_unit 'btcpayserver.service' do
}) })
verify false verify false
triggers_reload true triggers_reload true
action [:create, :enable, :start] action [:create]
end
service "btcpayserver" do
action [:enable, :start]
end end
firewall_rule "BTCPay API private access" do firewall_rule "BTCPay API private access" do

View File

@ -7,11 +7,16 @@ build_essential
include_recipe "git" include_recipe "git"
credentials = Chef::EncryptedDataBagItem.load('credentials', 'nbxplorer')
bitcoin_credentials = Chef::EncryptedDataBagItem.load('credentials', 'bitcoin')
postgres_user = node["nbxplorer"]["postgres"]["user"]
postgres_database = node["nbxplorer"]["postgres"]["database"]
git node['nbxplorer']['source_dir'] do git node['nbxplorer']['source_dir'] do
repository node['nbxplorer']['repo'] repository node['nbxplorer']['repo']
revision node['nbxplorer']['revision'] revision node['nbxplorer']['revision']
action :sync action :sync
notifies :stop, "systemd_unit[nbxplorer.service]", :immediately notifies :stop, "service[nbxplorer]", :immediately
notifies :run, 'bash[build_nbxplorer]', :immediately notifies :run, 'bash[build_nbxplorer]', :immediately
end end
@ -21,8 +26,6 @@ bash 'build_nbxplorer' do
action :nothing action :nothing
end end
bitcoin_credentials = Chef::EncryptedDataBagItem.load('credentials', 'bitcoin')
directory "/home/#{node['bitcoin']['username']}/.nbxplorer" do directory "/home/#{node['bitcoin']['username']}/.nbxplorer" do
owner node['bitcoin']['username'] owner node['bitcoin']['username']
group node['bitcoin']['usergroup'] group node['bitcoin']['usergroup']
@ -54,6 +57,12 @@ directory '/run/nbxplorer' do
mode '0640' mode '0640'
end end
env = {
NBXPLORER_POSTGRES: "User ID=#{postgres_user};Password=#{credentials['postgresql_password']};Database=#{postgres_database};Host=pg.kosmos.local;Port=5432;Application Name=nbxplorer;MaxPoolSize=20",
NBXPLORER_AUTOMIGRATE: "1",
NBXPLORER_NOMIGRATEEVTS: "1"
}
systemd_unit 'nbxplorer.service' do systemd_unit 'nbxplorer.service' do
content({ content({
Unit: { Unit: {
@ -66,7 +75,9 @@ systemd_unit 'nbxplorer.service' do
User: node['bitcoin']['username'], User: node['bitcoin']['username'],
Group: node['bitcoin']['usergroup'], Group: node['bitcoin']['usergroup'],
Type: 'simple', Type: 'simple',
ExecStart: "/usr/bin/dotnet '#{node['nbxplorer']['source_dir']}/NBXplorer/bin/Release/netcoreapp3.1/NBXplorer.dll' -c #{node['nbxplorer']['config_path']} --noauth", WorkingDirectory: node['nbxplorer']['source_dir'],
Environment: env.map{|k, v| "'#{k}=#{v}'"}.join(' '),
ExecStart: "#{node['nbxplorer']['source_dir']}/run.sh -c #{node['nbxplorer']['config_path']} --noauth",
PIDFile: '/run/nbxplorer/nbxplorer.pid', PIDFile: '/run/nbxplorer/nbxplorer.pid',
Restart: 'on-failure', Restart: 'on-failure',
PrivateTmp: true, PrivateTmp: true,
@ -80,5 +91,9 @@ systemd_unit 'nbxplorer.service' do
}) })
verify false verify false
triggers_reload true triggers_reload true
action [:create, :enable, :start] action [:create]
end
service "nbxplorer" do
action [:enable, :start]
end end

View File

@ -0,0 +1,19 @@
#
# Cookbook Name:: kosmos-bitcoin
# Recipe:: nbxplorer-go_pg_db
#
credentials = data_bag_item('credentials', 'nbxplorer')
postgres_user = node['nbxplorer']['postgres']['user']
postgres_db = node['nbxplorer']['postgres']['database']
postgresql_user postgres_user do
action :create
password credentials['postgresql_password']
end
postgresql_database postgres_db do
owner postgres_user
action :create
end

View File

@ -1,3 +1,5 @@
source 'https://supermarket.chef.io' source 'https://supermarket.chef.io'
cookbook 'kosmos-nginx', path: '../../site-cookbooks/kosmos-nginx'
metadata metadata

View File

@ -2,6 +2,11 @@
This file is used to list changes made in each version of the kosmos_rsk cookbook. This file is used to list changes made in each version of the kosmos_rsk cookbook.
## 0.3.0
* Bump rskj version
* Fix tests
## 0.2.0 ## 0.2.0
Add nginx recipe to configure public API access. Add nginx recipe to configure public API access.

View File

@ -1,3 +1,14 @@
# kosmos_rsk # kosmos_rsk
Configures/deploys RSK-related software. Configures/deploys RSKj and related software.
## Testing
With a Docker daemon running:
```bash
kitchen create
kitchen converge
kitchen verify
kitchen destroy
```

View File

@ -1,2 +1,2 @@
node.default['rskj']['version'] = '4.1.0~focal' node.default['rskj']['version'] = '4.2.0~focal'
node.default['rskj']['network'] = 'testnet' node.default['rskj']['network'] = 'testnet'

View File

@ -2,8 +2,8 @@ name 'kosmos_rsk'
maintainer 'Kosmos Developers' maintainer 'Kosmos Developers'
maintainer_email 'ops@kosmos.org' maintainer_email 'ops@kosmos.org'
license 'MIT' license 'MIT'
description 'Installs/configures RSK and related software' description 'Installs/configures RSKj and related software'
version '0.2.0' version '0.3.0'
chef_version '>= 15.0' chef_version '>= 15.0'
issues_url 'https://gitea.kosmos.org/kosmos/chef/issues' issues_url 'https://gitea.kosmos.org/kosmos/chef/issues'
source_url 'https://gitea.kosmos.org/kosmos/chef' source_url 'https://gitea.kosmos.org/kosmos/chef'

View File

@ -1,6 +1,6 @@
#_preseed_V1 #_preseed_V1
# Do you agree to the terms of the applicable licenses? # Do you agree to the terms of the applicable licenses?
rskj shared/accepted-rsk-license-v1-1 boolean true rskj shared/accepted-rsk-license-v1-1 select true
# Choose a configuration environment to run your node. # Choose a configuration environment to run your node.
# Choices: mainnet, testnet, regtest # Choices: mainnet, testnet, regtest
rskj shared/config select <%= @network %> rskj shared/config select <%= @network %>

View File

@ -9,7 +9,7 @@ end
describe package('rskj') do describe package('rskj') do
it { should be_installed } it { should be_installed }
its('version') { should eq '2.2.0~focal' } its('version') { should eq '4.2.0~focal' }
end end
describe service('rsk') do describe service('rsk') do