add extra user list and db creation task
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Robert Kaussow 2019-10-26 12:10:00 +02:00
parent bbfd07adf6
commit dcab833832
2 changed files with 42 additions and 2 deletions

View File

@ -5,7 +5,7 @@ postgres_repository_filename: "Postgresql-{{ postgres_version | regex_replace('\
postgres_user: postgres
postgres_group: postgres
# @var postgres_base_dir: $ "_os-default_"
# @var postgres_base_dir: $ "_osdefault_"
postgres_log_destination:
- stderr
@ -47,6 +47,27 @@ postgres_users: []
# pam_user: # defaults to not set
# @end
postgres_users_extra: []
postgres_db: []
# @var postgres_db:example: >
# postgres_db:
# - name: "my_app"
# lc_collate: "en_US.UTF-8"
# lc_ctype: "en_US.UTF-8"
# encoding: "UTF-8"
# template: "template0"
# login_host: "localhost"
# login_password: "_omit_"
# login_user: "{{ postgresql_user }}"
# login_unix_socket: "_omit_"
# port: "_omit_"
# owner: "_omit_"
# state: "present"
# @end
postgres_db_extra: []
postgres_hba_entries:
- contype: local
databases:

View File

@ -2,6 +2,25 @@
- name: Force all notified handlers to activate pg_hba.conf
meta: flush_handlers
- name: Ensure postgres databases exist
postgresql_db:
name: "{{ item.name }}"
lc_collate: "{{ item.lc_collate | default('en_US.UTF-8') }}"
lc_ctype: "{{ item.lc_ctype | default('en_US.UTF-8') }}"
encoding: "{{ item.encoding | default('UTF-8') }}"
template: "{{ item.template | default('template0') }}"
login_host: "{{ item.login_host | default('localhost') }}"
login_password: "{{ item.login_password | default(omit) }}"
login_user: "{{ item.login_user | default(postgresql_user) }}"
login_unix_socket: "{{ item.login_unix_socket | default(omit) }}"
port: "{{ item.port | default(omit) }}"
owner: "{{ item.owner | default(omit) }}"
state: "{{ item.state | default('present') }}"
no_log: True
loop: "{{ postgres_db + postgres_db_extra }}"
become: True
become_user: "{{ postgres_user }}"
- name: Ensure PostgreSQL users are present
postgresql_user:
name: "{{ item.name }}"
@ -17,7 +36,7 @@
port: "{{ item.port | default(omit) }}"
state: "{{ item.state | default('present') }}"
no_log: True
loop: "{{ postgres_users }}"
loop: "{{ postgres_users + postgres_users_extra }}"
become: True
become_user: "{{ postgres_user }}"