The readability check of the TLS certificate and key ran after the role had created the user and directories and installed the binary, so a fresh host with a key the service user cannot read was changed and then failed. It now runs in validation, from the files' owner, group and mode against openbao_user and openbao_group, before anything changes; prepare proves it on the fresh host. Also from review: - a seal status read that fails names the 127.0.0.1 IP SAN and openbao_tls_ca_file instead of a raw SSL error - :: gets the loopback listener too: it reaches 127.0.0.1 only while net.ipv6.bindv6only is 0 - the listen address check rejects strings such as ... or ::: - the TLS-disabled warning is registered, and verify asserts it - a missing binary under --skip-tags install fails with a clear message - the README names openbao_user and openbao_group and says the always tagged prereqs run under --tags health too Refs: #536 Assisted-by: Claude Code
56 lines
2.5 KiB
YAML
56 lines
2.5 KiB
YAML
---
|
|
# Reads the seal status on loopback, so it depends neither on DNS nor on the listen address,
|
|
# and validates the certificate against openbao_tls_ca_file: the certificate must cover
|
|
# 127.0.0.1. The endpoint needs no token.
|
|
- name: Read the OpenBao seal status
|
|
# Under --check a new unit or binary is only simulated, so nothing listens yet.
|
|
when: not ansible_check_mode or (__openbao_unit | default({}) is not changed and __openbao_installed)
|
|
tags: [openbao, configure, health]
|
|
block:
|
|
- name: Read the seal status on loopback
|
|
become: true
|
|
ansible.builtin.uri:
|
|
url: "{{ 'http' if openbao_tls_disable | bool else 'https' }}://127.0.0.1:{{ openbao_port }}/v1/sys/seal-status"
|
|
method: GET
|
|
validate_certs: true
|
|
ca_path: "{{ omit if openbao_tls_disable | bool else openbao_tls_ca_file }}"
|
|
status_code: [200]
|
|
register: __openbao_seal_status
|
|
# The listener opens a moment after systemd reports the unit started.
|
|
until: __openbao_seal_status.status | default(0) == 200
|
|
retries: 10
|
|
delay: 2
|
|
# Read-only GET: runs in --check too.
|
|
check_mode: false
|
|
rescue:
|
|
# A raw SSL error does not say which input is wrong.
|
|
- name: Fail with the likely cause
|
|
ansible.builtin.fail:
|
|
msg: >-
|
|
OpenBao did not answer its seal status at {{ __openbao_seal_status.url | default('127.0.0.1') }}
|
|
({{ __openbao_seal_status.msg | default('no response') }}).
|
|
{{ 'Check journalctl -u openbao on the host.' if openbao_tls_disable | bool else
|
|
'The listener certificate must cover 127.0.0.1 as an IP subject alternative name and be signed by the CA in openbao_tls_ca_file ('
|
|
~ openbao_tls_ca_file ~ '); otherwise check journalctl -u openbao on the host.' }}
|
|
|
|
- name: Warn that OpenBao is not initialised
|
|
ansible.builtin.debug:
|
|
msg: >-
|
|
WARNING: OpenBao on {{ inventory_hostname }} is not initialised and stays sealed. Initialise it before use;
|
|
until then it serves no secret.
|
|
when:
|
|
- __openbao_seal_status.json is defined
|
|
- not __openbao_seal_status.json.initialized
|
|
tags: [openbao, configure, health]
|
|
|
|
- name: Warn that OpenBao is sealed
|
|
ansible.builtin.debug:
|
|
msg: >-
|
|
WARNING: OpenBao on {{ inventory_hostname }} is sealed and serves no secret until it is unsealed with the
|
|
unseal keys.
|
|
when:
|
|
- __openbao_seal_status.json is defined
|
|
- __openbao_seal_status.json.initialized
|
|
- __openbao_seal_status.json.sealed
|
|
tags: [openbao, configure, health]
|