51 lines
1.4 KiB
YAML
51 lines
1.4 KiB
YAML
---
|
|
- name: Installer PostgreSQL et les dependances Python
|
|
ansible.builtin.apt:
|
|
name:
|
|
- postgresql
|
|
- postgresql-client
|
|
- python3-psycopg2
|
|
state: present
|
|
|
|
- name: Activer PostgreSQL
|
|
ansible.builtin.service:
|
|
name: postgresql
|
|
state: started
|
|
enabled: true
|
|
|
|
- name: Creer l'utilisateur PostgreSQL applicatif
|
|
community.postgresql.postgresql_user:
|
|
name: "{{ groupe_meditation_db_user }}"
|
|
password: "{{ groupe_meditation_db_password }}"
|
|
role_attr_flags: LOGIN
|
|
state: present
|
|
become_user: postgres
|
|
|
|
- name: Creer la base PostgreSQL applicative
|
|
community.postgresql.postgresql_db:
|
|
name: "{{ groupe_meditation_db_name }}"
|
|
owner: "{{ groupe_meditation_db_user }}"
|
|
encoding: UTF8
|
|
state: present
|
|
become_user: postgres
|
|
|
|
- name: Donner les droits sur le schema public
|
|
community.postgresql.postgresql_privs:
|
|
db: "{{ groupe_meditation_db_name }}"
|
|
type: schema
|
|
objs: public
|
|
roles: "{{ groupe_meditation_db_user }}"
|
|
privs: ALL
|
|
state: present
|
|
become_user: postgres
|
|
|
|
- name: Verifier la connexion PostgreSQL TCP locale
|
|
community.postgresql.postgresql_query:
|
|
db: "{{ groupe_meditation_db_name }}"
|
|
login_user: "{{ groupe_meditation_db_user }}"
|
|
login_password: "{{ groupe_meditation_db_password }}"
|
|
login_host: "{{ groupe_meditation_db_host }}"
|
|
port: "{{ groupe_meditation_db_port }}"
|
|
query: SELECT 1;
|
|
no_log: true
|
|
|