You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
# https://wiki.debian.org/PostgreSql
|
|
|
|
- name: Set up postgres
|
|
|
|
hosts: lotus-land-story
|
|
|
|
tasks:
|
|
|
|
|
|
|
|
- name: Install postgres
|
|
|
|
ansible.builtin.apt:
|
|
|
|
pkg:
|
|
|
|
- postgresql
|
|
|
|
- postgresql-client
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Make data directory
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: /mnt/lotus-land-story/postgresql
|
|
|
|
state: directory
|
|
|
|
owner: postgres
|
|
|
|
mode: "0700"
|
|
|
|
|
|
|
|
- name: Set data directory
|
|
|
|
ansible.builtin.lineinfile:
|
|
|
|
dest: "/etc/postgresql/13/main/postgresql.conf"
|
|
|
|
regexp: '^#?data_directory ='
|
|
|
|
line: "data_directory = '/mnt/lotus-land-story/postgresql'"
|
|
|
|
state: present
|
|
|
|
notify: Restart postgres
|
|
|
|
|
|
|
|
- name: Allow access from localhost
|
|
|
|
community.general.ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 5432
|
|
|
|
proto: tcp
|
|
|
|
from_ip: 127.0.0.1
|
|
|
|
notify: Reload ufw
|
|
|
|
|
|
|
|
- name: Allow access from docker
|
|
|
|
notify: Reload ufw
|
|
|
|
block:
|
|
|
|
|
|
|
|
- name: Get docker network
|
|
|
|
community.docker.docker_network:
|
|
|
|
name: lotus_land_story
|
|
|
|
register: docker_network
|
|
|
|
- name: Allow access from docker network
|
|
|
|
community.general.ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 5432
|
|
|
|
proto: tcp
|
|
|
|
from_ip: "{{ docker_network.network.IPAM.Config[0].Subnet }}"
|
|
|
|
notify: Reload ufw
|
|
|
|
|
|
|
|
handlers:
|
|
|
|
- name: Import restarts
|
|
|
|
ansible.builtin.import_tasks: restarts.yml
|
|
|
|
|
|
|
|
# vim: ft=yaml.ansible
|