|
| 1 | +--- |
| 2 | + |
| 3 | +- hosts: all |
| 4 | + |
| 5 | + roles: |
| 6 | + - role: kelvich.postgres |
| 7 | + pg_port: 5432 |
| 8 | + pg_repo: https://github.com/postgrespro/postgres_cluster.git |
| 9 | + pg_version_tag: master |
| 10 | + pg_destroy_and_init: true |
| 11 | + pg_config_role: |
| 12 | + - line: "multimaster.buffer_size = 65536" |
| 13 | + |
| 14 | + tasks: |
| 15 | + - name: generate connstrings |
| 16 | + set_fact: |
| 17 | + connstr: "host={{item}} user={{ansible_ssh_user}} dbname=postgres" |
| 18 | + with_items: |
| 19 | + groups['all'] | reverse | batch(nnodes | d(3) | int) | first |
| 20 | + register: connstrs |
| 21 | + |
| 22 | + - name: make a list |
| 23 | + set_fact: |
| 24 | + connections: "{{ connstrs.results | map(attribute='ansible_facts.connstr') | join(', ') }}" |
| 25 | + |
| 26 | + - debug: var=hostvars |
| 27 | + |
| 28 | + - debug: var=inventory_hostname |
| 29 | + |
| 30 | + #- debug: var=hostvars[inventory_hostname] |
| 31 | + |
| 32 | + - name: build raftable |
| 33 | + shell: "make clean && make -j {{makejobs}} install" |
| 34 | + args: |
| 35 | + chdir: "{{pg_src}}/contrib/raftable" |
| 36 | + |
| 37 | + - name: build multimaster |
| 38 | + shell: "make clean && make -j {{makejobs}} install" |
| 39 | + args: |
| 40 | + chdir: "{{pg_src}}/contrib/mmts" |
| 41 | + |
| 42 | + - name: enable dtm extension on datanodes |
| 43 | + lineinfile: |
| 44 | + dest: "{{pg_datadir}}/postgresql.conf" |
| 45 | + line: "{{item}}" |
| 46 | + state: present |
| 47 | + with_items: |
| 48 | + - "wal_level = logical" |
| 49 | + - "max_wal_senders = 10" |
| 50 | + - "wal_sender_timeout = 0" |
| 51 | + - "max_replication_slots = 10" |
| 52 | + - "max_connections = 200" |
| 53 | + - "max_worker_processes = 100" |
| 54 | + - "shared_preload_libraries = 'raftable,multimaster'" |
| 55 | + - "multimaster.conn_strings = '{{connections}}'" |
| 56 | + - "multimaster.node_id = {{ inventory_hostname | regex_replace('([0-9]+)', '\\1') }}" |
| 57 | + - "multimaster.buffer_size = 65536" |
| 58 | + - "multimaster.queue_size = 1073741824" |
| 59 | + - "multimaster.arbiter_port = 5600" |
| 60 | + - "multimaster.vacuum_delay = 1" |
| 61 | + - "multimaster.workers = 32" |
| 62 | + - "multimaster.use_dtm = 1" |
| 63 | + |
| 64 | + - name: restart postgrespro |
| 65 | + command: "{{pg_dst}}/bin/pg_ctl restart -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log" |
| 66 | + environment: |
| 67 | + LD_LIBRARY_PATH: "{{pg_dst}}/lib/" |
| 68 | + |
0 commit comments