Browse Source

setup posgres within the common role

Postgres is used by several roles, but the setup is currently part of the 'mailserver' role. By moving it to 'common', it's possible to disable the mailserver without breaking the others.
Wolfgang Steitz 7 years ago
parent
commit
3a42d15850
3 changed files with 16 additions and 11 deletions
  1. 1
    0
      roles/common/tasks/main.yml
  2. 15
    0
      roles/common/tasks/postgres.yml
  3. 0
    11
      roles/mailserver/tasks/postfix.yml

+ 1
- 0
roles/common/tasks/main.yml View File

68
 - include: security.yml tags=security
68
 - include: security.yml tags=security
69
 - include: ntp.yml tags=ntp
69
 - include: ntp.yml tags=ntp
70
 - include: google_auth.yml tags=google_auth
70
 - include: google_auth.yml tags=google_auth
71
+- include: postgres.yml

+ 15
- 0
roles/common/tasks/postgres.yml View File

1
+---
2
+# Defines tasks applicable for postgreSQL
3
+
4
+- name: Install Postgres
5
+  apt: pkg={{ item }} state=installed
6
+  with_items:
7
+    - postgresql
8
+    - python-psycopg2
9
+  tags:
10
+    - dependencies
11
+
12
+- name: Set password for PostgreSQL admin user
13
+  become: true
14
+  become_user: postgres
15
+  postgresql_user: name={{ db_admin_username }} password={{ db_admin_password }} encrypted=yes

+ 0
- 11
roles/mailserver/tasks/postfix.yml View File

1
-- name: Install Postgres
2
-  apt: pkg=postgresql state=present
3
-  tags:
4
-    - dependencies
5
-
6
 - name: Install Postfix and related packages
1
 - name: Install Postfix and related packages
7
   apt: pkg={{ item }} state=installed
2
   apt: pkg={{ item }} state=installed
8
   with_items:
3
   with_items:
16
   tags:
11
   tags:
17
     - dependencies
12
     - dependencies
18
 
13
 
19
-- name: Set password for PostgreSQL admin user
20
-  become: true
21
-  become_user: postgres
22
-  postgresql_user: name={{ db_admin_username }} password={{ db_admin_password }} encrypted=yes
23
-  notify: import sql postfix
24
-
25
 - name: Create database user for mail server
14
 - name: Create database user for mail server
26
   postgresql_user: login_host=localhost login_user={{ db_admin_username }} login_password="{{ db_admin_password }}" name={{ mail_db_username }} password="{{ mail_db_password }}" encrypted=yes state=present
15
   postgresql_user: login_host=localhost login_user={{ db_admin_username }} login_password="{{ db_admin_password }}" name={{ mail_db_username }} password="{{ mail_db_password }}" encrypted=yes state=present
27
   notify: import sql postfix
16
   notify: import sql postfix

Loading…
Cancel
Save