bundlewrap/bundles/postgresql/metadata.py

80 lines
2.2 KiB
Python
Raw Normal View History

2020-11-13 11:37:26 +00:00
defaults = {
'backups': {
'paths': {
'/var/lib/postgresql',
# FIXME
'/var/tmp/postgresdumps',
2020-11-13 11:37:26 +00:00
},
},
2021-02-20 09:56:20 +00:00
'bash_functions': {
'pg_query_mon': "watch -n 2 \"echo \\\"SELECT pid, age(clock_timestamp(), query_start), usename, query FROM pg_stat_activity WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' ORDER BY query_start desc;\\\" | psql postgres\""
},
2020-11-21 17:55:21 +00:00
'icinga2_api': {
2020-11-22 06:40:34 +00:00
'postgresql': {
2020-11-21 17:55:21 +00:00
'services': {
'POSTGRESQL PROCESS': {
'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C postgres -c 1:',
},
},
},
},
'postgresql': {
'max_connections': 100,
'autovacuum_max_workers': 3,
'maintenance_work_mem': 64,
'work_mem': 4,
'shared_buffers': 128,
'temp_buffers': 8,
'slow_query_log_sec': 0,
},
2020-11-13 11:37:26 +00:00
}
if node.has_bundle('zfs'):
defaults['zfs'] = {
'datasets': {
'tank/postgresql': {
'mountpoint': '/var/lib/postgresql',
},
},
}
# FIXME
#else:
# defaults['backups']['paths'].add('/var/tmp/postgresdumps')
@metadata_reactor.provides(
'apt/repos/postgresql',
'postgresql/version',
)
def default_postgresql_version_for_debian(metadata):
# <https://packages.debian.org/search?keywords=postgresql>
versions_in_debian = {
'10': '11', # buster
'11': '13', # bullseye
}
os = str(node.os_version[0])
version_to_be_installed = metadata.get('postgresql/version', versions_in_debian[os])
if version_to_be_installed != versions_in_debian[os]:
return {
'apt': {
'repos': {
'postgresql': {
'items': {
'deb https://apt.postgresql.org/pub/repos/apt/ {os_release}-pgdg main',
},
},
},
},
'postgresql': {
'version': version_to_be_installed,
},
}
2021-02-12 19:37:36 +00:00
return {
'postgresql': {
'version': version_to_be_installed,
},
}