feat(ansible): automate NAT gateway and VPN routing
OpenVPN Ansible / Ansible Syntax Check (push) Successful in 11s
OpenVPN Ansible / Ansible Lint (push) Successful in 19s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Failing after 1m27s
OpenVPN Ansible / Generate SBOM (push) Skipped
OpenVPN Ansible / Scan SBOM with Trivy (push) Skipped

- Add NAT gateway inventory and routing playbooks.
- Update Gitea Actions and GitLab CI to validate all playbooks.
- Deploy gateway and routing configurations before OpenVPN.
- Document setup and verification steps.
This commit is contained in:
2026-10-28 18:28:26 +01:00
parent c23ff11194
commit 545c9740e8
14 changed files with 384 additions and 84 deletions
+88 -79
View File
@@ -16,6 +16,7 @@ ansible-lint:
stage: validate
script:
- export ANSIBLE_CONFIG=$CI_PROJECT_DIR/ansible.cfg
- ansible-galaxy collection install -r requirements.yml
- ansible-lint
syntax-check:
@@ -23,93 +24,101 @@ syntax-check:
script:
- export ANSIBLE_CONFIG=$CI_PROJECT_DIR/ansible.cfg
- ansible-galaxy collection install -r requirements.yml
- ansible-playbook --syntax-check playbooks/openvpn.yml
deploy-prod:
extends: .openbao-with-secrets
stage: deploy
id_tokens:
OPENBAO_ID_TOKEN:
aud: "https://openbao.helmholz.local:8200"
variables:
OPENBAO_SECRET_REQUESTS_FILE: "secrets.json"
script:
- ansible-inventory --list > /dev/null
- |
set -eu
set -eu
for playbook in playbooks/*.yml; do
echo "Syntax checking ${playbook}"
ansible-playbook --syntax-check "$playbook"
done
echo "Setting up SSH..."
mkdir -p ~/.ssh
# deploy-prod:
# extends: .openbao-with-secrets
# stage: deploy
printf '%s\n' "$VPN_ADMIN_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
export ANSIBLE_CONFIG="$CI_PROJECT_DIR/ansible.cfg"
ansible-galaxy collection install -r requirements.yml
ansible-playbook playbooks/openvpn.yml
when: manual
# id_tokens:
# OPENBAO_ID_TOKEN:
# aud: "https://openbao.helmholz.local:8200"
sbom:
extends: .openbao-with-secrets
stage: security
# variables:
# OPENBAO_SECRET_REQUESTS_FILE: "secrets.json"
# script:
# - |
# set -eu
id_tokens:
OPENBAO_ID_TOKEN:
aud: "https://openbao.helmholz.local:8200"
# echo "Setting up SSH..."
# mkdir -p ~/.ssh
variables:
OPENBAO_SECRET_REQUESTS_FILE: "secrets.json"
needs:
- deploy-prod
script:
- |
set -eu
# printf '%s\n' "$VPN_ADMIN_PRIVATE_KEY" > ~/.ssh/id_ed25519
# chmod 600 ~/.ssh/id_ed25519
# export ANSIBLE_CONFIG="$CI_PROJECT_DIR/ansible.cfg"
# ansible-galaxy collection install -r requirements.yml
# ansible-playbook playbooks/nat-gateway.yml --limit nat_gateways
# ansible-playbook playbooks/private-vpn-routing.yml --limit vpn_nodes
# ansible-playbook playbooks/openvpn.yml
# when: manual
echo "Setting up SSH..."
mkdir -p ~/.ssh
# sbom:
# extends: .openbao-with-secrets
# stage: security
printf '%s\n' "$VPN_ADMIN_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
export ANSIBLE_CONFIG="$CI_PROJECT_DIR/ansible.cfg"
ansible-playbook playbooks/sbom.yml
artifacts:
when: always
paths:
- reports/sbom/
expire_in: 365 days
# id_tokens:
# OPENBAO_ID_TOKEN:
# aud: "https://openbao.helmholz.local:8200"
trivy:sbom:
stage: security
needs:
- job: sbom
artifacts: true
script:
- ls -R reports || true
- mkdir -p reports/trivy
- |
if compgen -G "reports/sbom/*.json" > /dev/null; then
for sbom in reports/sbom/*.json; do
filename=$(basename "$sbom" .json)
# variables:
# OPENBAO_SECRET_REQUESTS_FILE: "secrets.json"
# needs:
# - deploy-prod
# script:
# - |
# set -eu
echo "Scanning $sbom"
# echo "Setting up SSH..."
# mkdir -p ~/.ssh
trivy sbom \
--format json \
--output "reports/trivy/${filename}-trivy.json" \
--exit-code 0 \
"$sbom"
trivy sbom \
--format table \
--output "reports/trivy/${filename}-trivy.txt" \
--exit-code 0 \
"$sbom"
done
else
echo "No SBOM files found."
exit 1
fi
artifacts:
when: always
expire_in: 365 days
paths:
- reports/trivy/
# printf '%s\n' "$VPN_ADMIN_PRIVATE_KEY" > ~/.ssh/id_ed25519
# chmod 600 ~/.ssh/id_ed25519
# export ANSIBLE_CONFIG="$CI_PROJECT_DIR/ansible.cfg"
# ansible-playbook playbooks/sbom.yml
# artifacts:
# when: always
# paths:
# - reports/sbom/
# expire_in: 365 days
# trivy:sbom:
# stage: security
# needs:
# - job: sbom
# artifacts: true
# script:
# - ls -R reports || true
# - mkdir -p reports/trivy
# - |
# if compgen -G "reports/sbom/*.json" > /dev/null; then
# for sbom in reports/sbom/*.json; do
# filename=$(basename "$sbom" .json)
# echo "Scanning $sbom"
# trivy sbom \
# --format json \
# --output "reports/trivy/${filename}-trivy.json" \
# --exit-code 0 \
# "$sbom"
# trivy sbom \
# --format table \
# --output "reports/trivy/${filename}-trivy.txt" \
# --exit-code 0 \
# "$sbom"
# done
# else
# echo "No SBOM files found."
# exit 1
# fi
# artifacts:
# when: always
# expire_in: 365 days
# paths:
# - reports/trivy/