Merge pull request 'blog_dirty' (#8) from blog_dirty into master

Reviewed-on: #8
This commit is contained in:
cronekorkn 2023-04-20 11:10:04 +02:00
commit 534b7142a8
22 changed files with 99 additions and 54 deletions

4
.envrc
View file

@ -10,8 +10,8 @@ python3 -m venv .venv
source .venv/bin/activate
PATH_add .venv/bin
PATH_add bin
python3 -m pip install --upgrade pip wheel
python3 -m pip install --upgrade -r requirements.txt
python3 -m pip --require-virtualenv --quiet install --upgrade pip wheel
python3 -m pip --require-virtualenv --quiet install --upgrade -r requirements.txt
rm -rf .cache/bw/git_deploy
export BW_GIT_DEPLOY_CACHE=.cache/bw/git_deploy

View file

@ -68,7 +68,7 @@ for host, sources in hosts.items():
files[f'/etc/apt/sources.list.d/{host}.list'] = {
'content': '\n'.join(sorted(set(
str(source).format(
release=node.metadata.get('os_release'),
codename=node.metadata.get('os_codename'),
version=node.os_version[0], # WIP crystal
)
for source in sources
@ -95,7 +95,7 @@ for package, options in node.metadata.get('apt/packages', {}).items():
files[f'/etc/apt/preferences.d/{package}'] = {
'content': '\n'.join([
f"Package: {package}",
f"Pin: release a={node.metadata.get('os_release')}-backports",
f"Pin: release a={node.metadata.get('os_codename')}-backports",
f"Pin-Priority: 900",
]),
'needed_by': [

View file

@ -6,7 +6,7 @@ version = version=node.metadata.get('gitea/version')
downloads['/usr/local/bin/gitea'] = {
'url': f'https://dl.gitea.io/gitea/{version}/gitea-{version}-linux-amd64',
'sha256': node.metadata.get('gitea/sha256'),
'sha256_url': '{url}.sha256',
'triggers': {
'svc_systemd:gitea:restart',
},

View file

@ -30,8 +30,7 @@ defaults = {
'gitea.service': {
'Unit': {
'Description': 'gitea',
'After': 'syslog.target',
'After': 'network.target',
'After': {'syslog.target', 'network.target'},
'Requires': 'postgresql.service',
},
'Service': {

View file

@ -9,7 +9,7 @@ defaults = {
'monitoring-plugins': {},
},
'sources': {
'deb https://packages.icinga.com/debian icinga-{release} main',
'deb https://packages.icinga.com/debian icinga-{codename} main',
},
},
'icinga2': {

View file

@ -4,18 +4,27 @@ directories = {
'owner': 'www-data',
'group': 'icingaweb2',
'mode': '2770',
'needs': [
'pkg_apt:icingaweb2',
],
},
'/etc/icingaweb2/enabledModules': {
# 'purge': True,
'owner': 'www-data',
'group': 'icingaweb2',
'mode': '2770',
'needs': [
'pkg_apt:icingaweb2',
],
},
'/etc/icingaweb2/modules': {
# 'purge': True,
'owner': 'www-data',
'group': 'icingaweb2',
'mode': '2770',
'needs': [
'pkg_apt:icingaweb2',
],
},
}
@ -25,6 +34,9 @@ files = {
'owner': 'www-data',
'group': 'icingaweb2',
'mode': '0660',
'needs': [
'pkg_apt:icingaweb2',
],
},
}
@ -33,6 +45,9 @@ symlinks = {
'target': '/usr/share/icingaweb2/modules/monitoring',
'owner': 'www-data',
'group': 'icingaweb2',
'needs': [
'pkg_apt:icingaweb2',
],
},
}
@ -48,6 +63,9 @@ for name in [
'owner': 'www-data',
'group': 'icingaweb2',
'mode': '0660',
'needs': [
'pkg_apt:icingaweb2',
],
}
for name in [
@ -60,4 +78,7 @@ for name in [
'owner': 'www-data',
'group': 'icingaweb2',
'mode': '0660',
'needs': [
'pkg_apt:icingaweb2',
],
}

View file

@ -14,7 +14,7 @@ defaults = {
'icingaweb2-module-monitoring': {},
},
'sources': {
'deb https://packages.icinga.com/debian icinga-{release} main',
'deb https://packages.icinga.com/debian icinga-{codename} main',
},
},
'icingaweb2': {

View file

@ -7,7 +7,7 @@ defaults = {
'influxdb2-cli': {},
},
'sources': {
'deb https://repos.influxdata.com/debian {release} stable',
'deb https://repos.influxdata.com/debian {codename} stable',
},
},
'nftables': {

View file

@ -4,7 +4,7 @@ set -o pipefail
deploy_challenge() {
echo "
server 10.0.11.3
server ${server}
zone ${zone}.
update add $1.${zone}. 60 IN TXT \"$3\"
send
@ -13,7 +13,7 @@ deploy_challenge() {
clean_challenge() {
echo "
server 10.0.11.3
server ${server}
zone ${zone}.
update delete $1.${zone}. TXT
send

View file

@ -1,5 +1,4 @@
from shlex import quote
from ipaddress import ip_interface
defaults = {

View file

@ -23,8 +23,8 @@ def sources(metadata):
return {
'apt': {
'sources': {
f'deb https://deb.nodesource.com/node_{version}.x {{release}} main',
f'deb-src https://deb.nodesource.com/node_{version}.x {{release}} main',
f'deb https://deb.nodesource.com/node_{version}.x {{codename}} main',
f'deb-src https://deb.nodesource.com/node_{version}.x {{codename}} main',
},
},
}

View file

@ -15,16 +15,14 @@ defaults = {
def units(metadata):
units = {}
services = {}
for mountpoint, conf in metadata.get('systemd-mount').items():
formatted_name = mountpoint[1:].replace('-', '\\x2d').replace('/', '-') + '.mount'
units[formatted_name] = {
'Unit': {
'Description': f"Mount {conf['source']} -> {mountpoint}",
'DefaultDependencies': 'no',
'Conflicts': 'umount.target',
'Before': 'umount.target',
},
'Mount': {
'What': conf['source'],
@ -32,16 +30,11 @@ def units(metadata):
'Type': 'fuse.bindfs',
'Options': f"nonempty",
},
'Install': {
'WantedBy': {
'local-fs.target',
},
},
}
if conf.get('user'):
units[formatted_name]['Mount']['Options'] += f",force-user={conf.get('user')}"
services[formatted_name] = {}
return {

View file

@ -1,4 +1,4 @@
size_mb = node.metadata.get('systemd-swap')//1_000_000
size = node.metadata.get('systemd-swap')
actions = {
'stop_swap': {
@ -15,8 +15,8 @@ actions = {
},
},
'create_swapfile': {
'command': f'dd if=/dev/zero of=/swapfile bs=1000000 count={size_mb}',
'unless': f'stat -c %s /swapfile | grep ^{size_mb*1_000_000}$',
'command': f'fallocate -l {size} /swapfile',
'unless': f'stat -c %s /swapfile | grep ^{size}$',
'preceded_by': {
'action:stop_swap',
'action:remove_swapfile',

View file

@ -3,7 +3,7 @@
## show unit paths
```
systemctl --no-pager --property=UnitPath show | tr ' ' '\n'
systemctl --no-pager --property=UnitPath show --value | tr ' ' '\n'
```
## metadata

View file

@ -25,19 +25,14 @@ def units(metadata):
type = name.split('.')[-1]
if not config.get('Install/WantedBy'):
if type == 'service':
units[name] = {
'Install': {
'WantedBy': {'multi-user.target'},
}
}
elif type == 'timer':
units[name] = {
'Install': {
'WantedBy': {'timers.target'},
}
}
if type == 'service':
units.setdefault(name, {}).setdefault('Install', {}).setdefault('WantedBy', {'multi-user.target'})
elif type == 'timer':
units.setdefault(name, {}).setdefault('Install', {}).setdefault('WantedBy', {'timers.target'})
elif type == 'mount':
units.setdefault(name, {}).setdefault('Install', {}).setdefault('WantedBy', {'local-fs.target'})
units.setdefault(name, {}).setdefault('Unit', {}).setdefault('Conflicts', {'umount.target'})
units.setdefault(name, {}).setdefault('Unit', {}).setdefault('Before', {'umount.target'})
return {
'systemd': {

View file

@ -95,11 +95,11 @@ defaults = {
'apt/sources',
)
def apt(metadata):
release = {
codename = {
'buster': 'buster',
'bullseye': 'bullseye',
'bookworm': 'bullseye',
}[metadata.get('os_release')]
}[metadata.get('os_codename')]
return {
'apt': {
@ -107,7 +107,7 @@ def apt(metadata):
'telegraf': {},
},
'sources': {
f"deb https://repos.influxdata.com/debian {release} stable",
f"deb https://repos.influxdata.com/debian {codename} stable",
},
},
}

View file

@ -0,0 +1,7 @@
directories = {
'/var/lib/twitch-clips': {},
}
pkg_pip = {
'twitch-dl': {},
}

View file

@ -0,0 +1,28 @@
defaults = {
'backup': {
'paths': {
'/var/lib/twitch-clips',
},
},
'systemd-timers': {
f'twitch-clip-download': {
'command': '/usr/local/bin/twitch-dl clips cronekorkn_ --download --all',
'when': 'daily',
'persistent': True,
'working_dir': '/var/lib/twitch-clips',
'after': {
'network-online.target',
},
},
},
'zfs': {
'datasets': {
'tank/twitch-clips': {
'mountpoint': '/var/lib/twitch-clips',
'needed_by': {
'svc_systemd:twitch-clip-download.timer',
},
},
},
},
}

View file

@ -9,7 +9,7 @@
'postgresql': {
'version': '13',
},
'os_release': 'bullseye',
'os_codename': 'bullseye',
},
'os_version': (11,),
}

View file

@ -9,7 +9,7 @@
'postgresql': {
'version': '14',
},
'os_release': 'bookworm',
'os_codename': 'bookworm',
},
'os_version': (12,),
}

View file

@ -10,10 +10,10 @@
'metadata': {
'apt': {
'sources': {
'deb https://deb.debian.org/debian {release} main contrib non-free',
'deb https://deb.debian.org/debian {release}-updates main contrib non-free',
'deb https://deb.debian.org/debian {release}-backports main contrib non-free',
'deb https://security.debian.org/ {release}-security main contrib non-free',
'deb https://deb.debian.org/debian {codename} main contrib non-free',
'deb https://deb.debian.org/debian {codename}-updates main contrib non-free',
'deb https://deb.debian.org/debian {codename}-backports main contrib non-free',
'deb https://security.debian.org/ {codename}-security main contrib non-free',
},
'packages': {
'mtr-tiny': {},

View file

@ -30,6 +30,7 @@
'steam-chat-logger',
'steam-chat-viewer',
'systemd-swap',
'twitch-clip-download',
'raspberrymatic-cert',
'tasmota-charge',
'wireguard',
@ -60,8 +61,7 @@
'download_server': 'netcup.mails',
},
'gitea': {
'version': '1.17.1',
'sha256': 'eafd476ee2a303d758448314272add00898d045439ab0d353ff4286c5e63496f',
'version': '1.19.1',
'domain': 'git.sublimity.de',
'conf': {
'mailer': {
@ -153,6 +153,9 @@
'max': 70,
},
},
'twitch-clip-download': {
'channel_name': 'cronekorkn_',
},
'vm': {
'cores': 16,
'threads': 32,