|
| 1 | +--- |
| 2 | +# yamllint disable rule:line-length |
| 3 | + |
| 4 | +- block: # Debian pgdg repo |
| 5 | + - name: Make sure pgdg apt key is installed |
| 6 | + apt_key: |
| 7 | + id: ACCC4CF8 |
| 8 | + url: http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc |
| 9 | + |
| 10 | + - name: Make sure pgdg repository is installed |
| 11 | + apt_repository: |
| 12 | + repo: "deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main" |
| 13 | + |
| 14 | + - name: Update apt cache |
| 15 | + apt: |
| 16 | + update_cache: true |
| 17 | + environment: "{{ proxy_env | default({}) }}" |
| 18 | + when: |
| 19 | + - installation_method == "repo" |
| 20 | + - ansible_os_family == "Debian" |
| 21 | + - pgbackrest_install_from_pgdg_repo|bool |
| 22 | + tags: pgbackrest, pgbackrest_repo, pgbackrest_install |
| 23 | + |
| 24 | +- block: # RedHat pgdg repo |
| 25 | + - name: Get pgdg-redhat-repo-latest.noarch.rpm |
| 26 | + get_url: |
| 27 | + url: "https://download.postgresql.org/pub/repos/yum/reporpms/EL-{{ ansible_distribution_major_version }}-x86_64/pgdg-redhat-repo-latest.noarch.rpm" # noqa 204 |
| 28 | + dest: /tmp/ |
| 29 | + timeout: 30 |
| 30 | + validate_certs: false |
| 31 | + |
| 32 | + - name: Make sure pgdg repository is installed |
| 33 | + package: |
| 34 | + name: /tmp/pgdg-redhat-repo-latest.noarch.rpm |
| 35 | + state: present |
| 36 | + |
| 37 | + - name: Clean yum cache |
| 38 | + command: yum clean all |
| 39 | + args: |
| 40 | + warn: false |
| 41 | + when: ansible_distribution_major_version == '7' |
| 42 | + |
| 43 | + - name: Clean dnf cache |
| 44 | + command: dnf clean all |
| 45 | + args: |
| 46 | + warn: false |
| 47 | + when: ansible_distribution_major_version is version('8', '>=') |
| 48 | + environment: "{{ proxy_env | default({}) }}" |
| 49 | + when: |
| 50 | + - installation_method == "repo" |
| 51 | + - ansible_os_family == "RedHat" |
| 52 | + - pgbackrest_install_from_pgdg_repo|bool |
| 53 | + tags: pgbackrest, pgbackrest_repo, pgbackrest_install |
| 54 | + |
| 55 | +- name: Install pgbackrest |
| 56 | + package: |
| 57 | + name: pgbackrest |
| 58 | + state: latest |
| 59 | + tags: pgbackrest, pgbackrest_install |
| 60 | + |
| 61 | +- block: |
| 62 | + - name: Ensure config directory exist |
| 63 | + file: |
| 64 | + path: "{{ pgbackrest_conf_file | dirname }}" |
| 65 | + state: directory |
| 66 | + |
| 67 | + - name: "Generate conf file {{ pgbackrest_conf_file }}" |
| 68 | + template: |
| 69 | + src: pgbackrest.conf.j2 |
| 70 | + dest: "{{ pgbackrest_conf_file }}" |
| 71 | + owner: root |
| 72 | + group: root |
| 73 | + mode: 0644 |
| 74 | + when: "'postgres_cluster' in group_names" |
| 75 | + tags: pgbackrest, pgbackrest_conf |
| 76 | + |
| 77 | +# if pgbackrest_repo_type: "posix" and pgbackrest_repo_host is set |
| 78 | +- import_tasks: ssh_keys.yml |
| 79 | + when: |
| 80 | + - pgbackrest_repo_type|lower != "s3" |
| 81 | + - pgbackrest_repo_host is defined |
| 82 | + - pgbackrest_repo_host | length > 0 |
| 83 | + tags: pgbackrest, pgbackrest_ssh_keys |
| 84 | + |
| 85 | +- block: # if patroni_cluster_bootstrap_method: "pgbackrest" |
| 86 | + - name: Make sure the pgbackrest bootstrap script directory exist |
| 87 | + file: |
| 88 | + dest: /etc/patroni |
| 89 | + state: directory |
| 90 | + owner: postgres |
| 91 | + group: postgres |
| 92 | + |
| 93 | + - name: Create /etc/patroni/pgbackrest_bootstrap.sh script |
| 94 | + template: |
| 95 | + src: templates/pgbackrest_bootstrap.sh.j2 |
| 96 | + dest: /etc/patroni/pgbackrest_bootstrap.sh |
| 97 | + owner: postgres |
| 98 | + group: postgres |
| 99 | + mode: 0775 |
| 100 | + when: |
| 101 | + - patroni_cluster_bootstrap_method is defined |
| 102 | + - patroni_cluster_bootstrap_method == "pgbackrest" |
| 103 | + - "'postgres_cluster' in group_names" |
| 104 | + tags: pgbackrest, pgbackrest_bootstrap_script |
| 105 | + |
| 106 | +... |
0 commit comments