name: OpenVPN JWT Identity Preparation on: workflow_dispatch: inputs: vpn_host: description: Inventory hostname of the VPN server to prepare required: true type: string jobs: prepare-identity: name: Prepare VPN JWT identity runs-on: hetzner-ubuntu-latest container: image: gitea.infrastructure.helmholz.cloud/gitea_admin/ansible-utilities:latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup SSH 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 run: ansible-galaxy collection install -r requirements.yml - name: Validate selected VPN host env: VPN_HOST: ${{ github.event.inputs.vpn_host }} run: | set -eu ansible-inventory -i inventories/prod/hosts.ini --list | python3 -c ' import json import os import sys inventory = json.load(sys.stdin) selected_host = os.environ["VPN_HOST"] vpn_hosts = inventory.get("vpn_nodes", {}).get("hosts", []) if selected_host not in vpn_hosts: print("vpn_host must exactly match a host in the vpn_nodes inventory group", file=sys.stderr) sys.exit(1) ' - name: Prepare JWT identity env: ANSIBLE_CONFIG: ${{ github.workspace }}/ansible.cfg VPN_HOST: ${{ github.event.inputs.vpn_host }} run: | set -eu ansible-playbook \ -i inventories/prod/hosts.ini \ playbooks/openvpn-pki-identity.yml \ --limit "$VPN_HOST" - name: Upload public JWT key uses: actions/upload-artifact@v4 with: name: openvpn-pki-public-keys path: artifacts/openvpn-pki-public-keys/*.pem if-no-files-found: error retention-days: 7