WIP postgresql role
This commit is contained in:
parent
6e55c7ef47
commit
400806fd29
@ -1,10 +1,60 @@
|
|||||||
---
|
---
|
||||||
# tasks file for postgresql
|
# tasks file for postgresql
|
||||||
- name: Install postgres
|
- name: Install package dependencies
|
||||||
package:
|
package:
|
||||||
name:
|
name:
|
||||||
- postgresql
|
- postgresql
|
||||||
- postgresql-contrib
|
- postgresql-contrib
|
||||||
|
- python3-pip
|
||||||
|
- acl
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
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
|
2
roles/postgresql/templates/sample.csv
Normal file
2
roles/postgresql/templates/sample.csv
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
hello
|
||||||
|
world
|
|
Loading…
x
Reference in New Issue
Block a user