aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks/main.yml
blob: ad6b5bb1dba6499ceeab748bb8e99134f655ca15 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
- include: postgres-common-preinstall.yml
  tags:
    - postgres

- include: postgres-log-directory.yml
  tags:
    - postgres
  when:
   - postgres_log_dir is defined and postgres_log_dir

- include: postgres-data-directory.yml
  tags:
    - postgres
  when: postgres_data_dir is defined and postgres_data_dir

- name: fail if no clusters are defined
  fail:
    msg: "You probably forgot to define a PostgreSQL cluster on your host (`postgres_clusters` variable). Stopping run of the PostgreSQL role."
  when: (postgres_clusters is not defined) or (postgres_clusters|length == 0)

- include: postgres-cluster.yml
    postgres_version={{ item.version }}
    postgres_cluster_name={{ item.name }}
    postgres_port={{ item.port }}
    postgres_fsync_enabled={{ item.fsync_enabled }}
    postgres_archive_enabled={{ item.archive_enabled }}
    postgres_max_replication_slots={{ item.max_replication_slots | default(10) }}
    postgres_extra_config={{ item.extra_config | default({}) }}
    barman_directory={{ item.barman_directory | default(None) }}
    postgres_primary={{ item.primary | default(None) }}
    postgres_checksums={{ item.checksums | default(True) }}
  with_items: "{{ postgres_clusters }}"
  tags:
    - postgres

- include: postgres-common-postinstall.yml
  tags:
    - postgres

- include: postgres-user.yml
    postgres_username={{ item.1.username }}
    postgres_password={{ item.1.password }}
    postgres_port={{ item.0.port }}
    postgres_permissions={{ item.1.permissions | default('') }}
  with_subelements:
    - "{{ postgres_clusters }}"
    - users
    - skip_missing: true
  tags:
    - postgres
    - postgres-users

- include: postgres-database.yml
    postgres_dbname={{ item.1.dbname }}
    postgres_owner={{ item.1.owner }}
    postgres_port={{ item.0.port }}
  with_subelements:
    - "{{ postgres_clusters }}"
    - databases
    - skip_missing: true
  tags:
    - postgres
    - postgres-databases

- include: postgres-pgupgrades.yml
    postgres_dbname={{ item.dbname }}
    postgres_pgbouncer_uri={{ item.pgbouncer_uri|default(None) }}
    postgres_old_cluster_version={{ item.old_cluster_version }}
    postgres_old_cluster_name={{ item.old_cluster_name }}
    postgres_new_cluster_version={{ item.new_cluster_version }}
    postgres_new_cluster_name={{ item.new_cluster_name }}
    postgres_standby_server={{ item.standby_server }}
    postgres_standby_old_cluster_name={{ item.standby_old_cluster_name|default(item.old_cluster_name) }}
    postgres_standby_new_cluster_name={{ item.standby_new_cluster_name|default(item.new_cluster_name) }}
  with_items: "{{ postgres_pgupgrades }}"
  when: postgres_pgupgrades is defined
  tags:
    - postgres
    - postgres-pgupgrades