refactor(vpn): split JWT identity and OpenVPN certificate lifecycle
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
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
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
---
|
||||
openbao_cli_version: "2.7.0"
|
||||
openbao_cli_binary_path: /usr/bin/bao
|
||||
openbao_cli_architecture_map:
|
||||
x86_64: amd64
|
||||
aarch64: arm64
|
||||
openbao_cli_verify_checksum_signature: true
|
||||
openbao_cli_gpg_key_url: https://openbao.org/assets/openbao-gpg-pub-20240618.asc
|
||||
openbao_cli_gpg_primary_fingerprint: 66D15FDD87287219C8E15478D200CD702853E6D0
|
||||
@@ -0,0 +1,165 @@
|
||||
---
|
||||
- name: Validate OpenBao CLI platform
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts.distribution in ['Debian', 'Ubuntu']
|
||||
- ansible_facts.architecture in openbao_cli_architecture_map
|
||||
fail_msg: >-
|
||||
OpenBao CLI installation supports Debian and Ubuntu amd64 and arm64 only;
|
||||
detected {{ ansible_facts.distribution }} {{ ansible_facts.architecture }}.
|
||||
|
||||
- name: Set OpenBao release package facts
|
||||
ansible.builtin.set_fact:
|
||||
openbao_cli_package_name: "openbao_{{ openbao_cli_version }}_linux_{{ openbao_cli_architecture_map[ansible_facts.architecture] }}.deb"
|
||||
openbao_cli_release_url: "https://github.com/openbao/openbao/releases/download/v{{ openbao_cli_version }}"
|
||||
|
||||
- name: Read currently installed OpenBao CLI version
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- "{{ openbao_cli_binary_path }}"
|
||||
- version
|
||||
register: openbao_cli_current_version
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when: ansible_facts.pkg_mgr == 'apt'
|
||||
|
||||
- name: Set OpenBao CLI installation requirement using exact version equality
|
||||
ansible.builtin.set_fact:
|
||||
openbao_cli_install_required: >-
|
||||
{{ (openbao_cli_current_version.stdout | default('') | trim) != ('OpenBao v' ~ openbao_cli_version) }}
|
||||
|
||||
- name: Install pinned OpenBao CLI from the official release
|
||||
when: openbao_cli_install_required
|
||||
block:
|
||||
- name: Create OpenBao CLI temporary directory
|
||||
ansible.builtin.tempfile:
|
||||
state: directory
|
||||
suffix: openbao-cli
|
||||
register: openbao_cli_tmp
|
||||
|
||||
- name: Install GnuPG for mandatory checksum signature verification
|
||||
ansible.builtin.apt:
|
||||
name: gnupg
|
||||
state: present
|
||||
when: openbao_cli_verify_checksum_signature | bool
|
||||
|
||||
- name: Download official OpenBao release checksums
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ openbao_cli_release_url }}/checksums.txt"
|
||||
dest: "{{ openbao_cli_tmp.path }}/checksums.txt"
|
||||
mode: "0600"
|
||||
|
||||
- name: Download signature for official OpenBao checksums
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ openbao_cli_release_url }}/checksums.txt.gpgsig"
|
||||
dest: "{{ openbao_cli_tmp.path }}/checksums.txt.gpgsig"
|
||||
mode: "0600"
|
||||
when: openbao_cli_verify_checksum_signature | bool
|
||||
|
||||
- name: Download OpenBao signing public key
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ openbao_cli_gpg_key_url }}"
|
||||
dest: "{{ openbao_cli_tmp.path }}/openbao-gpg-key.asc"
|
||||
mode: "0600"
|
||||
when: openbao_cli_verify_checksum_signature | bool
|
||||
|
||||
- name: Create isolated GnuPG home
|
||||
ansible.builtin.file:
|
||||
path: "{{ openbao_cli_tmp.path }}/gnupg"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
when: openbao_cli_verify_checksum_signature | bool
|
||||
|
||||
- name: Import OpenBao signing key into isolated keyring
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- gpg
|
||||
- --batch
|
||||
- --homedir
|
||||
- "{{ openbao_cli_tmp.path }}/gnupg"
|
||||
- --import
|
||||
- "{{ openbao_cli_tmp.path }}/openbao-gpg-key.asc"
|
||||
register: openbao_cli_gpg_import
|
||||
changed_when: false
|
||||
when: openbao_cli_verify_checksum_signature | bool
|
||||
|
||||
- name: Read imported signing-key fingerprints
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- gpg
|
||||
- --batch
|
||||
- --homedir
|
||||
- "{{ openbao_cli_tmp.path }}/gnupg"
|
||||
- --with-colons
|
||||
- --fingerprint
|
||||
- --list-keys
|
||||
register: openbao_cli_gpg_fingerprints
|
||||
changed_when: false
|
||||
when: openbao_cli_verify_checksum_signature | bool
|
||||
|
||||
- name: Require the documented OpenBao primary key fingerprint
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- openbao_cli_gpg_fingerprints.stdout | regex_findall('(?m)^pub:') | length == 1
|
||||
- >-
|
||||
openbao_cli_gpg_fingerprints.stdout | regex_findall('(?m)^fpr:.*$') |
|
||||
map('regex_search', '[A-F0-9]{40}') |
|
||||
select('equalto', openbao_cli_gpg_primary_fingerprint) | list | length == 1
|
||||
fail_msg: The imported OpenBao signing key did not match the pinned primary fingerprint.
|
||||
when: openbao_cli_verify_checksum_signature | bool
|
||||
|
||||
- name: Verify official checksums.txt signature
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- gpg
|
||||
- --batch
|
||||
- --homedir
|
||||
- "{{ openbao_cli_tmp.path }}/gnupg"
|
||||
- --verify
|
||||
- "{{ openbao_cli_tmp.path }}/checksums.txt.gpgsig"
|
||||
- "{{ openbao_cli_tmp.path }}/checksums.txt"
|
||||
register: openbao_cli_gpg_verify
|
||||
changed_when: false
|
||||
when: openbao_cli_verify_checksum_signature | bool
|
||||
|
||||
- name: Find checksum for the requested Debian package
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- awk
|
||||
- "$2 == \"{{ openbao_cli_package_name }}\" {print $1}"
|
||||
- "{{ openbao_cli_tmp.path }}/checksums.txt"
|
||||
register: openbao_cli_expected_checksum
|
||||
changed_when: false
|
||||
|
||||
- name: Require a single valid SHA-256 checksum for the package
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- openbao_cli_expected_checksum.stdout | trim is match('^[a-fA-F0-9]{64}$')
|
||||
fail_msg: "No unique valid checksum for {{ openbao_cli_package_name }} in official release checksums."
|
||||
|
||||
- name: Download checksummed OpenBao Debian package
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ openbao_cli_release_url }}/{{ openbao_cli_package_name }}"
|
||||
dest: "{{ openbao_cli_tmp.path }}/{{ openbao_cli_package_name }}"
|
||||
checksum: "sha256:{{ openbao_cli_expected_checksum.stdout | trim }}"
|
||||
mode: "0600"
|
||||
|
||||
- name: Install OpenBao CLI Debian package
|
||||
ansible.builtin.apt:
|
||||
deb: "{{ openbao_cli_tmp.path }}/{{ openbao_cli_package_name }}"
|
||||
state: present
|
||||
always:
|
||||
- name: Remove OpenBao CLI temporary directory after success or failure
|
||||
ansible.builtin.file:
|
||||
path: "{{ openbao_cli_tmp.path }}"
|
||||
state: absent
|
||||
when: openbao_cli_tmp is defined and openbao_cli_tmp.path is defined
|
||||
|
||||
- name: Verify installed OpenBao CLI version exactly matches the pin
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- "{{ openbao_cli_binary_path }}"
|
||||
- version
|
||||
register: openbao_cli_installed_version
|
||||
changed_when: false
|
||||
failed_when: (openbao_cli_installed_version.stdout | trim) != ('OpenBao v' ~ openbao_cli_version)
|
||||
Reference in New Issue
Block a user