Browse Source

add another custom postgres user and database for own small php scripts and stuff like that.

Thomas Buck 5 years ago
parent
commit
345e85490d
2 changed files with 23 additions and 0 deletions
  1. 4
    0
      roles/blog/defaults/main.yml
  2. 19
    0
      roles/blog/tasks/blog.yml

+ 4
- 0
roles/blog/defaults/main.yml View File

27
 commento_db_password: "{{ lookup('password', secret + '/' + 'commento_db_password length=32') }}"
27
 commento_db_password: "{{ lookup('password', secret + '/' + 'commento_db_password length=32') }}"
28
 commento_db_database: 'commento'
28
 commento_db_database: 'commento'
29
 
29
 
30
+custom_db_username: 'pageuser'
31
+custom_db_password: "{{ lookup('password', secret + '/' + 'custom_db_password length=32') }}"
32
+custom_db_database: 'page'
33
+
30
 # must match values in roles/common
34
 # must match values in roles/common
31
 db_admin_username: 'postgres'
35
 db_admin_username: 'postgres'
32
 db_admin_password: "{{ lookup('password', secret + '/' + 'db_admin_password length=32') }}"
36
 db_admin_password: "{{ lookup('password', secret + '/' + 'db_admin_password length=32') }}"

+ 19
- 0
roles/blog/tasks/blog.yml View File

25
     group=root
25
     group=root
26
   notify: restart apache
26
   notify: restart apache
27
 
27
 
28
+- name: Add custom postgres user
29
+  postgresql_user:
30
+    login_host=localhost
31
+    login_user={{ db_admin_username }}
32
+    login_password="{{ db_admin_password }}"
33
+    name={{ custom_db_username }}
34
+    password="{{ custom_db_password }}"
35
+    encrypted=yes
36
+    state=present
37
+
38
+- name: Create custom database
39
+  postgresql_db:
40
+    login_host=localhost
41
+    login_user={{ db_admin_username }}
42
+    login_password="{{ db_admin_password }}"
43
+    name={{ custom_db_database }}
44
+    state=present
45
+    owner={{ custom_db_username }}
46
+
28
 - name: Create an example blog index page
47
 - name: Create an example blog index page
29
   template:
48
   template:
30
     src=var_www_blog_index.j2
49
     src=var_www_blog_index.j2

Loading…
Cancel
Save