8000 Farm deploy stuff · postgrespro/postgres_cluster@a162e5a · GitHub
[go: up one dir, main page]

Skip to content

Commit a162e5a

Browse files
committed
Farm deploy stuff
1 parent 6a7f95e commit a162e5a

File tree

13 files changed

+106
-261
lines changed

13 files changed

+106
-261
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- hosts: master-workers
3+
roles:
4+
- role: postgrespro
5+
deploy_dtm: true
6+
7+
- hosts: workers
8+
roles:
9+
- role: postgrespro
10+
pg_port: 15432
11+
deploy_postgres: true
12+
pg_dtm_enable: true
13+
pg_dtm_host: "{{groups['master-workers'][0]}}"
14+

contrib/pg_dtm/tests/deploy_layouts/cluster_no_dtm.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- hosts: master-workers
3+
roles:
4+
- role: postgrespro
5+
deploy_postgres: true
6+
ppg_usedtm: false
7+
8+
- hosts: workers
9+
roles:
10+
- role: postgrespro
11+
deploy_postgres: true
12+
ppg_usedtm: false
13+

contrib/pg_dtm/tests/deploy_layouts/cluster_with_dtm.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

contrib/pg_dtm/tests/deploy_layouts/roles/postgrespro/tasks/dtm.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@
1515
- name: compile dtmd
1616
shell: make "LIBUV_PREFIX={{libuv.dst}}"
1717
args:
18-
chdir: "{{ppg.src}}/contrib/pg_dtm/dtmd"
19-
creates: "{{ppg.src}}/contrib/pg_dtm/dtmd/bin/dtmd"
18+
chdir: "{{pg_src}}/contrib/pg_dtm/dtmd"
19+
creates: "{{pg_src}}/contrib/pg_dtm/dtmd/bin/dtmd"
2020

2121
- name: install dtmd
22-
command: cp "{{ppg.src}}/contrib/pg_dtm/dtmd/bin/dtmd" "{{dtmd.dst}}"
22+
command: cp "{{pg_src}}/contrib/pg_dtm/dtmd/bin/dtmd" "{{dtmd.dst}}"
2323
args:
2424
creates: "{{dtmd.dst}}"
2525

2626
- name: ensure datadir for dtm exists
2727
file: dest={{dtmd.datadir}} state=directory
28+
29+
# FIXME: use dtmd'd pid file
30+
- name: kill dtmd
31+
shell: killall -q dtmd || true
2832

2933
- name: start dtm
30-
shell: nohup {{dtmd.dst}} -d {{dtmd.datadir}} -a 0.0.0.0 -p 5431 > dtmd.log &
34+
shell: nohup {{dtmd.dst}} -d {{dtmd.datadir}} -a 0.0.0.0 -p {{dtmd.port}} > {{dtmd.log}} &
3135

3236
- name: wait until dtm is available
3337
wait_for: port=5431 delay=1

contrib/pg_dtm/tests/deploy_layouts/roles/postgrespro/tasks/main.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- flex
1212
- libreadline-dev
1313
when: ansible_os_family == "Debian"
14+
sudo: yes
1415

1516
- name: ensure dependencies (RedHat)
1617
yum: name="@Development tools" state=present
@@ -34,20 +35,20 @@
3435

3536
- name: ensure we have checked out postgrespro (xtm)
3637
git: repo=git@gitlab.postgrespro.ru:pgpro-dev/postgrespro.git
37-
dest={{ppg.src}}
38-
version={{ppg.version}}
38+
dest={{pg_src}}
39+
version={{pg_version}}
3940
force=yes
4041
update=yes
4142
key_file=.ssh/ppg-deploy
4243
accept_hostkey=yes
4344
depth=1
44-
register: ppgsources
45+
register: pg_sources
4546

4647
- include: postgres.yml
4748
when: deploy_postgres
4849

4950
- include: dtm.yml
5051
when: deploy_dtm
5152

52-
# - include: pg_shard.yml
53-
# when: deploy_pg_shard == true
53+
- include: pg_shard.yml
54+
when: deploy_pg_shard

contrib/pg_dtm/tests/deploy_layouts/roles/postgrespro/tasks/postgres.yml

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,67 @@
11
- name: remove binaries if sources have changed
22
file: dest={{item}} state=absent
33
with_items:
4-
- "{{ppg.dst}}"
4+
- "{{pg_dst}}"
55
- "{{dtmd.dst}}"
6-
when: ppgsources.changed
6+
when: pg_sources.changed
77

88
- name: build postgrespro
9-
shell: ./configure --prefix={{ppg.dst}} --without-zlib && make clean && make -j {{makejobs}} && make install
9+
shell: ./configure --prefix={{pg_dst}} --without-zlib && make clean && make -j {{makejobs}} && make install
1010
args:
11-
chdir: "{{ppg.src}}"
12-
creates: "{{ppg.dst}}/bin/postgres"
11+
chdir: "{{pg_src}}"
12+
creates: "{{pg_dst}}/bin/postgres"
1313

1414
- name: build dtm extension
1515
shell: make clean && make && make install
1616
args:
17-
chdir: "{{ppg.src}}/contrib/pg_dtm"
18-
creates: "{{ppg.dst}}/lib/pg_dtm.so"
17+
chdir: "{{pg_src}}/contrib/pg_dtm"
18+
creates: "{{pg_dst}}/lib/pg_dtm.so"
1919

