Skip to content

Commit d35f3d1

Browse files
authored
Install PostgreSQL dependency (pyscopg2) if not present (#112)
* Install psycopg2 only once per db host Signed-off-by: Anis FATHALLAH <anis@fathallah.fr>
1 parent b2de462 commit d35f3d1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

roles/deployment/databases/tasks/postgresql.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414

1515
---
1616

17+
- name: Ensure psycopg2 is installed
18+
package:
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 }}"
22+
connection: ssh
23+
when: item in groups.db_server
24+
1725
- name: Create database roles
1826
postgresql_user:
1927
name: "{{ databases[item].user }}"

0 commit comments

Comments
 (0)