Browse Source

use submodule for postgre role

master
histausse 7 months ago
parent
commit
c35e4c309e
Signed by: histausse
GPG Key ID: 67486F107F62E9E9
  1. 3
      .gitmodules
  2. 1
      roles/postgre
  3. 67
      roles/postgre/tasks/main.yml

3
.gitmodules vendored

@ -7,3 +7,6 @@
[submodule "roles/matrix-bridge-signal"]
path = roles/matrix-bridge-signal
url = ssh://git@gitea.auro.re:2222/Pains-Perdus/matrix-bridge-signal.git
[submodule "roles/postgre"]
path = roles/postgre
url = ssh://git@gitea.auro.re:2222/Pains-Perdus/postgre.git

1
roles/postgre

@ -0,0 +1 @@
Subproject commit e5ce16268f165be36d4f2f893caf47f9bdb6f332

67
roles/postgre/tasks/main.yml

@ -1,67 +0,0 @@
---
- name: Install postgre and usefull packages
apt:
update_cache: yes
name:
- acl # Don't ask me, required by postgresql_user
- postgresql
- postgresql-contrib
- libpq-dev
- python3-dev
- python3-psycopg2
- libpq5
state: latest
register: apt_result
retries: 3
until: apt_result is succeeded
- name: Enable and start PostgreSQL
systemd:
name: postgresql.service
state: started
enabled: yes
- name: Create users
become: true
become_user: postgres
postgresql_user:
name: "{{ item.name }}"
encrypted: yes
password: "{{ item.password }}"
loop: "{{ postgres_users }}"
no_log: true
- name: Create databases
become: true
become_user: postgres
postgresql_db:
name: "{{ item.name }}"
encoding: UTF-8
owner: "{{ item.owner | default(omit) }}"
lc_collate: "{{ item.local | default(omit) }}"
lc_ctype: "{{ item.local | default(omit) }}"
template: "{{ item.template | default(omit) }}"
loop: "{{ databases }}"
- name: Set encoding
become: true
become_user: postgres
postgresql_query:
query: "ALTER ROLE {{ item }} SET client_encoding TO 'utf8'"
loop: "{{ postgres_users | map(attribute='name') }}"
- name: Set encoding
become: true
become_user: postgres
postgresql_query:
query: "ALTER ROLE {{ item }} SET default_transaction_isolation TO 'read committed'"
when: item.read_committed | default(false)
loop: "{{ postgres_users | map(attribute='name') }}"
- name: Set timezone
become: true
become_user: postgres
postgresql_query:
query: "ALTER ROLE {{ item }} SET timezone TO 'CET'"
loop: "{{ postgres_users | map(attribute='name') }}"
Loading…
Cancel
Save