Build / build (pull_request) Successful in 21s
Lint / renovate-config (pull_request) Successful in 4s
Molecule / select (pull_request) Successful in 3s
Lint / lint (pull_request) Successful in 5m20s
Molecule / scenarios (pull_request) Successful in 37m31s
Molecule / Result (pull_request) Successful in 1s
Go opens a :: listener dual-stack, so it already serves 127.0.0.1 and a second loopback listener failed to bind with "address already in use". :: again gets no loopback listener. The TLS file checks did not follow symlinks, so a certbot-style live/ path was refused as not a regular file; the stat now follows them, and the scenario reaches its certificate and key through symlinks. Also: - an owner or group with no name gives the readability message, not a templating error - openbao_port and openbao_cluster_port must be 1024 or higher: the unit grants no capability to bind a lower port - SystemCallErrorNumber=EPERM, so a filtered syscall fails instead of killing the server with SIGSYS - a warning when the installed binary differs from openbao_version, since main does not change an installed binary - the TLS file inputs are type path in the argument spec Refs: #536 Assisted-by: Claude Code
180 lines
7.8 KiB
YAML
180 lines
7.8 KiB
YAML
---
|
|
# Input checks. Imported first in main.yml with tags: always, so a bad input fails before any
|
|
# change, whatever tags the run selects.
|
|
- name: Require a plain openbao_version
|
|
ansible.builtin.assert:
|
|
that:
|
|
- openbao_version is string
|
|
- openbao_version is match('^[0-9]+\\.[0-9]+\\.[0-9]+\\Z')
|
|
fail_msg: >-
|
|
openbao_version must be a release version such as 2.7.3, with no leading v: it is used in the
|
|
download URL.
|
|
quiet: true
|
|
|
|
- name: Require a supported architecture
|
|
ansible.builtin.assert:
|
|
that: __openbao_arch in ['amd64', 'arm64']
|
|
fail_msg: >-
|
|
OpenBao release tarballs are installed for amd64 and arm64 only; this host reports
|
|
{{ ansible_facts.architecture }}.
|
|
quiet: true
|
|
|
|
- name: Require a sha256 for this architecture
|
|
ansible.builtin.assert:
|
|
that:
|
|
- openbao_sha256 is mapping
|
|
- openbao_sha256[__openbao_arch] | default('') is string
|
|
- openbao_sha256[__openbao_arch] | default('') is match('^[0-9a-fA-F]{64}\\Z')
|
|
fail_msg: >-
|
|
openbao_sha256 must map {{ __openbao_arch }} to the 64-digit hex sha256 of
|
|
openbao_{{ openbao_version }}_linux_{{ __openbao_arch }}.tar.gz, as listed in the release's checksums.txt.
|
|
quiet: true
|
|
|
|
# The values land in the systemd unit and in file paths: a newline or % would inject or expand
|
|
# unit directives, and a space would split ReadWritePaths.
|
|
- name: Require plain service account names and absolute paths
|
|
ansible.builtin.assert:
|
|
that:
|
|
- openbao_user is string
|
|
- openbao_group is string
|
|
- openbao_bin_path is string
|
|
- openbao_config_dir is string
|
|
- openbao_data_dir is string
|
|
- (openbao_user ~ openbao_group ~ openbao_bin_path ~ openbao_config_dir ~ openbao_data_dir) is not search('[\\s%]')
|
|
- openbao_bin_path is match('/')
|
|
- openbao_bin_path | basename == 'bao'
|
|
- openbao_config_dir is match('/')
|
|
- openbao_data_dir is match('/')
|
|
fail_msg: >-
|
|
openbao_user, openbao_group, openbao_bin_path, openbao_config_dir and openbao_data_dir must not contain
|
|
whitespace or %; the three paths must be absolute, and the file name of openbao_bin_path must be bao.
|
|
quiet: true
|
|
|
|
# Without a Collection dependency for an IP test: a dotted quad, or IPv6 in full or with one ::
|
|
# (no embedded IPv4), at most 8 groups in full form and 7 around a ::.
|
|
- name: Require an IP listen address
|
|
ansible.builtin.assert:
|
|
that:
|
|
- openbao_listen_address is string
|
|
- >-
|
|
openbao_listen_address is match(__openbao_ipv4_pattern)
|
|
or (openbao_listen_address is match(__openbao_ipv6_pattern)
|
|
and openbao_listen_address.split(':') | select | list | length
|
|
<= (7 if '::' in openbao_listen_address else 8))
|
|
fail_msg: >-
|
|
openbao_listen_address must be an IPv4 or IPv6 address (0.0.0.0 for every address), such as 192.0.2.10 or
|
|
2001:db8::10, with no brackets or port.
|
|
quiet: true
|
|
vars:
|
|
__openbao_octet: '(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])'
|
|
__openbao_ipv4_pattern: '^({{ __openbao_octet }}\.){3}{{ __openbao_octet }}\Z'
|
|
__openbao_hex: '[0-9A-Fa-f]{1,4}'
|
|
__openbao_ipv6_pattern: >-
|
|
^(({{ __openbao_hex }}:){7}{{ __openbao_hex }}|(({{ __openbao_hex }}:){0,6}{{ __openbao_hex }})?::(({{
|
|
__openbao_hex }}:){0,6}{{ __openbao_hex }})?)\Z
|
|
|
|
- name: Require ports and a node id
|
|
ansible.builtin.assert:
|
|
that:
|
|
- openbao_port | int(0) >= 1024
|
|
- openbao_port | int(0) <= 65535
|
|
- openbao_cluster_port | int(0) >= 1024
|
|
- openbao_cluster_port | int(0) <= 65535
|
|
- openbao_port | int != openbao_cluster_port | int
|
|
- openbao_node_id is string
|
|
- openbao_node_id is match('^[A-Za-z0-9._-]+\\Z')
|
|
fail_msg: >-
|
|
openbao_port and openbao_cluster_port must be two different ports from 1024 to 65535 (the unit grants no
|
|
capability to bind a lower one); openbao_node_id must be letters, digits, dots, hyphens or underscores.
|
|
quiet: true
|
|
|
|
- name: Require API and cluster addresses
|
|
ansible.builtin.assert:
|
|
that:
|
|
- openbao_api_addr is string
|
|
- openbao_api_addr is match('^https?://[^\\s"]+\\Z')
|
|
- openbao_cluster_addr is string
|
|
- openbao_cluster_addr is match('^https://[^\\s"]+\\Z')
|
|
fail_msg: >-
|
|
openbao_api_addr must be an http:// or https:// URL and openbao_cluster_addr an https:// URL (cluster
|
|
traffic is always TLS), with no whitespace or quote.
|
|
quiet: true
|
|
|
|
- name: Require the TLS files unless TLS is disabled
|
|
ansible.builtin.assert:
|
|
that:
|
|
- openbao_tls_cert_file is string
|
|
- openbao_tls_key_file is string
|
|
- openbao_tls_ca_file is string
|
|
- openbao_tls_cert_file is match('/')
|
|
- openbao_tls_key_file is match('/')
|
|
- openbao_tls_ca_file is match('/')
|
|
fail_msg: >-
|
|
openbao_tls_cert_file, openbao_tls_key_file and openbao_tls_ca_file must be absolute paths of files on the
|
|
host: the role does not create key material. Set them, or set openbao_tls_disable to true to serve plain
|
|
HTTP.
|
|
quiet: true
|
|
when: not (openbao_tls_disable | bool)
|
|
|
|
- name: Stat the TLS files
|
|
become: true
|
|
ansible.builtin.stat:
|
|
path: "{{ __openbao_tls_file }}"
|
|
# A certbot-style live/ path is a symlink; the server reads the file behind it.
|
|
follow: true
|
|
loop:
|
|
- "{{ openbao_tls_cert_file }}"
|
|
- "{{ openbao_tls_key_file }}"
|
|
- "{{ openbao_tls_ca_file }}"
|
|
loop_control:
|
|
loop_var: __openbao_tls_file
|
|
register: __openbao_tls_stat
|
|
# Read-only: runs in --check too, so a missing file is caught in the preview.
|
|
check_mode: false
|
|
when: not (openbao_tls_disable | bool)
|
|
|
|
- name: Require the TLS files to exist
|
|
ansible.builtin.assert:
|
|
that: __openbao_tls_missing | length == 0
|
|
fail_msg: >-
|
|
The TLS file(s) {{ __openbao_tls_missing | join(', ') }} do not exist or are not regular files on the host.
|
|
Deploy the certificate, key and CA file before running the role.
|
|
quiet: true
|
|
vars:
|
|
__openbao_tls_missing: >-
|
|
{{ __openbao_tls_stat.results | rejectattr('stat.exists') | map(attribute='__openbao_tls_file') | list
|
|
+ __openbao_tls_stat.results | selectattr('stat.exists') | rejectattr('stat.isreg')
|
|
| map(attribute='__openbao_tls_file') | list }}
|
|
when: not (openbao_tls_disable | bool)
|
|
|
|
# From the permission bits, because the service user may not exist yet: the server refuses to
|
|
# start without its certificate and key, and this fails before the role changes anything. The
|
|
# directories above the files are not checked.
|
|
- name: Require the certificate and key to be readable by the service user
|
|
ansible.builtin.assert:
|
|
that: >-
|
|
__openbao_mode[2] in '4567'
|
|
or (__openbao_tls_item.stat.gr_name | default('') == openbao_group and __openbao_mode[1] in '4567')
|
|
or (__openbao_tls_item.stat.pw_name | default('') == openbao_user and __openbao_mode[0] in '4567')
|
|
fail_msg: >-
|
|
The user {{ openbao_user }} could not read {{ __openbao_tls_item.__openbao_tls_file }}. Create the
|
|
{{ openbao_group }} system group before the role runs and give it the file (for example
|
|
root:{{ openbao_group }}, mode 0640), or make the file readable by everyone (a certificate, not a key).
|
|
quiet: true
|
|
vars:
|
|
__openbao_mode: "{{ __openbao_tls_item.stat.mode[-3:] }}"
|
|
loop: "{{ (__openbao_tls_stat.results | default([]))[:2] }}"
|
|
loop_control:
|
|
loop_var: __openbao_tls_item
|
|
label: "{{ __openbao_tls_item.__openbao_tls_file }}"
|
|
when: not (openbao_tls_disable | bool)
|
|
|
|
- name: Warn that TLS is disabled
|
|
ansible.builtin.debug:
|
|
msg: >-
|
|
WARNING: openbao_tls_disable is true, so OpenBao serves plain HTTP: tokens and secrets cross the network
|
|
unencrypted. Use it only behind a listener address no one else can reach.
|
|
# Registered so a caller (and the scenario) can see whether the warning was given.
|
|
register: __openbao_tls_warning
|
|
when: openbao_tls_disable | bool
|