From 0cc659c14c17be6a381ea21113c1992321e7cbb4 Mon Sep 17 00:00:00 2001 From: Muhammad Aqeel Date: Wed, 28 Oct 2026 19:19:57 +0500 Subject: [PATCH 1/8] feat: install the repo client certificate for the gated pgEdge repositories --- .devcontainer/walkthrough/post-create.sh | 21 +++++++- lima/roles/deb_prerequisites/tasks/main.yaml | 47 +++++++++++++++++- lima/roles/rhel_prerequisites/tasks/main.yaml | 48 ++++++++++++++++++- 3 files changed, 112 insertions(+), 4 deletions(-) diff --git a/.devcontainer/walkthrough/post-create.sh b/.devcontainer/walkthrough/post-create.sh index ec887000..01fb56f7 100755 --- a/.devcontainer/walkthrough/post-create.sh +++ b/.devcontainer/walkthrough/post-create.sh @@ -3,11 +3,28 @@ set -euo pipefail echo "=== pgEdge Control Plane Walkthrough — Codespaces Setup ===" -# Add the pgEdge repository +# Add the pgEdge repository. downloads.pgedge.com, not apt.pgedge.com: the +# gated repository cannot serve the package that configures access to it. echo "Adding pgEdge apt repository..." -sudo curl -sSL https://apt.pgedge.com/repodeb/pgedge-release_latest_all.deb -o /tmp/pgedge-release.deb +sudo curl -sSL https://downloads.pgedge.com/repodeb/pgedge-release_latest_all.deb -o /tmp/pgedge-release.deb sudo dpkg -i /tmp/pgedge-release.deb +# The repository ships disabled and authenticates clients with mutual TLS. +# Supply PGEDGE_CLIENT_CERT and PGEDGE_CLIENT_KEY (PEM contents) to use it. +if [ -n "${PGEDGE_CLIENT_CERT:-}" ] && [ -n "${PGEDGE_CLIENT_KEY:-}" ]; then + echo "Installing the pgEdge client certificate..." + sudo install -d -m 0755 /etc/pgedge + printf '%s\n' "$PGEDGE_CLIENT_CERT" | sudo tee /etc/pgedge/client.crt >/dev/null + printf '%s\n' "$PGEDGE_CLIENT_KEY" | sudo tee /etc/pgedge/client.key >/dev/null + sudo chmod 0644 /etc/pgedge/client.crt + sudo chmod 0600 /etc/pgedge/client.key + sudo pgedge-subscription-manager install \ + /etc/pgedge/client.crt /etc/pgedge/client.key --force +else + echo "WARNING: PGEDGE_CLIENT_CERT / PGEDGE_CLIENT_KEY are not set." + echo " The pgEdge repository stays disabled and the install below will fail." +fi + # Install jq and the Postgres client echo "Installing jq and pgEdge Postgres client..." sudo apt-get update -qq diff --git a/lima/roles/deb_prerequisites/tasks/main.yaml b/lima/roles/deb_prerequisites/tasks/main.yaml index fa7290fd..c1c96a5c 100644 --- a/lima/roles/deb_prerequisites/tasks/main.yaml +++ b/lima/roles/deb_prerequisites/tasks/main.yaml @@ -15,9 +15,10 @@ - wget - git - chrony +# downloads.pgedge.com, not apt.pgedge.com -- see rhel_prerequisites. - name: Install pgEdge repository ansible.builtin.apt: - deb: https://apt.pgedge.com/repodeb/pgedge-release_latest_all.deb + deb: https://downloads.pgedge.com/repodeb/pgedge-release_latest_all.deb state: present - name: Reconfigure pgEdge repository for staging packages ansible.builtin.replace: @@ -37,6 +38,50 @@ ansible.builtin.apt: update_cache: yes changed_when: false +- name: Install the pgEdge client certificate and enable the repositories + when: pgedge_client_cert | default('') | length > 0 + and pgedge_client_key | default('') | length > 0 + block: + - name: Create the pgEdge configuration directory + ansible.builtin.file: + path: "/etc/pgedge" + state: directory + owner: root + group: root + mode: '0755' + - name: Write the client certificate + ansible.builtin.copy: + content: "{{ pgedge_client_cert | trim }}\n" + dest: "/etc/pgedge/client.crt" + owner: root + group: root + mode: '0644' + no_log: true + # Ownership and mode are left to pgedge-subscription-manager: apt reads the + # key as _apt, dnf as root. + - name: Write the client key + ansible.builtin.copy: + content: "{{ pgedge_client_key | trim }}\n" + dest: "/etc/pgedge/client.key" + owner: root + group: root + mode: '0600' + no_log: true + - name: Validate the certificate and enable the pgEdge repositories + ansible.builtin.command: >- + pgedge-subscription-manager install + /etc/pgedge/client.crt /etc/pgedge/client.key --force + changed_when: true + +- name: Warn when no pgEdge client certificate was supplied + ansible.builtin.debug: + msg: >- + No pgEdge client certificate supplied: the repositories stay disabled and + pgEdge packages will not install. Set pgedge_client_cert and + pgedge_client_key. + when: not (pgedge_client_cert | default('') | length > 0 + and pgedge_client_key | default('') | length > 0) + - name: Track configured Spock major for reinstall detection ansible.builtin.copy: content: "{{ spock_major | default('50') }}" diff --git a/lima/roles/rhel_prerequisites/tasks/main.yaml b/lima/roles/rhel_prerequisites/tasks/main.yaml index 2bbf32d0..9d4e65ff 100644 --- a/lima/roles/rhel_prerequisites/tasks/main.yaml +++ b/lima/roles/rhel_prerequisites/tasks/main.yaml @@ -13,9 +13,11 @@ community.general.dnf_config_manager: name: crb state: enabled +# downloads.pgedge.com, not dnf.pgedge.com: the gated repository cannot serve +# the package that configures access to it. - name: Install pgEdge repository ansible.builtin.package: - name: https://dnf.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm + name: https://downloads.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm state: present disable_gpg_check: true - name: Reconfigure pgEdge repository for staging packages @@ -32,6 +34,50 @@ replace: release when: not (use_staging_packages | bool) register: repo_reconfigured_to_release +- name: Install the pgEdge client certificate and enable the repositories + when: pgedge_client_cert | default('') | length > 0 + and pgedge_client_key | default('') | length > 0 + block: + - name: Create the pgEdge configuration directory + ansible.builtin.file: + path: "/etc/pki/pgedge" + state: directory + owner: root + group: root + mode: '0755' + - name: Write the client certificate + ansible.builtin.copy: + content: "{{ pgedge_client_cert | trim }}\n" + dest: "/etc/pki/pgedge/client.crt" + owner: root + group: root + mode: '0644' + no_log: true + # Ownership and mode are left to pgedge-subscription-manager: apt reads the + # key as _apt, dnf as root. + - name: Write the client key + ansible.builtin.copy: + content: "{{ pgedge_client_key | trim }}\n" + dest: "/etc/pki/pgedge/client.key" + owner: root + group: root + mode: '0600' + no_log: true + - name: Validate the certificate and enable the pgEdge repositories + ansible.builtin.command: >- + pgedge-subscription-manager install + /etc/pki/pgedge/client.crt /etc/pki/pgedge/client.key --force + changed_when: true + +- name: Warn when no pgEdge client certificate was supplied + ansible.builtin.debug: + msg: >- + No pgEdge client certificate supplied: the repositories stay disabled and + pgEdge packages will not install. Set pgedge_client_cert and + pgedge_client_key. + when: not (pgedge_client_cert | default('') | length > 0 + and pgedge_client_key | default('') | length > 0) + - name: Track configured Spock major for reinstall detection ansible.builtin.copy: content: "{{ spock_major | default('50') }}" From 2ab7ae7db1c1c26a984e94127193efce0cf29dc8 Mon Sep 17 00:00:00 2001 From: Muhammad Aqeel Date: Wed, 28 Oct 2026 20:22:18 +0500 Subject: [PATCH 2/8] fix: install the client certificate before any repository access and retire release_old --- .devcontainer/walkthrough/post-create.sh | 6 ++++-- docs/walkthrough.md | 8 ++++++++ lima/roles/deb_prerequisites/tasks/main.yaml | 15 ++++++++------- .../templates/pgedge-old.sources.tmpl | 5 ----- lima/roles/rhel_prerequisites/tasks/main.yaml | 6 +++--- lima/vars.yaml | 8 ++++++++ 6 files changed, 31 insertions(+), 17 deletions(-) delete mode 100644 lima/roles/deb_prerequisites/templates/pgedge-old.sources.tmpl diff --git a/.devcontainer/walkthrough/post-create.sh b/.devcontainer/walkthrough/post-create.sh index 01fb56f7..ae9e7390 100755 --- a/.devcontainer/walkthrough/post-create.sh +++ b/.devcontainer/walkthrough/post-create.sh @@ -14,10 +14,12 @@ sudo dpkg -i /tmp/pgedge-release.deb if [ -n "${PGEDGE_CLIENT_CERT:-}" ] && [ -n "${PGEDGE_CLIENT_KEY:-}" ]; then echo "Installing the pgEdge client certificate..." sudo install -d -m 0755 /etc/pgedge + # Create the key empty at 0600 first: writing it and then chmod'ing would + # leave it world-readable for the interval in between. + sudo install -m 0600 /dev/null /etc/pgedge/client.key + sudo install -m 0644 /dev/null /etc/pgedge/client.crt printf '%s\n' "$PGEDGE_CLIENT_CERT" | sudo tee /etc/pgedge/client.crt >/dev/null printf '%s\n' "$PGEDGE_CLIENT_KEY" | sudo tee /etc/pgedge/client.key >/dev/null - sudo chmod 0644 /etc/pgedge/client.crt - sudo chmod 0600 /etc/pgedge/client.key sudo pgedge-subscription-manager install \ /etc/pgedge/client.crt /etc/pgedge/client.key --force else diff --git a/docs/walkthrough.md b/docs/walkthrough.md index fe3a4b0e..8f1df47e 100644 --- a/docs/walkthrough.md +++ b/docs/walkthrough.md @@ -25,6 +25,14 @@ with three nodes, each accepting reads and writes. > [Runme extension](https://marketplace.visualstudio.com/items?itemName=stateful.runme) > in VS Code and click **Execute Cell** on each block. +> [!IMPORTANT] +> **The pgEdge package repository needs a client certificate** +> Before creating the Codespace, add two Codespaces secrets for this +> repository, `PGEDGE_CLIENT_CERT` and `PGEDGE_CLIENT_KEY`, holding the PEM +> contents of your client certificate and its matching key. The repositories +> authenticate clients with mutual TLS, so without both secrets the setup +> leaves them disabled and the Postgres client will not install. + ## Prerequisites - [Docker Engine](https://docs.docker.com/engine/install/) (Linux) or [Docker Desktop](https://docs.docker.com/desktop/) (macOS) diff --git a/lima/roles/deb_prerequisites/tasks/main.yaml b/lima/roles/deb_prerequisites/tasks/main.yaml index c1c96a5c..c8a4fefe 100644 --- a/lima/roles/deb_prerequisites/tasks/main.yaml +++ b/lima/roles/deb_prerequisites/tasks/main.yaml @@ -34,10 +34,6 @@ replace: release when: not (use_staging_packages | bool) register: repo_reconfigured_to_release -- name: Update apt cache again - ansible.builtin.apt: - update_cache: yes - changed_when: false - name: Install the pgEdge client certificate and enable the repositories when: pgedge_client_cert | default('') | length > 0 and pgedge_client_key | default('') | length > 0 @@ -76,12 +72,17 @@ - name: Warn when no pgEdge client certificate was supplied ansible.builtin.debug: msg: >- - No pgEdge client certificate supplied: the repositories stay disabled and - pgEdge packages will not install. Set pgedge_client_cert and - pgedge_client_key. + No pgEdge client certificate supplied for this run. Any existing + repository configuration is left as it is, and installing pgEdge packages + may fail. Set pgedge_client_cert and pgedge_client_key. when: not (pgedge_client_cert | default('') | length > 0 and pgedge_client_key | default('') | length > 0) +- name: Update apt cache again + ansible.builtin.apt: + update_cache: yes + changed_when: false + - name: Track configured Spock major for reinstall detection ansible.builtin.copy: content: "{{ spock_major | default('50') }}" diff --git a/lima/roles/deb_prerequisites/templates/pgedge-old.sources.tmpl b/lima/roles/deb_prerequisites/templates/pgedge-old.sources.tmpl deleted file mode 100644 index ab4764a8..00000000 --- a/lima/roles/deb_prerequisites/templates/pgedge-old.sources.tmpl +++ /dev/null @@ -1,5 +0,0 @@ -Types: deb -URIs: https://apt.pgedge.com/release_old/{{ansible_facts['distribution_release']}} -Suites: {{ansible_facts['distribution_release']}} -Components: main -Trusted: yes diff --git a/lima/roles/rhel_prerequisites/tasks/main.yaml b/lima/roles/rhel_prerequisites/tasks/main.yaml index 9d4e65ff..bdb09a33 100644 --- a/lima/roles/rhel_prerequisites/tasks/main.yaml +++ b/lima/roles/rhel_prerequisites/tasks/main.yaml @@ -72,9 +72,9 @@ - name: Warn when no pgEdge client certificate was supplied ansible.builtin.debug: msg: >- - No pgEdge client certificate supplied: the repositories stay disabled and - pgEdge packages will not install. Set pgedge_client_cert and - pgedge_client_key. + No pgEdge client certificate supplied for this run. Any existing + repository configuration is left as it is, and installing pgEdge packages + may fail. Set pgedge_client_cert and pgedge_client_key. when: not (pgedge_client_cert | default('') | length > 0 and pgedge_client_key | default('') | length > 0) diff --git a/lima/vars.yaml b/lima/vars.yaml index 1e1a09ac..05261d0d 100644 --- a/lima/vars.yaml +++ b/lima/vars.yaml @@ -1,5 +1,13 @@ --- use_staging_packages: false +# Client certificate for the gated pgEdge repositories. Read from files on the +# controller rather than passed on the command line, so the PEM never lands in +# argv. Override the paths with PGEDGE_CLIENT_CERT_FILE / PGEDGE_CLIENT_KEY_FILE. +pgedge_client_cert_file: "{{ lookup('env', 'PGEDGE_CLIENT_CERT_FILE') | default('~/.pgedge/client.crt', true) }}" +pgedge_client_key_file: "{{ lookup('env', 'PGEDGE_CLIENT_KEY_FILE') | default('~/.pgedge/client.key', true) }}" +pgedge_client_cert: "{{ lookup('file', pgedge_client_cert_file | expanduser, errors='ignore') | default('', true) }}" +pgedge_client_key: "{{ lookup('file', pgedge_client_key_file | expanduser, errors='ignore') | default('', true) }}" + os: rocky-9 machines: - name: control-plane-dev-1 From 2c0e26e5b292c311dd7197a08d5c2574174529b4 Mon Sep 17 00:00:00 2001 From: Muhammad Aqeel Date: Wed, 28 Oct 2026 21:16:19 +0500 Subject: [PATCH 3/8] fix: remove the retired pgEdge old repositories from reused VMs --- docs/walkthrough.md | 8 +++++--- lima/roles/deb_prerequisites/tasks/main.yaml | 12 +++++++++++- lima/roles/rhel_prerequisites/tasks/main.yaml | 14 +++++++++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/docs/walkthrough.md b/docs/walkthrough.md index 8f1df47e..248ceb4f 100644 --- a/docs/walkthrough.md +++ b/docs/walkthrough.md @@ -29,9 +29,11 @@ with three nodes, each accepting reads and writes. > **The pgEdge package repository needs a client certificate** > Before creating the Codespace, add two Codespaces secrets for this > repository, `PGEDGE_CLIENT_CERT` and `PGEDGE_CLIENT_KEY`, holding the PEM -> contents of your client certificate and its matching key. The repositories -> authenticate clients with mutual TLS, so without both secrets the setup -> leaves them disabled and the Postgres client will not install. +> contents of your client certificate and its matching key. The certificate +> must be the full chain -- your leaf certificate first, followed by the +> issuing intermediate -- because the leaf alone cannot authenticate. The +> repositories authenticate clients with mutual TLS, so without both secrets +> the setup leaves them disabled and the Postgres client will not install. ## Prerequisites diff --git a/lima/roles/deb_prerequisites/tasks/main.yaml b/lima/roles/deb_prerequisites/tasks/main.yaml index c8a4fefe..cddc0b83 100644 --- a/lima/roles/deb_prerequisites/tasks/main.yaml +++ b/lima/roles/deb_prerequisites/tasks/main.yaml @@ -1,4 +1,12 @@ --- +# Retired: release_old existed only because an old GPG key made those packages +# unverifiable. Lima reuses existing VMs, so a VM provisioned before this was +# removed still carries the source, and the endpoint is gone -- which fails +# every apt operation, not just pgEdge's. Remove it before the first one. +- name: Remove the retired pgEdge old repository + ansible.builtin.file: + path: /etc/apt/sources.list.d/pgedge-old.sources + state: absent - name: Update apt cache ansible.builtin.apt: update_cache: yes @@ -74,7 +82,9 @@ msg: >- No pgEdge client certificate supplied for this run. Any existing repository configuration is left as it is, and installing pgEdge packages - may fail. Set pgedge_client_cert and pgedge_client_key. + may fail. Put the certificate and key at ~/.pgedge/client.crt and + ~/.pgedge/client.key, or point PGEDGE_CLIENT_CERT_FILE and + PGEDGE_CLIENT_KEY_FILE at them. when: not (pgedge_client_cert | default('') | length > 0 and pgedge_client_key | default('') | length > 0) diff --git a/lima/roles/rhel_prerequisites/tasks/main.yaml b/lima/roles/rhel_prerequisites/tasks/main.yaml index bdb09a33..85030ea5 100644 --- a/lima/roles/rhel_prerequisites/tasks/main.yaml +++ b/lima/roles/rhel_prerequisites/tasks/main.yaml @@ -1,4 +1,14 @@ --- +# Retired: see the matching comment in deb_prerequisites. Reused VMs still +# carry these repo definitions and the endpoint is gone, so remove them before +# the first dnf operation. +- name: Remove the retired pgEdge old repositories + ansible.builtin.yum_repository: + name: '{{ item }}' + state: absent + loop: + - pgedge-old + - pgedge-noarch-old - name: Install base prerequisites ansible.builtin.package: name: '{{ item }}' @@ -74,7 +84,9 @@ msg: >- No pgEdge client certificate supplied for this run. Any existing repository configuration is left as it is, and installing pgEdge packages - may fail. Set pgedge_client_cert and pgedge_client_key. + may fail. Put the certificate and key at ~/.pgedge/client.crt and + ~/.pgedge/client.key, or point PGEDGE_CLIENT_CERT_FILE and + PGEDGE_CLIENT_KEY_FILE at them. when: not (pgedge_client_cert | default('') | length > 0 and pgedge_client_key | default('') | length > 0) From 53181e39172f93b12d5090fc5f0be5412e541c71 Mon Sep 17 00:00:00 2001 From: Muhammad Aqeel Date: Wed, 28 Oct 2026 21:49:43 +0500 Subject: [PATCH 4/8] docs: state that the Codespaces secrets are account-level and need no write access --- docs/walkthrough.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/walkthrough.md b/docs/walkthrough.md index 248ceb4f..8188edb3 100644 --- a/docs/walkthrough.md +++ b/docs/walkthrough.md @@ -27,11 +27,16 @@ with three nodes, each accepting reads and writes. > [!IMPORTANT] > **The pgEdge package repository needs a client certificate** -> Before creating the Codespace, add two Codespaces secrets for this -> repository, `PGEDGE_CLIENT_CERT` and `PGEDGE_CLIENT_KEY`, holding the PEM -> contents of your client certificate and its matching key. The certificate -> must be the full chain -- your leaf certificate first, followed by the -> issuing intermediate -- because the leaf alone cannot authenticate. The +> Before creating the Codespace, add `PGEDGE_CLIENT_CERT` and +> `PGEDGE_CLIENT_KEY` as *account-level* Codespaces secrets -- under your own +> [Codespaces settings](https://github.com/settings/codespaces), granting this +> repository access to each -- holding the PEM contents of your client +> certificate and its matching key. Account-level secrets need no write access +> to this repository, so there is no need to fork it; they reach the setup +> script because it runs as `postCreateCommand`, after the Codespace is up. +> The certificate must be the full chain -- your leaf certificate first, +> followed by the issuing intermediate -- because the leaf alone cannot +> authenticate. The > repositories authenticate clients with mutual TLS, so without both secrets > the setup leaves them disabled and the Postgres client will not install. From d912301dc6eb0e44c2e95066baab77951e11435d Mon Sep 17 00:00:00 2001 From: Muhammad Aqeel Date: Thu, 29 Oct 2026 13:09:38 +0500 Subject: [PATCH 5/8] fix: import the pgEdge RPM signing key from downloads.pgedge.com/keys/dnf --- lima/roles/rhel_prerequisites/tasks/main.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lima/roles/rhel_prerequisites/tasks/main.yaml b/lima/roles/rhel_prerequisites/tasks/main.yaml index 85030ea5..ce989edb 100644 --- a/lima/roles/rhel_prerequisites/tasks/main.yaml +++ b/lima/roles/rhel_prerequisites/tasks/main.yaml @@ -23,8 +23,16 @@ community.general.dnf_config_manager: name: crb state: enabled +# Imported explicitly rather than left to dnf's auto-import from the repo's +# gpgkey=. The RPM and DEB repositories are signed with different keys, so this +# is keys/dnf specifically. +- name: Install the pgEdge package signing key + ansible.builtin.rpm_key: + key: https://downloads.pgedge.com/keys/dnf/pgedge-rsa.pub + state: present # downloads.pgedge.com, not dnf.pgedge.com: the gated repository cannot serve -# the package that configures access to it. +# the package that configures access to it. The repo package itself is +# unsigned, hence disable_gpg_check here and nowhere else. - name: Install pgEdge repository ansible.builtin.package: name: https://downloads.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm From 3787bffeac0253729266bb9fd611a8dc1ed965eb Mon Sep 17 00:00:00 2001 From: Muhammad Aqeel Date: Thu, 29 Oct 2026 13:24:21 +0500 Subject: [PATCH 6/8] Drop the retired-repository cleanup tasks: main already removed the definitions --- lima/roles/deb_prerequisites/tasks/main.yaml | 8 -------- lima/roles/rhel_prerequisites/tasks/main.yaml | 10 ---------- 2 files changed, 18 deletions(-) diff --git a/lima/roles/deb_prerequisites/tasks/main.yaml b/lima/roles/deb_prerequisites/tasks/main.yaml index cddc0b83..5087fb5f 100644 --- a/lima/roles/deb_prerequisites/tasks/main.yaml +++ b/lima/roles/deb_prerequisites/tasks/main.yaml @@ -1,12 +1,4 @@ --- -# Retired: release_old existed only because an old GPG key made those packages -# unverifiable. Lima reuses existing VMs, so a VM provisioned before this was -# removed still carries the source, and the endpoint is gone -- which fails -# every apt operation, not just pgEdge's. Remove it before the first one. -- name: Remove the retired pgEdge old repository - ansible.builtin.file: - path: /etc/apt/sources.list.d/pgedge-old.sources - state: absent - name: Update apt cache ansible.builtin.apt: update_cache: yes diff --git a/lima/roles/rhel_prerequisites/tasks/main.yaml b/lima/roles/rhel_prerequisites/tasks/main.yaml index ce989edb..0a03ccf5 100644 --- a/lima/roles/rhel_prerequisites/tasks/main.yaml +++ b/lima/roles/rhel_prerequisites/tasks/main.yaml @@ -1,14 +1,4 @@ --- -# Retired: see the matching comment in deb_prerequisites. Reused VMs still -# carry these repo definitions and the endpoint is gone, so remove them before -# the first dnf operation. -- name: Remove the retired pgEdge old repositories - ansible.builtin.yum_repository: - name: '{{ item }}' - state: absent - loop: - - pgedge-old - - pgedge-noarch-old - name: Install base prerequisites ansible.builtin.package: name: '{{ item }}' From 8a33d39c6066f7c7dca476bdffedc57cfcd5b4e2 Mon Sep 17 00:00:00 2001 From: Muhammad Aqeel Date: Thu, 29 Oct 2026 13:25:22 +0500 Subject: [PATCH 7/8] Restore the orphaned pgedge-old template: removing it is not this change's business --- .../deb_prerequisites/templates/pgedge-old.sources.tmpl | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 lima/roles/deb_prerequisites/templates/pgedge-old.sources.tmpl diff --git a/lima/roles/deb_prerequisites/templates/pgedge-old.sources.tmpl b/lima/roles/deb_prerequisites/templates/pgedge-old.sources.tmpl new file mode 100644 index 00000000..ab4764a8 --- /dev/null +++ b/lima/roles/deb_prerequisites/templates/pgedge-old.sources.tmpl @@ -0,0 +1,5 @@ +Types: deb +URIs: https://apt.pgedge.com/release_old/{{ansible_facts['distribution_release']}} +Suites: {{ansible_facts['distribution_release']}} +Components: main +Trusted: yes From f701dca6ca474b4c575e0341288de90adbd269ed Mon Sep 17 00:00:00 2001 From: Jason Lynch Date: Tue, 1 Dec 2026 11:25:51 -0500 Subject: [PATCH 8/8] test: use pgedge repo certs in systemd test fixtures Adds the pgEdge enterprise repository certificates to the ci-systemd and lima e2e test fixtures. Also adds instructions for how to generate a certificate request and obtain a repo certificate for development. --- .circleci/config.yml | 15 ++- Makefile | 27 +++++- .../debian-13-community/docker-compose.yaml | 8 +- .../debian-13/Dockerfile | 50 +++++++--- .../debian-13/docker-compose.yaml | 50 +++------- .../debian-13/host-1.config.json | 7 -- .../debian-13/host-2.config.json | 7 -- .../debian-13/host-3.config.json | 7 -- .../rocky-9-community/docker-compose.yaml | 8 +- .../rocky-9/Dockerfile | 46 +++++++--- .../rocky-9/docker-compose.yaml | 52 +++-------- .../rocky-9/host-1.config.json | 7 -- .../rocky-9/host-2.config.json | 7 -- .../rocky-9/host-3.config.json | 7 -- docs/development/running-locally.md | 26 ++++++ ...temd-debian-13-community.test_config.yaml} | 6 +- ...docker-systemd-debian-13.test_config.yaml} | 6 +- ...ystemd-rocky-9-community.test_config.yaml} | 6 +- ...> docker-systemd-rocky-9.test_config.yaml} | 6 +- .../defaults/main.yaml | 7 ++ .../tasks/main.yaml | 92 ++++++++++++++++--- .../vars/main.yaml | 3 + 22 files changed, 266 insertions(+), 184 deletions(-) delete mode 100644 docker/control-plane-systemd-ci/debian-13/host-1.config.json delete mode 100644 docker/control-plane-systemd-ci/debian-13/host-2.config.json delete mode 100644 docker/control-plane-systemd-ci/debian-13/host-3.config.json delete mode 100644 docker/control-plane-systemd-ci/rocky-9/host-1.config.json delete mode 100644 docker/control-plane-systemd-ci/rocky-9/host-2.config.json delete mode 100644 docker/control-plane-systemd-ci/rocky-9/host-3.config.json rename e2e/fixtures/outputs/{docker-systemd-debian13-community.test_config.yaml => docker-systemd-debian-13-community.test_config.yaml} (51%) rename e2e/fixtures/outputs/{docker-systemd-debian13.test_config.yaml => docker-systemd-debian-13.test_config.yaml} (50%) rename e2e/fixtures/outputs/{docker-systemd-rocky9-community.test_config.yaml => docker-systemd-rocky-9-community.test_config.yaml} (51%) rename e2e/fixtures/outputs/{docker-systemd-rocky9.test_config.yaml => docker-systemd-rocky-9.test_config.yaml} (51%) diff --git a/.circleci/config.yml b/.circleci/config.yml index e07b615a..111d7545 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -170,16 +170,23 @@ jobs: type: string steps: - common_setup + - run: + name: Write pgEdge repository client credentials + command: | + mkdir -p ~/.pgedge + chmod 700 ~/.pgedge + ( + umask 077 + printf '%s' "${PGEDGE_CLIENT_KEY:?PGEDGE_CLIENT_KEY must be set}" | base64 -d > ~/.pgedge/client.key + printf '%s' "${PGEDGE_CLIENT_CRT:?PGEDGE_CLIENT_CRT must be set}" | base64 -d > ~/.pgedge/client.crt + ) - run: name: Start << parameters.systemd_os >> systemd cluster command: make ci-systemd-up SYSTEMD_OS=<< parameters.systemd_os >> - run: name: Run << parameters.systemd_os >> systemd E2E tests command: | - # The fixture names drop the hyphen before the OS version, e.g. - # rocky-9-community -> docker-systemd-rocky9-community. - fixture="docker-systemd-$(echo '<< parameters.systemd_os >>' | sed -E 's/^([a-z]+)-([0-9]+)/\1\2/')" - make test-e2e E2E_FIXTURE="${fixture}" E2E_DEBUG=1 TEST_RERUN_FAILS=2 + make test-e2e E2E_FIXTURE='docker-systemd-<< parameters.systemd_os >>' E2E_DEBUG=1 TEST_RERUN_FAILS=2 - run: name: Archive debug output command: | diff --git a/Makefile b/Makefile index a62476df..466f6cf6 100644 --- a/Makefile +++ b/Makefile @@ -138,9 +138,9 @@ e2e-help: @echo "" @echo " E2E variables:" @echo " E2E_FIXTURE Fixture name (lima, ec2, ec2-systemd, lima-systemd," - @echo " docker-systemd-rocky9, docker-systemd-debian13," - @echo " docker-systemd-rocky9-community," - @echo " docker-systemd-debian13-community)" + @echo " docker-systemd-rocky-9, docker-systemd-debian-13," + @echo " docker-systemd-rocky-9-community," + @echo " docker-systemd-debian-13-community)" @echo " E2E_RUN Test name regex filter" @echo " E2E_PARALLEL Parallelism (default: 4)" @echo " E2E_DEBUG=1 Print debug output for failing tests" @@ -663,3 +663,24 @@ ci-systemd-down: docs: docker build -t control-plane-docs ./docs docker run --rm -it -p 8000:8000 -v ${PWD}:/docs control-plane-docs + +################################### +# pgEdge repo key # +################################### + +repo_key_dir=$(HOME)/.pgedge +repo_key=$(repo_key_dir)/client.key +repo_csr=$(repo_key_dir)/client.csr +repo_crt=$(repo_key_dir)/client.crt + +$(repo_key_dir): + mkdir $(repo_key_dir) + +$(repo_key): $(repo_key_dir) + openssl genrsa -out $(repo_key) 2048 + +$(repo_csr): $(repo_key) + openssl req -new -key $(repo_key) -out $(repo_csr) -subj "/CN=$(shell hostname)" + +.PHONY: pgedge-repo-csr +pgedge-repo-csr: $(repo_csr) diff --git a/docker/control-plane-systemd-ci/debian-13-community/docker-compose.yaml b/docker/control-plane-systemd-ci/debian-13-community/docker-compose.yaml index f91478d7..80b4de04 100644 --- a/docker/control-plane-systemd-ci/debian-13-community/docker-compose.yaml +++ b/docker/control-plane-systemd-ci/debian-13-community/docker-compose.yaml @@ -8,7 +8,7 @@ # IP on the compose network. # # make ci-systemd-up SYSTEMD_OS=debian-13-community -# make test-e2e E2E_FIXTURE=docker-systemd-debian13-community +# make test-e2e E2E_FIXTURE=docker-systemd-debian-13-community # make ci-systemd-down SYSTEMD_OS=debian-13-community name: cp-systemd-debian-13-community @@ -34,21 +34,21 @@ x-host: &host services: host-1: <<: *host - container_name: cp-debian13-community-host-1 + container_name: cp-debian-13-community-host-1 hostname: host-1 ports: - "127.0.0.1:3030:3000" host-2: <<: *host - container_name: cp-debian13-community-host-2 + container_name: cp-debian-13-community-host-2 hostname: host-2 ports: - "127.0.0.1:3031:3000" host-3: <<: *host - container_name: cp-debian13-community-host-3 + container_name: cp-debian-13-community-host-3 hostname: host-3 ports: - "127.0.0.1:3032:3000" diff --git a/docker/control-plane-systemd-ci/debian-13/Dockerfile b/docker/control-plane-systemd-ci/debian-13/Dockerfile index 66553b18..a99a735e 100644 --- a/docker/control-plane-systemd-ci/debian-13/Dockerfile +++ b/docker/control-plane-systemd-ci/debian-13/Dockerfile @@ -21,21 +21,41 @@ RUN apt-get update && \ # pgEdge prerequisites from the release repo, so CI tests certified builds. # The RAG server package enables its own unit, which would listen on port # 8080 at boot. The Control Plane runs its own RAG units, so disable it. -RUN curl -fsSL --retry 5 https://apt.pgedge.com/repodeb/pgedge-release_latest_all.deb \ - -o /tmp/pgedge-release.deb && \ - dpkg -i /tmp/pgedge-release.deb && \ - rm /tmp/pgedge-release.deb && \ - apt-get update -o Acquire::Retries=5 && \ - apt-get install -y -o Acquire::Retries=5 \ - pgedge-postgresql-18 \ - pgedge-postgresql-18-spock50 \ - pgedge-pgbackrest \ - pgedge-patroni \ - pgedge-postgrest \ - pgedge-postgres-mcp \ - pgedge-rag-server2 && \ - rm -f /etc/systemd/system/multi-user.target.wants/pgedge-rag-server2.service && \ - rm -rf /var/lib/apt/lists/* +RUN --mount=type=secret,id=repo_client_crt \ + --mount=type=secret,id=repo_client_key \ + < 0 + and pgedge_client_key | default('') | length > 0 + block: + - name: Create the pgEdge configuration directory + ansible.builtin.file: + path: "{{ _pgedge_client_cert_dir }}" + state: directory + owner: root + group: root + mode: '0755' + - name: Write the client certificate + ansible.builtin.copy: + content: "{{ pgedge_client_cert | trim }}\n" + dest: "{{ _pgedge_client_cert_dir }}/client.crt" + owner: root + group: root + mode: '0644' + no_log: true + # Ownership and mode are left to pgedge-subscription-manager: apt reads the + # key as _apt, dnf as root. + - name: Write the client key + ansible.builtin.copy: + content: "{{ pgedge_client_key | trim }}\n" + dest: "{{ _pgedge_client_cert_dir }}/client.key" + owner: root + group: root + mode: '0600' + no_log: true + - name: Validate the certificate and enable the pgEdge repositories + ansible.builtin.command: >- + pgedge-subscription-manager install + {{ _pgedge_client_cert_dir }}/client.crt {{ _pgedge_client_cert_dir }}/client.key --force + changed_when: true + +- name: Warn when no pgEdge client certificate was supplied + ansible.builtin.debug: + msg: >- + No pgEdge client certificate supplied for this run. Any existing + repository configuration is left as it is, and installing pgEdge packages + may fail. Put the certificate and key at ~/.pgedge/client.crt and + ~/.pgedge/client.key, or point PGEDGE_CLIENT_CERT_FILE and + PGEDGE_CLIENT_KEY_FILE at them. + when: not (pgedge_client_cert | default('') | length > 0 + and pgedge_client_key | default('') | length > 0) + +# ── pgEdge packages ─────────────────────────────────────────────────────────── + +- name: Install pgEdge packages (RPM) + dnf: + name: "{{ _rpm_packages }}" + state: present + when: ansible_os_family == 'RedHat' + +- name: Install awscli (RPM) + dnf: + name: awscli + state: present + when: ansible_os_family == 'RedHat' + - name: Install pgEdge packages (DEB) apt: name: "{{ _deb_packages }}" diff --git a/e2e/fixtures/roles/install_systemd_prerequisites/vars/main.yaml b/e2e/fixtures/roles/install_systemd_prerequisites/vars/main.yaml index 3eceb34c..7276701e 100644 --- a/e2e/fixtures/roles/install_systemd_prerequisites/vars/main.yaml +++ b/e2e/fixtures/roles/install_systemd_prerequisites/vars/main.yaml @@ -5,6 +5,9 @@ _arch_transform: aarch64: arm64 arm64: arm64 +# Where the repository client certificate and key are written +_pgedge_client_cert_dir: "{{ '/etc/pki/pgedge' if ansible_os_family == 'RedHat' else '/etc/pgedge' }}" + # RPM package names _rpm_packages: - "pgedge-postgresql{{ pg_version }}"