60 lines
1.5 KiB
YAML
60 lines
1.5 KiB
YAML
---
|
|
# tasks file for postgresql
|
|
- name: Install package dependencies
|
|
package:
|
|
name:
|
|
- postgresql
|
|
- postgresql-contrib
|
|
- python3-pip
|
|
- acl
|
|
state: present
|
|
update_cache: yes
|
|
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 |