Infrastructure/ansible/roles/postgresql-server/tasks/main.yml

40 lines
931 B
YAML
Raw Normal View History

2024-02-16 18:01:26 +02:00
---
- name: Install PostgreSQL and psycopg2
ansible.builtin.package:
name: "{{ install_packages[ansible_os_family] }}"
state: present
vars:
install_packages:
Debian:
- postgresql
- python3-psycopg2
RedHat:
- postgresql
- python3-psycopg2
Suse:
- postgresql
- python311-psycopg2
- name: Enable and start the PostgreSQL server
ansible.builtin.service:
name: postgresql.service
enabled: true
state: started
- name: Create a PostgreSQL user for root
become: true
become_user: postgres
community.postgresql.postgresql_user:
name: root
2024-02-17 11:00:06 +02:00
role_attr_flags: SUPERUSER
- name: Change listen addresses
community.postgresql.postgresql_set:
name: listen_addresses
value: "{{ postgresql.listen_addresses }}"
become: true
become_user: postgres
when: postgresql.listen_addresses is defined
notify: Restart PostgreSQL