Changeset View
Changeset View
Standalone View
Standalone View
winery-test-environment/rw.yml
- This file was added.
--- | |||||
- name: install and configure Read Write Storage | |||||
hosts: rw | |||||
become: true | |||||
pre_tasks: | |||||
- name: zap attached disks | |||||
shell: | | |||||
for disk in {{ rw_disk1 }} {{ rw_disk2 }} ; do | |||||
dd if=/dev/zero of=$disk count=100 bs=1024k | |||||
done | |||||
touch /etc/zapped.done | |||||
args: | |||||
creates: /etc/zapped.done | |||||
- name: apt install lvm2 | |||||
apt: | |||||
name: | |||||
- lvm2 | |||||
- name: vgcreate pg | |||||
lvg: | |||||
vg: pg | |||||
pvs: "{{ rw_disk1 }},{{ rw_disk2 }}" | |||||
- name: lvcreate pg | |||||
lvol: | |||||
vg: pg | |||||
lv: pg | |||||
size: +100%FREE | |||||
- name: mkfs /dev/mapper/pg-pg | |||||
filesystem: | |||||
fstype: ext4 | |||||
# force: yes | |||||
dev: /dev/mapper/pg-pg | |||||
- name: mkdir /var/lib/postgresql | |||||
file: | |||||
path: /var/lib/postgresql | |||||
state: directory | |||||
mode: 755 | |||||
- name: mount /var/lib/postgresql | |||||
mount: | |||||
path: /var/lib/postgresql | |||||
src: /dev/mapper/pg-pg | |||||
fstype: ext4 | |||||
state: mounted | |||||
- name: apt install postgres | |||||
apt: | |||||
name: | |||||
- postgresql | |||||
- postgresql-contrib | |||||
- libpq-dev | |||||
- python3-psycopg2 | |||||
- acl | |||||
- name: postgresql.conf max_connections = 1000 | |||||
lineinfile: | |||||
path: /etc/postgresql/13/main/postgresql.conf | |||||
regexp: '^max_connections' | |||||
line: "max_connections = 1000" | |||||
# | |||||
# https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server | |||||
# | |||||
- name: postgresql.conf shared_buffers | |||||
lineinfile: | |||||
path: /etc/postgresql/13/main/postgresql.conf | |||||
regexp: '^shared_buffers' | |||||
# 1/4 RAM | |||||
line: "shared_buffers = {{ postgres_shared_buffers }}" | |||||
- name: postgresql.conf effective_cache_size | |||||
lineinfile: | |||||
path: /etc/postgresql/13/main/postgresql.conf | |||||
regexp: '.*effective_cache_size' | |||||
# 1/2 RAM | |||||
line: "effective_cache_size = {{ postgres_effective_cache_size }}" | |||||
- name: postgresql.conf random_page_cost | |||||
lineinfile: | |||||
path: /etc/postgresql/13/main/postgresql.conf | |||||
regexp: '.*random_page_cost' | |||||
line: "random_page_cost = 2.0" | |||||
- name: listen on * | |||||
lineinfile: | |||||
path: /etc/postgresql/13/main/postgresql.conf | |||||
line: "listen_addresses = '*'" | |||||
- name: allow all connexions | |||||
lineinfile: | |||||
path: /etc/postgresql/13/main/pg_hba.conf | |||||
line: "host all all 0.0.0.0/0 trust" | |||||
- name: systemctl restart postgresql | |||||
service: | |||||
name: postgresql | |||||
state: restarted | |||||
- name: pg user testuser/testpassword | |||||
postgresql_user: | |||||
name: testuser | |||||
password: testpassword | |||||
role_attr_flags: SUPERUSER | |||||
become_user: postgres |