add check to see if key exists

This commit is contained in:
Souldiv 2023-10-19 11:23:27 -05:00
parent 52476f53d7
commit b281caf880
1 changed files with 7 additions and 0 deletions

View File

@ -1,13 +1,20 @@
---
- name: Check if key is present
stat:
path: /etc/apt/trusted.gpg.d/pgdg.asc
register: st_pgdg
- name: Add PostgreSQL APT repo
command: sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
become: true
when: not st_pgdg.stat.exists
- name: Import and Write gpg key to pgdg.asc
get_url:
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
dest: /etc/apt/trusted.gpg.d/pgdg.asc
become: true
when: not st_pgdg.stat.exists
- name: Update cache
apt: update_cache=yes state=latest