20-
- stat: path={{ppg.datadir}}/postmaster.pid
20+
- stat: path={{pg_datadir}}/postmaster.pid
2121
register: pg_pidfile
2222

23-
- name: stop postgres if running
24-
command: "{{ppg.dst}}/bin/pg_ctl stop -w -D {{ppg.datadir}}"
23+
- name: stop postgres if it was running
24+
command: "{{pg_dst}}/bin/pg_ctl stop -w -D {{pg_datadir}}"
2525
when: pg_pidfile.stat.exists
2626

2727
- name: remove datadirs on datanodes
28-
command: "rm -rf {{ppg.datadir}}"
28+
command: "rm -rf {{pg_datadir}}"
2929

3030
- name: create datadirs on datanodes
31-
command: "{{ppg.dst}}/bin/initdb {{ppg.datadir}}"
31+
command: "{{pg_dst}}/bin/initdb {{pg_datadir}}"
3232
args:
33-
creates: "{{ppg.datadir}}"
33+
creates: "{{pg_datadir}}"
3434

3535
- name: configure postgres on datanodes
3636
lineinfile:
37-
dest: "{{ppg.datadir}}/postgresql.conf"
38-
regexp: "{{item.regexp}}"
37+
dest: "{{pg_datadir}}/postgresql.conf"
3938
line: "{{item.line}}"
4039
state: present
41-
with_items: "{{ppg_configfile}}"
40+
with_items: "{{pg_config}}"
4241

4342
- name: enable dtm extension on datanodes
4443
lineinfile:
45-
dest: "{{ppg.datadir}}/postgresql.conf"
44+
dest: "{{pg_datadir}}/postgresql.conf"
4645
regexp: "{{item.regexp}}"
4746
line: "{{item.line}}"
4847
state: present
4948
with_items:
50-
- line: "dtm.host = '{{ppg_dtmhost}}'"
49+
- line: "dtm.host = '{{pg_dtm_host}}'"
5150
regexp: "^dtm.host "
5251
- line: "shared_preload_libraries = 'pg_dtm'"
5352
regexp: "^shared_preload_libraries "
54-
- line: "dtm.node_id = {{ppg.node_id}}"
55-
regexp: "^dtm.node_id "
56-
when: ppg.usedtm
57-
58-
- name: disable dtm extension on datanodes
59-
lineinfile:
60-
dest: "{{ppg.datadir}}/postgresql.conf"
61-
regexp: "{{item}}"
62-
state: absent
63-
with_items:
64-
- "^dtm.host "
65-
- "^shared_preload_libraries "
66-
when: not ppg_usedtm
53+
when: pg_dtm_enable
6754

6855
- name: enable blind trust on datanodes
6956
lineinfile:
70-
dest: "{{ppg.datadir}}/pg_hba.conf"
57+
dest: "{{pg_datadir}}/pg_hba.conf"
7158
line: "host all all 0.0.0.0/0 trust"
7259

7360
- include: pg_shard.yml
7461
when: deploy_pg_shard
7562

7663
- name: start postgrespro
77-
command: "{{ppg.dst}}/bin/pg_ctl start -w -D {{ppg.datadir}} -l {{ppg.log}}"
64+
command: "{{pg_dst}}/bin/pg_ctl start -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
7865

7966

8067

contrib/pg_dtm/tests/deploy_layouts/roles/postgrespro/vars/main.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1+
# vim: ts=2 sts=2 sw=2 expandtab
12
---
23
makejobs: 4
34

45
deploy_postgres: false
56
deploy_dtm: false
67
deploy_pg_shard: false
78

8-
ppg_usedtm: false
9-
ppg_dtmhost: "localhost"
10-
ppg_configfile:
11-
- line: "shared_buffers = 1024MB" # 1/4 RAM
12-
regexp: "^shared_buffers "
13-
14-
ppg:
15-
version: xtm
16-
src: ./postgrespro
17-
dst: "/tmp/postgrespro-build"
18-
log: ./ppg1.log
19-
datadir: ./postgrespro-data1
20-
usedtm: true
21-
node_id: 1
9+
pg_version: xtm
10+
pg_port: 5432
11+
pg_dtm_enable: false
12+
pg_dtm_host: "127.0.0.1"
13+
pg_config:
14+
- line: "shared_buffers = 3GB"
15+
- line: "wal_keep_segments = 128"
16+
- line: "fsync = off"
17+
- line: "autovacuum = off"
18+
- line: "listen_addresses = '*'"
19+
- line: "max_connections = 512"
20+
- line: "port = {{pg_port}}"
21+
pg_src: ./postgrespro
22+
pg_dst: /tmp/postgrespro-build
23+
pg_datadir: ./postgrespro-data
2224

2325
libuv:
2426
version: v1.7.5
2527
src: ./libuv
2628
dst: /tmp/libuv-build
2729

2830
dtmd:
31+
port: 5431
2932
dst: ./dtmd
3033
datadir: ./dtmd-data
3134
log: ./dtmd.log
3235

33-
34-
# vim: ts=2 sts=2 sw=2 expandtab

0 commit comments

Comments
 (0)
0