Files
Kamino/roles/openbao/molecule/default/verify.yml
T
Defame1297 7511d40ff8
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
fix(openbao): follow TLS symlinks and keep :: on one listener
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
2026-12-06 22:51:40 +00:00

230 lines
9.1 KiB
YAML

---
- name: Verify the converged server
hosts: all
gather_facts: false
tasks:
- name: Ask systemd about the service
ansible.builtin.systemd_service:
name: openbao
register: openbao_test_service
- name: The service runs with the role's unit settings
ansible.builtin.assert:
that:
- openbao_test_service.status.ActiveState == 'active'
- openbao_test_service.status.UnitFileState == 'enabled'
- openbao_test_service.status.Type == 'notify'
- openbao_test_service.status.KillSignal == '2'
- openbao_test_service.status.MemorySwapMax == '0'
- openbao_test_service.status.NoNewPrivileges == 'yes'
- "'HUP' in openbao_test_service.status.ExecReload"
quiet: true
- name: Read the service account
ansible.builtin.getent:
database: passwd
key: openbao
- name: Stat the data directory and the configuration
ansible.builtin.stat:
path: "{{ openbao_test_path }}"
loop: [/var/lib/openbao, /etc/openbao/openbao.hcl]
loop_control:
loop_var: openbao_test_path
register: openbao_test_paths
- name: The service user has no shell and owns the private data directory
ansible.builtin.assert:
that:
- ansible_facts.getent_passwd.openbao[5] == '/usr/sbin/nologin'
- openbao_test_paths.results[0].stat.pw_name == 'openbao'
- openbao_test_paths.results[0].stat.mode == '0700'
- openbao_test_paths.results[1].stat.gr_name == 'openbao'
- openbao_test_paths.results[1].stat.mode == '0640'
quiet: true
- name: Ask the installed binary for its version
ansible.builtin.command:
argv: [/usr/local/bin/bao, version]
register: openbao_test_version
changed_when: false
# Over TLS on loopback, validated against the test CA: the listener serves the supplied
# certificate, and the server is left uninitialised and sealed on raft storage.
- name: Read the seal status over TLS
ansible.builtin.uri:
url: https://127.0.0.1:8200/v1/sys/seal-status
ca_path: "{{ openbao_tls_ca_file }}"
validate_certs: true
register: openbao_test_seal
- name: The pinned server answers uninitialised and sealed on raft
ansible.builtin.assert:
that:
- ('OpenBao v' ~ openbao_test_defaults.openbao_version ~ ' ') in openbao_test_version.stdout
- openbao_test_seal.json.version == openbao_test_defaults.openbao_version
- openbao_test_seal.json.storage_type == 'raft'
- not openbao_test_seal.json.initialized
- openbao_test_seal.json.sealed
quiet: true
- name: Reload the service
ansible.builtin.systemd_service:
name: openbao
state: reloaded
- name: Ask systemd about the service after the reload
ansible.builtin.systemd_service:
name: openbao
register: openbao_test_reloaded
- name: The reload signalled the running server instead of restarting it
ansible.builtin.assert:
that:
- openbao_test_reloaded.status.ActiveState == 'active'
- openbao_test_reloaded.status.MainPID == openbao_test_service.status.MainPID
quiet: true
- name: Verify the failure paths
hosts: all
gather_facts: false
tasks:
- name: Checksum the configuration before the failure cases
ansible.builtin.stat:
path: /etc/openbao/openbao.hcl
checksum_algorithm: sha256
register: openbao_test_config_before
- name: Run each case
ansible.builtin.include_tasks: tasks/failed_run.yml
loop:
- name: tls-cert-missing
vars: {openbao_tls_cert_file: ""}
expect: must be absolute paths of files on the host
- name: tls-ca-missing
vars: {openbao_tls_ca_file: ""}
expect: must be absolute paths of files on the host
- name: tls-key-absent
vars: {openbao_tls_key_file: /etc/molecule-tls/absent.key}
expect: /etc/molecule-tls/absent.key do not exist
- name: tls-key-unreadable
vars: {openbao_tls_key_file: /etc/molecule-tls/root-only.key}
expect: The user openbao could not read /etc/molecule-tls/root-only.key
# Changes nothing: the CA file is read only by the role's own seal status call.
- name: ca-not-the-signer
vars: {openbao_tls_ca_file: /etc/molecule-tls/other-ca.crt}
expect: must cover 127.0.0.1 as an IP subject alternative name
- name: tls-min-version-unknown
vars: {openbao_tls_min_version: tls10}
expect: openbao_tls_min_version must be one of
- name: version-with-v
vars: {openbao_version: v2.7.3}
expect: openbao_version must be a release version
- name: sha256-not-hex
vars: {openbao_sha256: {amd64: not-a-hash, arm64: not-a-hash}}
expect: openbao_sha256 must map
- name: bin-path-not-bao
vars: {openbao_bin_path: /usr/local/bin/openbao}
expect: the file name of openbao_bin_path must be bao
- name: listen-address-hostname
vars: {openbao_listen_address: localhost}
expect: openbao_listen_address must be an IPv4 or IPv6 address
- name: listen-address-dots
vars: {openbao_listen_address: "..."}
expect: openbao_listen_address must be an IPv4 or IPv6 address
- name: listen-address-triple-colon
vars: {openbao_listen_address: ":::"}
expect: openbao_listen_address must be an IPv4 or IPv6 address
- name: port-privileged
vars: {openbao_port: 443}
expect: must be two different ports from 1024 to 65535
- name: ports-equal
vars: {openbao_cluster_port: 8200}
expect: must be two different ports
- name: node-id-with-space
vars: {openbao_node_id: "node one"}
expect: openbao_node_id must be letters
- name: cluster-addr-plain-http
vars: {openbao_cluster_addr: "http://127.0.0.1:8201"}
expect: openbao_cluster_addr an https:// URL
loop_control:
loop_var: openbao_test_case
label: "{{ openbao_test_case.name }}"
# Not a failure: the installed binary stays, and the role says so.
- name: Run the role with another openbao_version
ansible.builtin.include_role:
name: mortis.kamino.openbao
vars:
openbao_version: 2.7.2
- name: The role warned that it keeps the installed version
ansible.builtin.assert:
that:
- "'not openbao_version 2.7.2' in hostvars[inventory_hostname].__openbao_version_warning.msg"
- "('OpenBao v' ~ openbao_test_defaults.openbao_version) in hostvars[inventory_hostname].__openbao_version_warning.msg"
quiet: true
- name: Checksum the configuration after the failure cases
ansible.builtin.stat:
path: /etc/openbao/openbao.hcl
checksum_algorithm: sha256
register: openbao_test_config_after
- name: Ask systemd about the service after the failure cases
ansible.builtin.systemd_service:
name: openbao
register: openbao_test_after_failures
- name: The failures changed nothing and the server still runs
ansible.builtin.assert:
that:
- openbao_test_config_after.stat.checksum == openbao_test_config_before.stat.checksum
- openbao_test_after_failures.status.ActiveState == 'active'
- openbao_test_after_failures.status.MainPID == openbao_test_reloaded.status.MainPID
quiet: true
# Runs last: it rewrites the configuration and restarts the server, then the TLS run restores it.
- name: Verify the TLS switch
hosts: all
gather_facts: false
tasks:
- name: Run the role with TLS disabled and no TLS input
ansible.builtin.include_role:
name: mortis.kamino.openbao
vars:
openbao_tls_disable: true
openbao_tls_cert_file: ""
openbao_tls_key_file: ""
openbao_tls_ca_file: ""
# The role registers the warning it gave; the next run replaces it.
- name: Keep the warning of the plain HTTP run
ansible.builtin.set_fact:
openbao_test_plain_warning: "{{ hostvars[inventory_hostname].__openbao_tls_warning }}"
- name: Read the seal status over plain HTTP
ansible.builtin.uri:
url: http://127.0.0.1:8200/v1/sys/seal-status
register: openbao_test_plain
- name: Run the role with the scenario's TLS inputs again
ansible.builtin.include_role:
name: mortis.kamino.openbao
- name: Read the seal status over TLS again
ansible.builtin.uri:
url: https://127.0.0.1:8200/v1/sys/seal-status
ca_path: "{{ openbao_tls_ca_file }}"
validate_certs: true
register: openbao_test_tls_again
- name: The switch warned, served plain HTTP, and TLS came back without the warning
ansible.builtin.assert:
that:
- "'openbao_tls_disable is true' in openbao_test_plain_warning.msg"
- openbao_test_plain.json.sealed
- openbao_test_tls_again.json.sealed
- hostvars[inventory_hostname].__openbao_tls_warning is skipped
quiet: true