use submodule for postgre role

This commit is contained in:
histausse 2022-03-07 20:39:37 +01:00
parent 80c27a774b
commit c35e4c309e
Signed by: histausse
GPG key ID: 67486F107F62E9E9
3 changed files with 4 additions and 67 deletions

3
.gitmodules vendored
View file

@ -7,3 +7,6 @@
[submodule "roles/matrix-bridge-signal"] [submodule "roles/matrix-bridge-signal"]
path = roles/matrix-bridge-signal path = roles/matrix-bridge-signal
url = ssh://git@gitea.auro.re:2222/Pains-Perdus/matrix-bridge-signal.git 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 Submodule

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

View file

@ -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') }}"