From 5fc9d40c5a3b6df8a5b682986d32930030caface Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Wed, 14 May 2025 13:51:37 +0200 Subject: [PATCH] postgres Korrekturen --- playbooks.templates/pg_dbs.yaml | 30 ++++++++++++++++++++++++++++++ playbooks.templates/pg_init.yaml | 2 +- templates.vars/pg.yaml | 13 ++++++++++--- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 playbooks.templates/pg_dbs.yaml diff --git a/playbooks.templates/pg_dbs.yaml b/playbooks.templates/pg_dbs.yaml new file mode 100644 index 0000000..610caa5 --- /dev/null +++ b/playbooks.templates/pg_dbs.yaml @@ -0,0 +1,30 @@ +- name: Playbook to prepare the PosgreSQL databases + hosts: all + vars_files: + - ../vars/common.yaml + - ../vars/pg_vault.yaml + - ../vars/pg.yaml + tasks: + - name: Create primary groups + become: true + become_user: postgres + community.postgresql.postgresql_user: + name: "{{ item }}" + role_attr_flags: NOLOGIN + state: present + with_items: "{{ pg_databases }}" + - name: Create PostgreSQL database + become: true + become_user: postgres + community.postgresql.postgresql_db: + name: "{{ item }}" + state: present + with_items: "{{ pg_databases }}" + - name: Create POSTGIS extension + become: true + become_user: postgres + community.postgresql.postgresql_ext: + name: postgis + db: "{{ item }}" + state: present + with_items: "{{ pg_databases }}" diff --git a/playbooks.templates/pg_init.yaml b/playbooks.templates/pg_init.yaml index b7bed73..072312f 100644 --- a/playbooks.templates/pg_init.yaml +++ b/playbooks.templates/pg_init.yaml @@ -12,7 +12,7 @@ state: present - name: install additional packages ansible.builtin.apt: - pkg: "{{ items }}" + pkg: "{{ item }}" state: present with_items: "{{ pg_additional_packages }}" diff --git a/templates.vars/pg.yaml b/templates.vars/pg.yaml index 8bfb35f..8ad54e5 100644 --- a/templates.vars/pg.yaml +++ b/templates.vars/pg.yaml @@ -8,16 +8,23 @@ pg_additional_packages: - "postgresql-{{ pg_version }}-ogr-fdw" - "postgresql-{{ pg_version }}-mysql-fdw" -pg_databases: [] +pg_databases: + - pggreenlab + - pggrlabtest # Users with password: # If password is empty the password is not known pg_users: - jonny: '' + wk: '' + reinhard: '' + roman: '' # Groups are roles without login rights. # Key: name of the role Value: the list of group members # Convention: each database has a group with the same name pg_groups: - admins: [jonny] + admins: [wk, reinhard] + pgusers: [wk, reinhard, roman] + pggreenlab: [pgusers] + pggrlabtest: [pgusers] -- 2.39.5