|
| 1 | +--- |
| 2 | + |
| 3 | +- name: Deploy PostgreSQL High-Availability Cluster (based on "Patroni" and "DCS(etcd)") |
| 4 | + hosts: postgres-cluster |
| 5 | + become: true |
| 6 | + become_method: sudo |
| 7 | + any_errors_fatal: true |
| 8 | + gather_facts: true |
| 9 | + vars_files: |
| 10 | + - vars/main.yml |
| 11 | + - "vars/{{ ansible_os_family }}.yml" |
| 12 | + |
| 13 | + |
| 14 | + pre_tasks: |
| 15 | + - import_tasks: tasks/check_system.yml |
| 16 | + |
| 17 | + - import_tasks: tasks/add-repository.yml |
| 18 | + tags: [ add_repo, configure ] |
| 19 | + |
| 20 | + - import_tasks: tasks/packages.yml |
| 21 | + tags: [ install_packages, install_postgres ] |
| 22 | + |
| 23 | + - import_tasks: tasks/sudo.yml |
| 24 | + tags: [ sudo, postgres_sudo, configure ] |
| 25 | + |
| 26 | + - import_tasks: tasks/configure.yml |
| 27 | + tags: configure |
| 28 | + |
| 29 | + roles: |
| 30 | + - role: ansible-role-firewall |
| 31 | + tags: firewall |
| 32 | + |
| 33 | + tasks: |
| 34 | + - meta: flush_handlers |
| 35 | + |
| 36 | + - import_tasks: tasks/etcd.yml |
| 37 | + when: dcs_exists == "false" and dcs_type == "etcd" |
| 38 | + tags: [ etcd, etcd_cluster ] |
| 39 | + |
| 40 | + - import_tasks: tasks/patroni.yml |
| 41 | + tags: patroni |
| 42 | + |
| 43 | + - import_tasks: tasks/pgbouncer.yml |
| 44 | + when: install_pgbouncer == "true" |
| 45 | + tags: pgbouncer |
| 46 | + |
| 47 | + - import_tasks: tasks/haproxy.yml |
| 48 | + when: with_haproxy_load_balancing == "true" and cluster_vip | length > 0 |
| 49 | + tags: [ haproxy, load_balancing ] |
| 50 | + |
| 51 | + - import_tasks: tasks/vip-manager.yml |
| 52 | + when: with_haproxy_load_balancing != "true" and cluster_vip | length > 0 |
| 53 | + tags: [ vip, vip_manager ] |
| 54 | + |
| 55 | + # optional |
| 56 | + - import_tasks: tasks/postgresql-users.yml |
| 57 | + when: is_master == "true" and postgresql_users | length > 0 |
| 58 | + tags: postgresql_users |
| 59 | + |
| 60 | + - import_tasks: tasks/postgresql-databases.yml |
| 61 | + when: is_master == "true" and postgresql_databases | length > 0 |
| 62 | + tags: postgresql_databases |
| 63 | + |
| 64 | + - import_tasks: tasks/postgresql-extensions.yml |
| 65 | + when: is_master == "true" and postgresql_extensions | length > 0 |
| 66 | + tags: postgresql_extensions |
| 67 | + |
| 68 | + # finish (info) |
| 69 | + - import_tasks: tasks/deploy_finish.yml |
| 70 | + tags: [ cluster_info, cluster_status ] |
| 71 | + |
| 72 | + |
| 73 | + |
0 commit comments