diff options
| author | Michal Nasiadka <mnasiadka@gmail.com> | 2025-10-08 16:25:06 +0200 |
|---|---|---|
| committer | Michal Nasiadka <mnasiadka@gmail.com> | 2025-10-09 08:32:57 +0000 |
| commit | 00d33a38a6a41f226ae53d05d3ee4c5660ff85fc (patch) | |
| tree | a1e7af8921d11236d1dbf1dc81dcdfc8d82d0438 /tests/test-openbao-passwords.sh | |
| parent | 740147c43e986611da4357439693e08f3aee7913 (diff) | |
| download | kolla-ansible-00d33a38a6a41f226ae53d05d3ee4c5660ff85fc.tar.gz kolla-ansible-00d33a38a6a41f226ae53d05d3ee4c5660ff85fc.zip | |
CI: Rework Hashicorp Vault jobs into OpenBao
Change-Id: I1a8ebc171da8990b21f03e6d5c3da296eef92e28
Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
Diffstat (limited to 'tests/test-openbao-passwords.sh')
| -rwxr-xr-x | tests/test-openbao-passwords.sh | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/test-openbao-passwords.sh b/tests/test-openbao-passwords.sh new file mode 100755 index 000000000..5e6b115ba --- /dev/null +++ b/tests/test-openbao-passwords.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +set -o xtrace +set -o errexit + +export PYTHONUNBUFFERED=1 + +function install_openbao { + if [[ $BASE_DISTRO =~ (debian|ubuntu) ]]; then + curl -fsSLO https://github.com/openbao/openbao/releases/download/v2.4.1/bao_2.4.1_linux_amd64.deb + sudo dpkg -i bao_2.4.1_linux_amd64.deb + rm -f bao_2.4.1_linux_amd64.deb + else + sudo dnf install -y https://github.com/openbao/openbao/releases/download/v2.4.1/bao_2.4.1_linux_amd64.rpm + fi +} + +function start_openbao { + nohup bao server --dev & + # Give Vault some time to warm up + sleep 10 +} + +function test_openbao { + TOKEN=$(bao token create -address 'http://127.0.0.1:8200' -field token) + echo "${TOKEN}" | bao login -address 'http://127.0.0.1:8200' - + bao kv put -address 'http://127.0.0.1:8200' secret/foo data=bar +} + +function test_writepwd { + TOKEN=$(bao token create -address 'http://127.0.0.1:8200' -field token) + kolla-writepwd \ + --passwords /etc/kolla/passwords.yml \ + --vault-addr 'http://127.0.0.1:8200' \ + --vault-token ${TOKEN} \ + --vault-mount-point secret +} + +function test_readpwd { + TOKEN=$(bao token create -address 'http://127.0.0.1:8200' -field token) + cp etc/kolla/passwords.yml /tmp/passwords-openbao.yml + kolla-readpwd \ + --passwords /tmp/passwords-openbao.yml \ + --vault-addr 'http://127.0.0.1:8200' \ + --vault-token ${TOKEN} \ + --vault-mount-point secret +} + +function teardown { + pkill bao +} + +function test_openbao_passwords { + echo "Setting up development OpenBao server..." + source $KOLLA_ANSIBLE_VENV_PATH/bin/activate + install_openbao + start_openbao + test_openbao + echo "Write passwords to OpenBao..." + test_writepwd + echo "Read passwords from OpenBao..." + test_readpwd + echo "Cleaning up..." + teardown +} + +test_openbao_passwords |
