ansible-role-mailserver/tasks/db.yml

49 lines
1.0 KiB
YAML

- name: Workaround ansible switch between users
file:
path: "/tmp/ansible/"
mode: 0777
state: directory
- name: DB - Install PostgreSQL
package:
state: latest
name:
- postgresql
- python-psycopg2
- postgresql-old-upgrade
- postgis
- name: DB - Ensure a locale exists
locale_gen:
name: en_US.UTF-8
state: present
- name: DB - Init
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
- name: DB - starting
systemd:
name: postgresql
enabled: yes
state: started
- name: DB - create user
postgresql_user:
login_host: "{{ mailserver_db_host }}"
name: "{{ mailserver_db_user }}"
password: "{{ mailserver_db_password }}"
- name: DB - create database
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