ansible-role-mailserver/tasks/db.yml

43 lines
955 B
YAML
Raw Normal View History

2020-07-22 23:20:10 +02:00
- name: DB - Install PostgreSQL
2020-07-21 02:29:22 +02:00
package:
2020-07-22 19:51:50 +02:00
state: latest
2020-07-21 02:29:22 +02:00
name:
- postgresql
2020-07-22 19:51:50 +02:00
- python-psycopg2
- postgresql-old-upgrade
- postgis
2020-07-22 16:06:30 +02:00
2020-07-22 23:20:10 +02:00
- name: DB - Ensure a locale exists
2020-07-22 19:51:50 +02:00
locale_gen:
name: en_US.UTF-8
state: present
2020-07-22 16:06:30 +02:00
2020-07-22 23:20:10 +02:00
- name: DB - Init
2020-07-22 19:51:50 +02:00
become: yes
become_user: postgres
become_method: su
command: initdb --locale=en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data
args:
creates: /var/lib/postgres/data/postgresql.conf
2020-07-22 16:06:30 +02:00
2020-07-22 23:20:10 +02:00
- name: DB - starting
2020-07-22 19:51:50 +02:00
systemd:
name: postgresql
enabled: yes
state: started
2020-07-22 23:20:10 +02:00
- name: DB - create user
2020-07-22 19:51:50 +02:00
postgresql_user:
login_host: "{{ mailserver_db_host }}"
name: "{{ mailserver_db_user }}"
password: "{{ mailserver_db_password }}"
2020-07-22 23:20:10 +02:00
- name: DB - create database
2020-07-22 19:51:50 +02:00
postgresql_db:
login_host: "{{ mailserver_db_host }}"
name: "{{ mailserver_db_name }}"
owner: "{{ mailserver_db_user }}"
encoding: UTF-8
lc_collate: en_US.UTF-8
lc_ctype: en_US.UTF-8