A consumer gets a running single-node OpenBao server on integrated raft storage, listening on TLS they supply, left uninitialised and sealed. The role installs the pinned 2.7.3 release tarball, checked by get_url against the sha256 of each architecture from the release's checksums.txt (its GPG signature checks out against OpenBao's release key). It creates its own system user, data directory, configuration and sandboxed unit: Type=notify, SIGINT stop, MemorySwapMax=0 instead of mlock, an empty capability set, ProtectSystem=strict with the data directory writable, and ExecReload sending SIGHUP. The directive set was tried against the real binary under systemd before it was kept. TLS certificate, key and CA paths are required unless openbao_tls_disable is true, which warns; validation fails before any change when a file is missing, and the role checks the service user can read the key and certificate before writing the config. It reads its seal status over https://127.0.0.1 validated against the CA file, so an address other than a wildcard or loopback gets a second loopback listener. The tasks are split by job (validate, prereqs, install, configure, seal_status) so the init, unseal, audit and update work can reuse them. Refs: #536 Assisted-by: Claude Code
134 lines
5.4 KiB
YAML
134 lines
5.4 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
|
|
|
|
- name: Require a listen address, ports and node id
|
|
ansible.builtin.assert:
|
|
that:
|
|
- openbao_listen_address is string
|
|
- openbao_listen_address is match('^[0-9A-Fa-f.:]+\\Z')
|
|
- openbao_port | int(0) >= 1
|
|
- openbao_port | int(0) <= 65535
|
|
- openbao_cluster_port | int(0) >= 1
|
|
- 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_listen_address must be an IPv4 or IPv6 address (0.0.0.0 for every address); openbao_port and
|
|
openbao_cluster_port must be two different ports from 1 to 65535; 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 }}"
|
|
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)
|
|
|
|
- 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.
|
|
when: openbao_tls_disable | bool
|