Compare commits
6 Commits
jammy_jell
...
0b2e3150aa
| Author | SHA1 | Date | |
|---|---|---|---|
|
0b2e3150aa
|
|||
|
b550fb3841
|
|||
|
adb160af2e
|
|||
|
0763574610
|
|||
|
ef413bdcf6
|
|||
|
c13a74e865
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -4,3 +4,9 @@
|
|||||||
[submodule "site-cookbooks/openresty"]
|
[submodule "site-cookbooks/openresty"]
|
||||||
path = site-cookbooks/openresty
|
path = site-cookbooks/openresty
|
||||||
url = https://github.com/67P/chef-openresty.git
|
url = https://github.com/67P/chef-openresty.git
|
||||||
|
[submodule "site-cookbooks/strfry"]
|
||||||
|
path = site-cookbooks/strfry
|
||||||
|
url = git@gitea.kosmos.org:kosmos/strfry-cookbook.git
|
||||||
|
[submodule "site-cookbooks/deno"]
|
||||||
|
path = site-cookbooks/deno
|
||||||
|
url = git@gitea.kosmos.org:kosmos/deno-cookbook.git
|
||||||
|
|||||||
@@ -101,6 +101,16 @@
|
|||||||
},
|
},
|
||||||
"sentry": {
|
"sentry": {
|
||||||
"allowed_ips": "10.1.1.0/24"
|
"allowed_ips": "10.1.1.0/24"
|
||||||
|
},
|
||||||
|
"strfry": {
|
||||||
|
"domain": "nostr.kosmos.org",
|
||||||
|
"real_ip_header": "x-real-ip",
|
||||||
|
"info": {
|
||||||
|
"name": "Kosmos Relay",
|
||||||
|
"description": "Members-only nostr relay for kosmos.org users",
|
||||||
|
"pubkey": "1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb",
|
||||||
|
"contact": "ops@kosmos.org"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
"kosmos_liquor-cabinet::nginx",
|
"kosmos_liquor-cabinet::nginx",
|
||||||
"kosmos_rsk::nginx_testnet",
|
"kosmos_rsk::nginx_testnet",
|
||||||
"kosmos_rsk::nginx_mainnet",
|
"kosmos_rsk::nginx_mainnet",
|
||||||
|
"kosmos_strfry::nginx",
|
||||||
"kosmos_website",
|
"kosmos_website",
|
||||||
"kosmos_website::default",
|
"kosmos_website::default",
|
||||||
"kosmos-akkounts::nginx",
|
"kosmos-akkounts::nginx",
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ production_run_list = %w(
|
|||||||
kosmos_liquor-cabinet::nginx
|
kosmos_liquor-cabinet::nginx
|
||||||
kosmos_rsk::nginx_testnet
|
kosmos_rsk::nginx_testnet
|
||||||
kosmos_rsk::nginx_mainnet
|
kosmos_rsk::nginx_mainnet
|
||||||
|
kosmos_strfry::nginx
|
||||||
kosmos_website::default
|
kosmos_website::default
|
||||||
kosmos-akkounts::nginx
|
kosmos-akkounts::nginx
|
||||||
kosmos-akkounts::nginx_api
|
kosmos-akkounts::nginx_api
|
||||||
|
|||||||
6
roles/strfry.rb
Normal file
6
roles/strfry.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
name "strfry"
|
||||||
|
|
||||||
|
run_list %w(
|
||||||
|
strfry::default
|
||||||
|
kosmos_strfry::firewall
|
||||||
|
)
|
||||||
1
site-cookbooks/deno
Submodule
1
site-cookbooks/deno
Submodule
Submodule site-cookbooks/deno added at 617f7959ab
@@ -1,9 +1,9 @@
|
|||||||
release = "20240514"
|
ubuntu_server_cloud_image_release = "20230506"
|
||||||
|
|
||||||
node.default["kosmos_kvm"]["host"]["qemu_base_image"] = {
|
node.default["kosmos_kvm"]["host"]["qemu_base_image"] = {
|
||||||
"url" => "https://cloud-images.ubuntu.com/releases/jammy/release-#{release}/ubuntu-22.04-server-cloudimg-amd64-disk-kvm.img",
|
"url" => "https://cloud-images.ubuntu.com/releases/focal/release-#{ubuntu_server_cloud_image_release}/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img",
|
||||||
"checksum" => "2e7698b3ebd7caead06b08bd3ece241e6ce294a6db01f92ea12bcb56d6972c3f",
|
"checksum" => "27d2b91fd2b715729d739e2a3155dce70d1aaae4f05c177f338b9d4b60be638c",
|
||||||
"path" => "/var/lib/libvirt/images/base/ubuntu-22.04-server-cloudimg-amd64-disk-kvm-#{release}.qcow2"
|
"path" => "/var/lib/libvirt/images/base/ubuntu-20.04-server-cloudimg-amd64-disk-kvm-#{ubuntu_server_cloud_image_release}.qcow2"
|
||||||
}
|
}
|
||||||
|
|
||||||
# A systemd.timer OnCalendar config value
|
# A systemd.timer OnCalendar config value
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ DISKSIZE=${4:-10} # 10GB default
|
|||||||
# Directory where image files will be stored
|
# Directory where image files will be stored
|
||||||
IMAGE_DIR=/var/lib/libvirt/images
|
IMAGE_DIR=/var/lib/libvirt/images
|
||||||
IMAGE_PATH=$IMAGE_DIR/${VMNAME}.qcow2
|
IMAGE_PATH=$IMAGE_DIR/${VMNAME}.qcow2
|
||||||
CIDATA_PATH=${IMAGE_DIR}/${VMNAME}-cloudinit
|
CIDATA_PATH=${IMAGE_DIR}/cidata-${VMNAME}.iso
|
||||||
BASE_FILE=<%= @base_image_path %>
|
BASE_FILE=<%= @base_image_path %>
|
||||||
|
|
||||||
# Create the VM image if it does not already exist
|
# Create the VM image if it does not already exist
|
||||||
@@ -38,8 +38,9 @@ qemu-img info "$IMAGE_PATH"
|
|||||||
# Check if the cloud-init metadata file exists
|
# Check if the cloud-init metadata file exists
|
||||||
# if not, generate it
|
# if not, generate it
|
||||||
if [ ! -r $CIDATA_PATH ]; then
|
if [ ! -r $CIDATA_PATH ]; then
|
||||||
mkdir -p $CIDATA_PATH
|
pushd $(dirname $CIDATA_PATH)
|
||||||
pushd $CIDATA_PATH
|
mkdir -p $VMNAME
|
||||||
|
cd $VMNAME
|
||||||
|
|
||||||
cat > user-data <<-EOS
|
cat > user-data <<-EOS
|
||||||
#cloud-config
|
#cloud-config
|
||||||
@@ -61,19 +62,25 @@ instance-id: $VMNAME
|
|||||||
local-hostname: $VMNAME
|
local-hostname: $VMNAME
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
|
genisoimage -output "$CIDATA_PATH" -volid cidata -joliet -rock user-data meta-data
|
||||||
|
chown libvirt-qemu:kvm "$CIDATA_PATH"
|
||||||
|
chmod 600 "$CIDATA_PATH"
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# setting --os-variant to ubuntu20.04 and ubuntu18.04 breaks SSH and networking
|
||||||
virt-install \
|
virt-install \
|
||||||
--name "$VMNAME" \
|
--name "$VMNAME" \
|
||||||
--ram "$RAM" \
|
--ram "$RAM" \
|
||||||
--vcpus "$CPUS" \
|
--vcpus "$CPUS" \
|
||||||
--cpu host \
|
--cpu host \
|
||||||
--arch x86_64 \
|
--arch x86_64 \
|
||||||
--osinfo detect=on,name=ubuntujammy \
|
--os-type linux \
|
||||||
|
--os-variant ubuntu16.04 \
|
||||||
--hvm \
|
--hvm \
|
||||||
--virt-type kvm \
|
--virt-type kvm \
|
||||||
--disk "$IMAGE_PATH" \
|
--disk "$IMAGE_PATH" \
|
||||||
|
--cdrom "$CIDATA_PATH" \
|
||||||
--boot hd \
|
--boot hd \
|
||||||
--network=bridge=virbr0,model=virtio \
|
--network=bridge=virbr0,model=virtio \
|
||||||
--graphics none \
|
--graphics none \
|
||||||
@@ -81,5 +88,4 @@ virt-install \
|
|||||||
--console pty \
|
--console pty \
|
||||||
--channel unix,mode=bind,path=/var/lib/libvirt/qemu/$VMNAME.guest_agent.0,target_type=virtio,name=org.qemu.guest_agent.0 \
|
--channel unix,mode=bind,path=/var/lib/libvirt/qemu/$VMNAME.guest_agent.0,target_type=virtio,name=org.qemu.guest_agent.0 \
|
||||||
--autostart \
|
--autostart \
|
||||||
--import \
|
--import
|
||||||
--cloud-init root-password-generate=off,disable=on,meta-data=$CIDATA_PATH/meta-data,user-data=$CIDATA_PATH/user-data
|
|
||||||
|
|||||||
20
site-cookbooks/kosmos_strfry/LICENSE
Normal file
20
site-cookbooks/kosmos_strfry/LICENSE
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
Copyright (c) 2024 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.
|
||||||
4
site-cookbooks/kosmos_strfry/README.md
Normal file
4
site-cookbooks/kosmos_strfry/README.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
kosmos_strfry
|
||||||
|
=============
|
||||||
|
|
||||||
|
Installs/configures a strfry relay and its reverse proxy config
|
||||||
9
site-cookbooks/kosmos_strfry/metadata.rb
Normal file
9
site-cookbooks/kosmos_strfry/metadata.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
name 'kosmos_strfry'
|
||||||
|
maintainer 'Kosmos'
|
||||||
|
maintainer_email 'mail@kosmos.org'
|
||||||
|
license 'MIT'
|
||||||
|
description 'strfry wrapper cookbook'
|
||||||
|
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||||
|
version '0.1.0'
|
||||||
|
|
||||||
|
depends 'kosmos_openresty'
|
||||||
13
site-cookbooks/kosmos_strfry/recipes/firewall.rb
Normal file
13
site-cookbooks/kosmos_strfry/recipes/firewall.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#
|
||||||
|
# Cookbook Name:: kosmos_strfry
|
||||||
|
# Recipe:: firewall
|
||||||
|
#
|
||||||
|
|
||||||
|
include_recipe "kosmos-base::firewall"
|
||||||
|
|
||||||
|
firewall_rule "strfry" do
|
||||||
|
port node["strfry"]["port"]
|
||||||
|
source "10.1.1.0/24"
|
||||||
|
protocol :tcp
|
||||||
|
command :allow
|
||||||
|
end
|
||||||
29
site-cookbooks/kosmos_strfry/recipes/nginx.rb
Normal file
29
site-cookbooks/kosmos_strfry/recipes/nginx.rb
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#
|
||||||
|
# Cookbook Name:: kosmos_strfry
|
||||||
|
# Recipe:: nginx
|
||||||
|
#
|
||||||
|
|
||||||
|
domain = node["strfry"]["domain"]
|
||||||
|
|
||||||
|
upstream_hosts = []
|
||||||
|
search(:node, 'role:strfry').each do |node|
|
||||||
|
upstream_hosts << node['knife_zero']['host']
|
||||||
|
end
|
||||||
|
if upstream_hosts.empty?
|
||||||
|
Chef::Log.warn("No node found with 'strfry' role. Not configuring nginx site.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
tls_cert_for domain do
|
||||||
|
auth "gandi_dns"
|
||||||
|
action :create
|
||||||
|
end
|
||||||
|
|
||||||
|
openresty_site domain do
|
||||||
|
template "nginx_conf_strfry.erb"
|
||||||
|
variables domain: domain,
|
||||||
|
upstream_port: node['strfry']['port'],
|
||||||
|
upstream_hosts: upstream_hosts,
|
||||||
|
ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
|
||||||
|
ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem"
|
||||||
|
end
|
||||||
28
site-cookbooks/kosmos_strfry/templates/nginx_conf_strfry.erb
Normal file
28
site-cookbooks/kosmos_strfry/templates/nginx_conf_strfry.erb
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
upstream _strfry {
|
||||||
|
<% @upstream_hosts.each do |host| %>
|
||||||
|
server <%= host %>:<%= @upstream_port || "7777" %>;
|
||||||
|
<% end %>
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||||
|
listen [::]:443 ssl http2;
|
||||||
|
server_name <%= @domain %>;
|
||||||
|
|
||||||
|
access_log "/var/log/nginx/<%= @domain %>.access.log";
|
||||||
|
error_log "/var/log/nginx/<%= @domain %>.error.log";
|
||||||
|
|
||||||
|
ssl_certificate <%= @ssl_cert %>;
|
||||||
|
ssl_certificate_key <%= @ssl_key %>;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto https;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_pass http://_strfry;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
}
|
||||||
|
}
|
||||||
1
site-cookbooks/strfry
Submodule
1
site-cookbooks/strfry
Submodule
Submodule site-cookbooks/strfry added at 65b6d65527
Reference in New Issue
Block a user