This commit is contained in:
dima 2024-11-18 23:52:42 +03:00
parent 293bf6d004
commit 3bf99fc8f0
8 changed files with 30 additions and 22 deletions

View File

@ -2,3 +2,4 @@
inventory = inventory.yml inventory = inventory.yml
roles_path = ./roles roles_path = ./roles
force_color = true force_color = true
interpreter_python = /usr/bin/python3

View File

@ -1,6 +1,4 @@
all: all:
children:
postgres_servers:
hosts: hosts:
192.168.0.71: 192.168.0.71:
ansible_user: ansible ansible_user: ansible

View File

@ -1,4 +1,4 @@
- name: Configure postgresql.conf with template - name: Configure postgresql.conf
template: template:
src: postgresql.conf.j2 src: postgresql.conf.j2
dest: /var/lib/pgsql/data/postgresql.conf dest: /var/lib/pgsql/data/postgresql.conf
@ -7,7 +7,7 @@
mode: '0644' mode: '0644'
notify: Restart PostgreSQL notify: Restart PostgreSQL
- name: Configure pg_hba.conf with template - name: Configure pg_hba.conf
template: template:
src: pg_hba.conf.j2 src: pg_hba.conf.j2
dest: /var/lib/pgsql/data/pg_hba.conf dest: /var/lib/pgsql/data/pg_hba.conf

View File

@ -5,7 +5,7 @@
encoding: UTF8 encoding: UTF8
state: present state: present
- name: Create contacts table in PostgreSQL - name: Create contacts table
community.postgresql.postgresql_query: community.postgresql.postgresql_query:
db: '{{ postgres_db }}' db: '{{ postgres_db }}'
query: | query: |

View File

@ -1,4 +1,4 @@
- name: Insert data into PostgreSQL database idempotently - name: Insert data into PostgreSQL database
community.postgresql.postgresql_query: community.postgresql.postgresql_query:
db: '{{ postgres_db }}' db: '{{ postgres_db }}'
query: | query: |

View File

@ -5,6 +5,8 @@
state: enabled state: enabled
become: true become: true
- name: Reload firewall using command - name: Reload firewalld
command: firewall-cmd --reload systemd:
name: firewalld
state: reloaded
become: true become: true

View File

@ -1,12 +1,11 @@
listen_addresses = '{{ postgres_listen_addresses | default("*") }}' listen_addresses = '{{ postgres_listen_addresses }}'
port = {{ postgres_port | default(5432) }} port = {{ postgres_port }}
max_connections = {{ postgres_max_connections }}
max_connections = {{ postgres_max_connections | default(100) }} shared_buffers = {{ postgres_shared_buffers }}
shared_buffers = {{ postgres_shared_buffers | default("128MB") }} effective_cache_size = {{ postgres_effective_cache_size }}
effective_cache_size = {{ postgres_effective_cache_size | default("4GB") }} maintenance_work_mem = {{ postgres_maintenance_work_mem }}
maintenance_work_mem = {{ postgres_maintenance_work_mem | default("64MB") }} checkpoint_completion_target = {{ postgres_checkpoint_completion_target }}
checkpoint_completion_target = {{ postgres_checkpoint_completion_target | default(0.7) }} wal_buffers = {{ postgres_wal_buffers }}
wal_buffers = {{ postgres_wal_buffers | default("16MB") }} default_statistics_target = {{ postgres_default_statistics_target }}
default_statistics_target = {{ postgres_default_statistics_target | default(100) }}

View File

@ -8,3 +8,11 @@ postgres_hba_entries:
backup_dir: "/var/backups/postgresql" backup_dir: "/var/backups/postgresql"
postgres_user: "postgres" postgres_user: "postgres"
postgres_db: "mydb" postgres_db: "mydb"
postgres_max_connections: 100
postgres_shared_buffers: '128MB'
postgres_effective_cache_size: '4GB'
postgres_maintenance_work_mem: '64MB'
postgres_checkpoint_completion_target: 0.7
postgres_wal_buffers: '16MB'
postgres_default_statistics_target: 100