|
342 | 342 | mode: 0700
|
343 | 343 | tags: patroni
|
344 | 344 |
|
| 345 | +- name: Prepare PostgreSQL | make sure the custom WAL directory "{{ postgresql_wal_dir }}" exists |
| 346 | + file: |
| 347 | + path: "{{ postgresql_wal_dir }}" |
| 348 | + owner: postgres |
| 349 | + group: postgres |
| 350 | + state: directory |
| 351 | + mode: 0700 |
| 352 | + when: postgresql_wal_dir is defined and postgresql_wal_dir | length > 0 |
| 353 | + tags: patroni, custom_wal_dir |
| 354 | + |
345 | 355 | - block: # when postgresql exists (master)
|
346 | 356 | - name: Prepare PostgreSQL | check that data directory "{{ postgresql_data_dir }}" is initialized on Master
|
347 | 357 | stat:
|
|
521 | 531 | postgresql_packages|join(" ") is not search("postgrespro")) and
|
522 | 532 | not postgresql_conf_file.stat.exists
|
523 | 533 |
|
524 |
| - - name: Prepare PostgreSQL | make sure the data directory "{{ postgresql_data_dir }}" is empty on Master |
| 534 | + - name: Prepare PostgreSQL | make sure the data directory "{{ postgresql_data_dir }}" is empty |
525 | 535 | file:
|
526 | 536 | path: "{{ postgresql_data_dir }}"
|
527 | 537 | state: "{{ item }}"
|
|
531 | 541 | loop:
|
532 | 542 | - absent
|
533 | 543 | - directory
|
534 |
| - when: is_master == "true" and |
| 544 | + when: patroni_cluster_bootstrap_method != "pgbackrest" # --delta restore |
| 545 | + |
| 546 | + - name: Prepare PostgreSQL | make sure the custom WAL directory "{{ postgresql_wal_dir }}" is empty |
| 547 | + file: |
| 548 | + path: "{{ postgresql_wal_dir }}" |
| 549 | + state: "{{ item }}" |
| 550 | + owner: postgres |
| 551 | + group: postgres |
| 552 | + mode: 0700 |
| 553 | + loop: |
| 554 | + - absent |
| 555 | + - directory |
| 556 | + when: (postgresql_wal_dir is defined and postgresql_wal_dir | length > 0) and |
535 | 557 | patroni_cluster_bootstrap_method != "pgbackrest" # --delta restore
|
536 | 558 | when: postgresql_exists != "true"
|
537 | 559 | tags: patroni, point_in_time_recovery
|
|
710 | 732 | group: postgres
|
711 | 733 | mode: 0640
|
712 | 734 | when: patroni_cluster_bootstrap_method != "initdb" and
|
| 735 | + postgresql_conf_dir != postgresql_data_dir and |
713 | 736 | (existing_pgcluster is not defined or not existing_pgcluster|bool)
|
714 | 737 | tags: patroni
|
715 | 738 |
|
|
752 | 775 | tags: patroni, patroni_start_master, point_in_time_recovery
|
753 | 776 |
|
754 | 777 | - block: # pg_hba (using a templates/pg_hba.conf.j2)
|
755 |
| - - name: Prepare PostgreSQL | generate pg_hba.conf |
| 778 | + - name: Prepare PostgreSQL | generate pg_hba.conf on Master |
756 | 779 | template:
|
757 | 780 | src: templates/pg_hba.conf.j2
|
758 | 781 | dest: "{{ postgresql_conf_dir }}/pg_hba.conf"
|
759 | 782 | owner: postgres
|
760 | 783 | group: postgres
|
761 | 784 | mode: 0640
|
| 785 | + when: is_master == "true" |
| 786 | + |
| 787 | + - name: Prepare PostgreSQL | generate pg_hba.conf on Replica |
| 788 | + template: |
| 789 | + src: templates/pg_hba.conf.j2 |
| 790 | + dest: "{{ postgresql_conf_dir }}/pg_hba.conf" |
| 791 | + owner: postgres |
| 792 | + group: postgres |
| 793 | + mode: 0640 |
| 794 | + when: is_master != "true" and |
| 795 | + postgresql_conf_dir != postgresql_data_dir |
762 | 796 |
|
763 | 797 | - name: Prepare PostgreSQL | reload for apply the pg_hba.conf
|
764 | 798 | become: true
|
|
837 | 871 | group: postgres
|
838 | 872 | mode: 0640
|
839 | 873 | when: existing_pgcluster is defined and existing_pgcluster|bool
|
| 874 | + and postgresql_conf_dir != postgresql_data_dir |
840 | 875 | tags: patroni, pg_hba, pg_hba_generate
|
841 | 876 |
|
842 | 877 | - block: # start patroni on replica
|
843 |
| - - name: Prepare PostgreSQL | make sure the data directory "{{ postgresql_data_dir }}" is empty on Replica |
844 |
| - file: |
845 |
| - path: "{{ postgresql_data_dir }}" |
846 |
| - state: "{{ item }}" |
847 |
| - owner: postgres |
848 |
| - group: postgres |
849 |
| - mode: 0700 |
850 |
| - loop: |
851 |
| - - absent |
852 |
| - - directory |
853 |
| - when: not 'pgbackrest' in patroni_create_replica_methods # --delta restore |
854 |
| - |
855 | 878 | - name: Start patroni service on Replica servers
|
856 | 879 | systemd:
|
857 | 880 | daemon_reload: true
|
|
879 | 902 | when: is_master != "true"
|
880 | 903 | tags: patroni, patroni_start_replica, point_in_time_recovery
|
881 | 904 |
|
| 905 | +# create symlink pg_xlog/pg_wal to custom WAL dir |
| 906 | +- import_tasks: custom_wal_dir.yml |
| 907 | + when: postgresql_wal_dir is defined and postgresql_wal_dir | length > 0 |
| 908 | + tags: patroni, custom_wal_dir |
| 909 | + |
882 | 910 | # disable postgresql from autostart
|
883 | 911 | - block: # "Debian"
|
884 | 912 | - name: Turning off postgresql autostart from config "start.conf" (will be managed by patroni)
|
|
0 commit comments