From 91badd0e16fd9b94f5ecca0b33e873f261e748ca Mon Sep 17 00:00:00 2001 From: Souldiv Date: Wed, 11 Oct 2023 05:10:19 +0000 Subject: [PATCH 1/8] Modified tasks/setup-Debian.yml to include tasks for adding PostgreSQL apt repo and signing key --- tasks/setup-Debian.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index 1b540196..fbaee07f 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -1,4 +1,16 @@ --- +- 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' + +- name: Import the repository signing key + command: wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc + register: downloaded_key + +- name: Write gpg key to pgdg.asc + copy: + content: "{{ downloaded_key.stdout }}" + dest: /etc/apt/trusted.gpg.d/pgdg.asc + - name: Ensure PostgreSQL Python libraries are installed. apt: name: "{{ postgresql_python_library }}" From 7c09a4b9d1f75ec3c3c0065459a8baeff8a85722 Mon Sep 17 00:00:00 2001 From: Souldiv Date: Wed, 11 Oct 2023 05:24:07 +0000 Subject: [PATCH 2/8] update cache task for updating repo --- tasks/setup-Debian.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index fbaee07f..64430808 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -11,6 +11,9 @@ content: "{{ downloaded_key.stdout }}" dest: /etc/apt/trusted.gpg.d/pgdg.asc +- name: Update cache + apt: update_cache=yes state=latest + - name: Ensure PostgreSQL Python libraries are installed. apt: name: "{{ postgresql_python_library }}" From 81be8d995e3e16e3c8c6502cddc7e325ffc44cad Mon Sep 17 00:00:00 2001 From: Souldiv Date: Wed, 11 Oct 2023 05:41:04 +0000 Subject: [PATCH 3/8] attempt at fixing linting issues and refactored task for adding gpg key --- tasks/setup-Debian.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index 64430808..449556b0 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -2,17 +2,13 @@ - 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' -- name: Import the repository signing key - command: wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc - register: downloaded_key - -- name: Write gpg key to pgdg.asc - copy: - content: "{{ downloaded_key.stdout }}" +- 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 - name: Update cache - apt: update_cache=yes state=latest + apt: update_cache=yes state=latest - name: Ensure PostgreSQL Python libraries are installed. apt: From 2d1b00617e7712673be40a8867510ed477fa9c65 Mon Sep 17 00:00:00 2001 From: Souldiv Date: Wed, 11 Oct 2023 05:43:15 +0000 Subject: [PATCH 4/8] fixed trailing space --- tasks/setup-Debian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index 449556b0..a2240561 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -3,7 +3,7 @@ command: sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' - name: Import and Write gpg key to pgdg.asc - get_url: + get_url: url: https://www.postgresql.org/media/keys/ACCC4CF8.asc dest: /etc/apt/trusted.gpg.d/pgdg.asc From 52476f53d7ac9373e258a67ec29c4d9a84070f13 Mon Sep 17 00:00:00 2001 From: Souldiv Date: Wed, 11 Oct 2023 06:12:12 +0000 Subject: [PATCH 5/8] attempt at fixing CI issues --- tasks/setup-Debian.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index a2240561..39ec3e4d 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -1,14 +1,17 @@ --- - 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 - 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 - name: Update cache apt: update_cache=yes state=latest + become: true - name: Ensure PostgreSQL Python libraries are installed. apt: From b281caf8806ab4380505098967a521bce1dd480f Mon Sep 17 00:00:00 2001 From: Souldiv Date: Thu, 19 Oct 2023 11:23:27 -0500 Subject: [PATCH 6/8] add check to see if key exists --- tasks/setup-Debian.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index 39ec3e4d..da65b87e 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -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 From ab212d0a3dd1ec54496e22f042bbd8d6a892e7a5 Mon Sep 17 00:00:00 2001 From: Souldiv Date: Tue, 31 Oct 2023 13:28:38 -0500 Subject: [PATCH 7/8] refactor code to replace command module --- tasks/setup-Debian.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index da65b87e..44f5de41 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -1,20 +1,20 @@ --- -- name: Check if key is present +- name: Check if signing 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 + register: postgresql_st_pgdg - 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 + when: not postresql_st_pgdg.stat.exists + +- name: Add postgresql repository into sources list + ansible.builtin.apt_repository: + repo: "deb http://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main" + state: present - name: Update cache apt: update_cache=yes state=latest From c5c0866449d13e5eb856e19fa4d7bb5c59297239 Mon Sep 17 00:00:00 2001 From: Souldiv Date: Tue, 31 Oct 2023 13:32:03 -0500 Subject: [PATCH 8/8] typo fix --- tasks/setup-Debian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index 44f5de41..95dae534 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -9,7 +9,7 @@ url: https://www.postgresql.org/media/keys/ACCC4CF8.asc dest: /etc/apt/trusted.gpg.d/pgdg.asc become: true - when: not postresql_st_pgdg.stat.exists + when: not postgresql_st_pgdg.stat.exists - name: Add postgresql repository into sources list ansible.builtin.apt_repository: