]> gitweb.hamatoma.de Git - ansknife.git/commitdiff
postgres Korrekturen
authorHamatoma <author@hamatoma.de>
Wed, 14 May 2025 11:51:37 +0000 (13:51 +0200)
committerHamatoma <author@hamatoma.de>
Wed, 14 May 2025 11:51:37 +0000 (13:51 +0200)
playbooks.templates/pg_dbs.yaml [new file with mode: 0644]
playbooks.templates/pg_init.yaml
templates.vars/pg.yaml

diff --git a/playbooks.templates/pg_dbs.yaml b/playbooks.templates/pg_dbs.yaml
new file mode 100644 (file)
index 0000000..610caa5
--- /dev/null
@@ -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 }}"
index b7bed730f52f0177ce531b028138e9c8d297262d..072312fbbacd9e65c85162065b42df1b5f1f976c 100644 (file)
@@ -12,7 +12,7 @@
         state: present
     - name: install additional packages
       ansible.builtin.apt:
-        pkg: "{{ items }}"
+        pkg: "{{ item }}"
         state: present
       with_items: "{{ pg_additional_packages }}"
 
index 8bfb35f03cbc77ae745397d0de19a2fd7e6e5fd9..8ad54e5553e8d3e789ff1bf6dad20d905c272f0e 100644 (file)
@@ -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]