added support to create users and dbs
This commit is contained in:
parent
c611a53558
commit
682cfa6259
3 changed files with 30 additions and 3 deletions
|
|
@ -1,6 +1,11 @@
|
|||
- name: install postgres
|
||||
apt:
|
||||
pkg: postgresql
|
||||
pkg: "{{ item }}"
|
||||
state: latest
|
||||
update_cache: yes
|
||||
with_items:
|
||||
- postgresql
|
||||
- python-psycopg2
|
||||
|
||||
- name: generate pg_hba
|
||||
template:
|
||||
|
|
@ -11,3 +16,18 @@
|
|||
mode: 0640
|
||||
notify:
|
||||
- restart postgres
|
||||
|
||||
- name: add postgresql dbs
|
||||
postgresql_db:
|
||||
name: "{{ item.key }}"
|
||||
become_user: postgres
|
||||
become: true
|
||||
with_dict: "{{ postgresql.dbs }}"
|
||||
|
||||
- name: add postgresql user(s)
|
||||
postgresql_user:
|
||||
name: "{{ item.key }}"
|
||||
password: "{{ item.value }}"
|
||||
become_user: postgres
|
||||
become: true
|
||||
with_dict: "{{ postgresql.users }}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue