Compare commits
2 commits
cd5b854b00
...
c37be21034
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c37be21034 | ||
![]() |
57079a0cbe |
3 changed files with 54 additions and 3 deletions
|
@ -1,5 +1,8 @@
|
||||||
from bundlewrap.utils.dicts import merge_dict
|
from bundlewrap.utils.dicts import merge_dict
|
||||||
|
|
||||||
|
|
||||||
|
version = node.metadata.get('postgresql/version')
|
||||||
|
|
||||||
directories = {
|
directories = {
|
||||||
'/var/lib/postgresql': {
|
'/var/lib/postgresql': {
|
||||||
'owner': 'postgres',
|
'owner': 'postgres',
|
||||||
|
@ -14,6 +17,22 @@ directories = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files = {
|
||||||
|
f"/etc/postgresql/{version}/main/conf.d/managed.conf": {
|
||||||
|
'content': '\n'.join(
|
||||||
|
f'{key} = {value}'
|
||||||
|
for key, value in sorted(node.metadata.get('postgresql/conf').items())
|
||||||
|
) + '\n',
|
||||||
|
'owner': 'postgres',
|
||||||
|
'group': 'postgres',
|
||||||
|
'needed_by': [
|
||||||
|
'svc_systemd:postgresql',
|
||||||
|
],
|
||||||
|
'triggers': [
|
||||||
|
'svc_systemd:postgresql:restart',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
svc_systemd['postgresql'] = {
|
svc_systemd['postgresql'] = {
|
||||||
'needs': [
|
'needs': [
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import builtins
|
||||||
|
|
||||||
|
|
||||||
root_password = repo.vault.password_for(f'{node.name} postgresql root')
|
root_password = repo.vault.password_for(f'{node.name} postgresql root')
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
|
@ -12,6 +15,7 @@ defaults = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'postgresql': {
|
'postgresql': {
|
||||||
|
'conf': {},
|
||||||
'roles': {
|
'roles': {
|
||||||
'root': {
|
'root': {
|
||||||
'password': root_password,
|
'password': root_password,
|
||||||
|
@ -24,6 +28,32 @@ defaults = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@metadata_reactor.provides(
|
||||||
|
'postgresql/conf',
|
||||||
|
)
|
||||||
|
def conf(metadata):
|
||||||
|
conf = {}
|
||||||
|
|
||||||
|
def limit(value, min=float('-inf'), max=float('inf'), unit=None):
|
||||||
|
result = int(builtins.max([builtins.min([max, value]), min]))
|
||||||
|
return str(result) + unit if unit else result
|
||||||
|
|
||||||
|
ram = metadata.get('vm/ram', None)
|
||||||
|
if ram:
|
||||||
|
conf['max_connections'] = limit(ram/50, min=100)
|
||||||
|
conf['shared_buffers'] = limit(ram/20, min=128, unit='MB')
|
||||||
|
conf['work_mem'] = limit(ram/500, min=4, max=64, unit='MB')
|
||||||
|
conf['temp_buffers'] = limit(ram/500, min=8, max=64, unit='MB')
|
||||||
|
conf['effective_cache_size'] = limit(ram/3, min=4096, unit='MB')
|
||||||
|
conf['maintenance_work_mem'] = limit(ram/50, min=64, unit='MB')
|
||||||
|
|
||||||
|
return {
|
||||||
|
'postgresql': {
|
||||||
|
'conf': conf,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@metadata_reactor.provides(
|
@metadata_reactor.provides(
|
||||||
'zfs/datasets',
|
'zfs/datasets',
|
||||||
)
|
)
|
||||||
|
|
|
@ -83,6 +83,7 @@
|
||||||
'nextcloud': {
|
'nextcloud': {
|
||||||
'hostname': 'cloud.sublimity.de',
|
'hostname': 'cloud.sublimity.de',
|
||||||
'version': '24.0.2',
|
'version': '24.0.2',
|
||||||
|
'instance_id': 'oci6dw1woodz',
|
||||||
},
|
},
|
||||||
'nextcloud-picsort': {
|
'nextcloud-picsort': {
|
||||||
'ckn': {
|
'ckn': {
|
||||||
|
@ -120,7 +121,8 @@
|
||||||
},
|
},
|
||||||
'vm': {
|
'vm': {
|
||||||
'cores': 16,
|
'cores': 16,
|
||||||
'ram': 32384,
|
'threads': 32,
|
||||||
|
'ram': 49152,
|
||||||
},
|
},
|
||||||
'wireguard': {
|
'wireguard': {
|
||||||
'my_ip': '172.30.0.2/32',
|
'my_ip': '172.30.0.2/32',
|
||||||
|
@ -135,7 +137,7 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'zfs': {
|
'zfs': {
|
||||||
'zfs_arc_max_percent': 75,
|
'zfs_arc_max_percent': 80,
|
||||||
'storage_classes': {
|
'storage_classes': {
|
||||||
'ssd': 'ssd',
|
'ssd': 'ssd',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue