Skip to content

Commit a168fb9

Browse files
committed
install psycopg2 only once per db host
Signed-off-by: Anis FATHALLAH <anis@fathallah.fr>
1 parent e6bf483 commit a168fb9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

roles/deployment/databases/tasks/postgresql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
- name: Ensure psycopg2 is installed
1818
package:
19-
name: "{{ ((hostvars[databases[item].host]['ansible_os_family'] == 'RedHat') and (hostvars[databases[item].host]['ansible_distribution_major_version'] == '7')) | ternary('python-psycopg2', 'python3-psycopg2') }}"
20-
with_items: "{{ databases }}"
21-
delegate_to: "{{ databases[item].host }}"
19+
name: "{{ ((hostvars[item]['ansible_os_family'] == 'RedHat') and (hostvars[item]['ansible_distribution_major_version'] == '7')) | ternary('python-psycopg2', 'python3-psycopg2') }}"
20+
with_items: "{{ databases | json_query('*.host') | unique }}"
21+
delegate_to: "{{ item }}"
2222
connection: ssh
23-
when: databases[item].host in groups.db_server
23+
when: item in groups.db_server
2424

2525
- name: Create database roles
2626
postgresql_user:

0 commit comments

Comments
 (0)