aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
authorThéophile Helleboid - chtitux <chtitux@gmail.com>2019-01-13 13:02:05 +0100
committerGitHub <noreply@github.com>2019-01-13 13:02:05 +0100
commit2bedf1bbf762903d955e4a76f674799a6acb2258 (patch)
tree5be007378ece2b320b541389377d429925644a20 /tasks
parent758d478b83050f248f5df8177027e2870f4308c5 (diff)
parentf1a9ab46fed919f445e3b2eacb90a594eb095fd1 (diff)
downloadansible-postgresql-role-2bedf1bbf762903d955e4a76f674799a6acb2258.tar.gz
ansible-postgresql-role-2bedf1bbf762903d955e4a76f674799a6acb2258.tar.zst
ansible-postgresql-role-2bedf1bbf762903d955e4a76f674799a6acb2258.zip
Merge pull request #4 from paulRbr/better-loop1.3.0
improvement: remove 'with_items' loop and use modern ansible loops
Diffstat (limited to 'tasks')
-rw-r--r--tasks/main.yml27
-rw-r--r--tasks/postgres-cluster.yml13
-rw-r--r--tasks/postgres-pgupgrades.yml13
3 files changed, 31 insertions, 22 deletions
diff --git a/tasks/main.yml b/tasks/main.yml
index ad6b5bb..2fa7883 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -20,17 +20,9 @@
20 when: (postgres_clusters is not defined) or (postgres_clusters|length == 0) 20 when: (postgres_clusters is not defined) or (postgres_clusters|length == 0)
21 21
22- include: postgres-cluster.yml 22- include: postgres-cluster.yml
23 postgres_version={{ item.version }} 23 loop: "{{ postgres_clusters }}"
24 postgres_cluster_name={{ item.name }} 24 loop_control:
25 postgres_port={{ item.port }} 25 loop_var: postgres_cluster
26 postgres_fsync_enabled={{ item.fsync_enabled }}
27 postgres_archive_enabled={{ item.archive_enabled }}
28 postgres_max_replication_slots={{ item.max_replication_slots | default(10) }}
29 postgres_extra_config={{ item.extra_config | default({}) }}
30 barman_directory={{ item.barman_directory | default(None) }}
31 postgres_primary={{ item.primary | default(None) }}
32 postgres_checksums={{ item.checksums | default(True) }}
33 with_items: "{{ postgres_clusters }}"
34 tags: 26 tags:
35 - postgres 27 - postgres
36 28
@@ -64,16 +56,9 @@
64 - postgres-databases 56 - postgres-databases
65 57
66- include: postgres-pgupgrades.yml 58- include: postgres-pgupgrades.yml
67 postgres_dbname={{ item.dbname }} 59 loop: "{{ postgres_pgupgrades }}"
68 postgres_pgbouncer_uri={{ item.pgbouncer_uri|default(None) }} 60 loop_control:
69 postgres_old_cluster_version={{ item.old_cluster_version }} 61 loop_var: postgres_pgupgrade
70 postgres_old_cluster_name={{ item.old_cluster_name }}
71 postgres_new_cluster_version={{ item.new_cluster_version }}
72 postgres_new_cluster_name={{ item.new_cluster_name }}
73 postgres_standby_server={{ item.standby_server }}
74 postgres_standby_old_cluster_name={{ item.standby_old_cluster_name|default(item.old_cluster_name) }}
75 postgres_standby_new_cluster_name={{ item.standby_new_cluster_name|default(item.new_cluster_name) }}
76 with_items: "{{ postgres_pgupgrades }}"
77 when: postgres_pgupgrades is defined 62 when: postgres_pgupgrades is defined
78 tags: 63 tags:
79 - postgres 64 - postgres
diff --git a/tasks/postgres-cluster.yml b/tasks/postgres-cluster.yml
index 769d119..c052982 100644
--- a/tasks/postgres-cluster.yml
+++ b/tasks/postgres-cluster.yml
@@ -1,3 +1,16 @@
1---
2- set_fact:
3 postgres_version: "{{ postgres_cluster.version }}"
4 postgres_cluster_name: "{{ postgres_cluster.name }}"
5 postgres_port: "{{ postgres_cluster.port }}"
6 postgres_fsync_enabled: "{{ postgres_cluster.fsync_enabled }}"
7 postgres_archive_enabled: "{{ postgres_cluster.archive_enabled }}"
8 postgres_max_replication_slots: "{{ postgres_cluster.max_replication_slots | default(10) }}"
9 postgres_extra_config: "{{ postgres_cluster.extra_config | default({}) }}"
10 barman_directory: "{{ postgres_cluster.barman_directory | default(None) }}"
11 postgres_primary: "{{ postgres_cluster.primary | default(None) }}"
12 postgres_checksums: "{{ postgres_cluster.checksums | default(True) }}"
13
1- name: Install postgresql version {{ postgres_version }} 14- name: Install postgresql version {{ postgres_version }}
2 apt: name=postgresql-{{ postgres_version }} 15 apt: name=postgresql-{{ postgres_version }}
3 when: ansible_distribution_release != 'NA' 16 when: ansible_distribution_release != 'NA'
diff --git a/tasks/postgres-pgupgrades.yml b/tasks/postgres-pgupgrades.yml
index a0b17b4..6eb9cb7 100644
--- a/tasks/postgres-pgupgrades.yml
+++ b/tasks/postgres-pgupgrades.yml
@@ -1,7 +1,18 @@
1--- 1---
2- set_fact:
3 postgres_dbname: "{{ postgres_pgupgrade.dbname }}"
4 postgres_pgbouncer_uri: "{{ postgres_pgupgrade.pgbouncer_uri|default(None) }}"
5 postgres_old_cluster_version: "{{ postgres_pgupgrade.old_cluster_version }}"
6 postgres_old_cluster_name: "{{ postgres_pgupgrade.old_cluster_name }}"
7 postgres_new_cluster_version: "{{ postgres_pgupgrade.new_cluster_version }}"
8 postgres_new_cluster_name: "{{ postgres_pgupgrade.new_cluster_name }}"
9 postgres_standby_server: "{{ postgres_pgupgrade.standby_server }}"
10 postgres_standby_old_cluster_name: "{{ postgres_pgupgrade.standby_old_cluster_name|default(postgres_pgupgrade.old_cluster_name) }}"
11 postgres_standby_new_cluster_name: "{{ postgres_pgupgrade.standby_new_cluster_name|default(postgres_pgupgrade.new_cluster_name) }}"
12
2- name: Find matching new cluster 13- name: Find matching new cluster
3 set_fact: 14 set_fact:
4 postgres_new_cluster: "{{ postgres_clusters|selectattr('name','equalto',postgres_new_cluster_name)|selectattr('version','equalto',postgres_new_cluster_version|float)|list|first }}" 15 postgres_new_cluster: "{{ postgres_clusters|selectattr('name','equalto',postgres_new_cluster_name)|selectattr('version','equalto', postgres_new_cluster_version|float)|list|first }}"
5 16
6- name: Extract database port of new matching cluster 17- name: Extract database port of new matching cluster
7 set_fact: 18 set_fact: