OpenVPN Ansible / Ansible Syntax Check (push) Successful in 43s
OpenVPN Ansible / Ansible Lint (push) Successful in 1m8s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Successful in 3m32s
OpenVPN Ansible / Generate SBOM (push) Successful in 55s
OpenVPN Ansible / Scan SBOM with Trivy (push) Successful in 18s
- Add a dedicated role and workflow to generate VPN JWT identities and export public keys - Run identity preparation automatically for VPN nodes awaiting OpenBao registration - Gate OpenVPN and PKI setup until each node is registered - Split PKI setup into runtime, configuration, service, and initial certificate tasks - Restore TAP and bridge attachment after OpenVPN restarts - Remove bundled server certificate and private key
92 lines
3.0 KiB
YAML
92 lines
3.0 KiB
YAML
name: OpenVPN JWT Identity Preparation
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows:
|
|
- OpenVPN Ansible
|
|
types:
|
|
- completed
|
|
|
|
jobs:
|
|
prepare-identities:
|
|
name: Prepare unregistered VPN identities
|
|
runs-on: hetzner-ubuntu-latest
|
|
if: >-
|
|
github.event.workflow_run.conclusion == 'success' &&
|
|
github.event.workflow_run.head_branch == 'main'
|
|
|
|
container:
|
|
image: gitea.infrastructure.helmholz.cloud/gitea_admin/ansible-utilities:latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.workflow_run.head_sha }}
|
|
|
|
- name: Find VPN nodes awaiting JWT registration
|
|
id: pending
|
|
run: |
|
|
set -eu
|
|
ansible-inventory -i inventories/prod/hosts.ini --list |
|
|
python3 -c '
|
|
import json
|
|
import sys
|
|
|
|
inventory = json.load(sys.stdin)
|
|
vpn_hosts = inventory.get("vpn_nodes", {}).get("hosts", [])
|
|
hostvars = inventory.get("_meta", {}).get("hostvars", {})
|
|
pending = []
|
|
for hostname in vpn_hosts:
|
|
registered = hostvars.get(hostname, {}).get("openvpn_jwt_registered", False)
|
|
if str(registered).strip().lower() not in {"true", "yes", "1", "on"}:
|
|
pending.append(hostname)
|
|
|
|
print(",".join(pending))
|
|
' > /tmp/openvpn-jwt-pending-hosts
|
|
pending_hosts=$(cat /tmp/openvpn-jwt-pending-hosts)
|
|
if [ -n "$pending_hosts" ]; then
|
|
echo "has_hosts=true" >> "$GITHUB_OUTPUT"
|
|
echo "hosts=$pending_hosts" >> "$GITHUB_OUTPUT"
|
|
echo "Preparing JWT identities for: $pending_hosts"
|
|
else
|
|
echo "has_hosts=false" >> "$GITHUB_OUTPUT"
|
|
echo "No VPN nodes are awaiting JWT registration."
|
|
fi
|
|
|
|
- name: Setup SSH
|
|
if: steps.pending.outputs.has_hosts == 'true'
|
|
env:
|
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
run: |
|
|
set -eu
|
|
mkdir -p ~/.ssh
|
|
printf '%s\n' "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
ssh-keygen -y -f ~/.ssh/id_ed25519 > /dev/null
|
|
|
|
- name: Install Ansible collections
|
|
if: steps.pending.outputs.has_hosts == 'true'
|
|
run: ansible-galaxy collection install -r requirements.yml
|
|
|
|
- name: Prepare JWT identities
|
|
if: steps.pending.outputs.has_hosts == 'true'
|
|
env:
|
|
ANSIBLE_CONFIG: ${{ github.workspace }}/ansible.cfg
|
|
PENDING_HOSTS: ${{ steps.pending.outputs.hosts }}
|
|
run: |
|
|
set -eu
|
|
ansible-playbook \
|
|
-i inventories/prod/hosts.ini \
|
|
playbooks/openvpn-jwt-identity.yml \
|
|
--limit "$PENDING_HOSTS"
|
|
|
|
- name: Upload public JWT keys
|
|
if: steps.pending.outputs.has_hosts == 'true'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: openvpn-jwt-public-keys
|
|
path: artifacts/openvpn-jwt-public-keys/*.pem
|
|
if-no-files-found: error
|
|
retention-days: 7
|