Add PostgreSQL server role
This commit is contained in:
parent
9aca035f2d
commit
c0be314268
@ -1,3 +1,6 @@
|
|||||||
[defaults]
|
[defaults]
|
||||||
inventory = ./environments/development
|
inventory = ./environments/development
|
||||||
interpreter_python = /usr/bin/python3
|
interpreter_python = /usr/bin/python3
|
||||||
|
|
||||||
|
[connection]
|
||||||
|
pipelining = true
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
- host_vars/proxy.yml
|
- host_vars/proxy.yml
|
||||||
roles:
|
roles:
|
||||||
- base
|
- base
|
||||||
|
- postgresql
|
||||||
- proxy
|
- proxy
|
||||||
- docker
|
- docker
|
||||||
- bitwarden
|
|
||||||
- gitea
|
- gitea
|
||||||
|
- bitwarden
|
||||||
|
1
roles/.gitignore
vendored
1
roles/.gitignore
vendored
@ -10,6 +10,7 @@
|
|||||||
!minecraft*/
|
!minecraft*/
|
||||||
!nextcloud*/
|
!nextcloud*/
|
||||||
!nginx*/
|
!nginx*/
|
||||||
|
!postgresql*/
|
||||||
!prometheus*/
|
!prometheus*/
|
||||||
!proxy*/
|
!proxy*/
|
||||||
!rsnapshot*/
|
!rsnapshot*/
|
||||||
|
@ -13,3 +13,10 @@
|
|||||||
loop:
|
loop:
|
||||||
- aptitude
|
- aptitude
|
||||||
- python3-docker
|
- python3-docker
|
||||||
|
- python3-psycopg2
|
||||||
|
|
||||||
|
- name: Create Ansible's temporary remote directory
|
||||||
|
file:
|
||||||
|
path: "~/.ansible/tmp"
|
||||||
|
state: directory
|
||||||
|
mode: 0700
|
||||||
|
2
roles/postgresql/defaults/main.yml
Normal file
2
roles/postgresql/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
postgresql_config: /etc/postgresql/13/main/pg_hba.conf
|
||||||
|
postgresql_listen: "*"
|
34
roles/postgresql/tasks/main.yml
Normal file
34
roles/postgresql/tasks/main.yml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
- name: Install PostgreSQL
|
||||||
|
apt:
|
||||||
|
name: postgresql
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Trust connections to PostgreSQL from Docker
|
||||||
|
postgresql_pg_hba:
|
||||||
|
dest: "{{ postgresql_config }}"
|
||||||
|
contype: host
|
||||||
|
databases: all
|
||||||
|
users: all
|
||||||
|
address: "172.16.0.0/12"
|
||||||
|
method: trust
|
||||||
|
register: postgresql_hba
|
||||||
|
|
||||||
|
- name: Change PostgreSQL listen addresses
|
||||||
|
postgresql_set:
|
||||||
|
name: listen_addresses
|
||||||
|
value: "{{ postgresql_listen }}"
|
||||||
|
become: true
|
||||||
|
become_user: postgres
|
||||||
|
register: postgresql_config
|
||||||
|
|
||||||
|
- name: Reload PostgreSQL
|
||||||
|
service:
|
||||||
|
name: postgresql
|
||||||
|
state: reloaded
|
||||||
|
when: postgresql_hba.changed and not postgresql_config.changed
|
||||||
|
|
||||||
|
- name: Restart PostgreSQL
|
||||||
|
service:
|
||||||
|
name: postgresql
|
||||||
|
state: restarted
|
||||||
|
when: postgresql_config.changed
|
Loading…
Reference in New Issue
Block a user