diff --git a/bundles/postgresql/items.py b/bundles/postgresql/items.py index 7b20dc3..ff24ccd 100644 --- a/bundles/postgresql/items.py +++ b/bundles/postgresql/items.py @@ -3,21 +3,43 @@ pkg_apt = { 'postgresql-client-11': {}, } +if node.has_bundle('zfs'): + pkg_apt['postgresql-11']['needs'] = { + 'zfs_dataset:tank/postgresql', + } + postgres_roles = { 'root': { 'password': repo.vault.password_for('{} postgresql root'.format(node.name)), 'superuser': True, + 'needs': { + 'svc_systemd:postgresql', + }, + }, +} + +svc_systemd = { + 'postgresql': { + 'needs': { + 'pkg_apt:postgresql-11', + }, }, } postgres_dbs = {} -for user, config in node.metadata['postgresql']['users'].items(): +for user, config in node.metadata.get('postgresql', {}).get('users', {}).items(): postgres_roles[user] = { 'password': config['password'], + 'needs': { + 'svc_systemd:postgresql', + }, } -for database, config in node.metadata['postgresql']['databases'].items(): +for database, config in node.metadata.get('postgresql', {}).get('databases', {}).items(): postgres_dbs[database] = { 'owner': config['owner'], + 'needs': { + 'svc_systemd:postgresql', + }, } diff --git a/bundles/postgresql/metadata.py b/bundles/postgresql/metadata.py new file mode 100644 index 0000000..c9e1cbc --- /dev/null +++ b/bundles/postgresql/metadata.py @@ -0,0 +1,10 @@ +defaults = {} + +if node.has_bundle('zfs'): + defaults['zfs'] = { + 'datasets': { + 'tank/postgresql': { + 'mountpoint': '/var/lib/postgresql', + }, + }, + }