WIP postgresql role

This commit is contained in:
strNophix 2022-03-14 11:33:22 +01:00
parent 6e55c7ef47
commit 400806fd29
2 changed files with 54 additions and 2 deletions
roles/postgresql
tasks
templates

@ -1,10 +1,60 @@
---
# tasks file for postgresql
- name: Install postgres
- name: Install package dependencies
package:
name:
- postgresql
- postgresql-contrib
- python3-pip
- acl
state: present
update_cache: yes
become: true
become: true
- name: Install `psycopg2` driver for postgresql
pip:
name: psycopg2-binary
state: present
become: true
- name: Update `listen_address` in `/etc/postgresql/12/main/postgresql.conf`
lineinfile:
path: /etc/postgresql/12/main/postgresql.conf
regexp: ^#listen_addresses = 'localhost'
line: listen_addresses='*'
become: true
# TODO: Copy over template `pg_hba.conf` to `/etc/postgresql/12/main/pg_hba.conf`
- name: Create new test-database
become_user: postgres
become: yes
community.postgresql.postgresql_db:
name: test
- name: Create table `test`.`message`
become_user: postgres
become: yes
community.postgresql.postgresql_table:
db: test
name: message
columns:
- id bigserial primary key
- content text
# TODO: Figure out what would be the correct `copy_from`
- name: Insert sample data into `test`.`message`
become_user: postgres
become: yes
community.postgresql.postgresql_copy:
copy_from: sample.csv
db: test
dst: message
columns: content
options:
format: csv
- name: Update password of postgres user
become_user: postgres
become: yes
community.postgresql.postgresql_user:
name: postgres
password: coolshit
- name: Restart postgresql service
service:
name: postgresql
state: restarted
enabled: yes

@ -0,0 +1,2 @@
hello
world
1 hello
2 world