Installation and Activation¶
Inventory Variables¶
To enable Vault, CredentialAPI, and Portal Credential, add the following variables to your Ansible inventory:
# Enable CredentialAPI
CREDENTIAL_ENABLED: true
# IP restriction on the portal (optional)
CREDENTIAL_PORTAL_RESTRICT_IP:
- name: siteA
ip: 1.1.1.1
- name: siteB
ip: 192.168.1.0/24
# Enable Vault
VAULT_ENABLED: true
# Vault storage mode
# - "file" : single-node (recommended for dev/small infrastructures)
# - "raft" : HA cluster (recommended for prod, requires >=3 manager nodes)
VAULT_MODE: file
# Unseal mode
# - "manual" : unseal via init.json keys (default)
# - "transit" : auto-unseal via another Vault
# - "awskms" : auto-unseal via AWS KMS
VAULT_UNSEAL_MODE: manual
# Number of Shamir keys generated at init
VAULT_KEY_SHARES: 5
# Number of keys required to unseal
VAULT_KEY_THRESHOLD: 3
Automatic Password Rotation (Optional)¶
For Vault to regularly change the passwords of Active Directory, LDAP, or Linux (SSH) accounts, install the selfrotate plugin in OpenBao. Each account changes its own password with its own credentials: Vault keeps no privileged account. The principle is described in Active Directory, LDAP, and SSH password rotation.
Before deploying, prepare each target type:
Active Directory: the domain controller is reachable on port 636 (LDAPS), with no clear-text LDAP, and you have its certificate.
OpenLDAP: the server is reachable on port 636 (LDAPS), or on port 389 with StartTLS, and you have its certificate.
SSH: the server is reachable on port 22 or on the port you define, and its
sshdacceptsPasswordAuthentication yes, orKbdInteractiveAuthentication yeswithauth_method: "keyboard-interactive". You have the host key (ssh-keyscan -t ed25519 <host>), and the account is a local account with a real shell.
Also check the password policy of the target accounts, to know the minimum password age: with a minimum age of 0 days, the account can change its password several times in a row; with 1 day, it must wait 24 hours. The rotation interval must exceed this minimum age.
Add the following variables to your inventory, then redeploy Vault. Only the target types you use need to be filled in.
# Enables installation, registration, and mounting of the plugin
# (selfrotate/ engine)
VAULT_SELFROTATE_ENABLED: true
# Active Directory targets
VAULT_SELFROTATE_AD_TARGETS:
# Target name, to select in the credential form
- name: ""
# Domain controller(s), LDAPS only,
# several URLs separated by commas
url: ""
# DNS name of the domain, in uppercase
realm: ""
# Minimum password age to assume when a fine-grained password
# policy (PSO) applies to the account but the account
# cannot read it
pso_min_pwd_age: "0s"
# Certificate authority of the domain controllers (PEM),
# pinned: no other certificate is accepted
certificate: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
# Optional: domain controller to use first;
# otherwise the plugin looks for the PDC emulator
# preferred_dc: ""
# Optional: kpasswd server (expired passwords),
# defaults to the domain controller in use
# kdc: ""
# LDAP / OpenLDAP targets
VAULT_SELFROTATE_LDAP_TARGETS:
# Target name, to select in the credential form
- name: ""
# Server(s) using ldaps://, or ldap:// with mandatory StartTLS;
# writable servers only
url: "ldaps://<server>:636"
# Certificate authority of the directory (PEM), pinned
certificate: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
# Accounts base: bind with <userattr>=<username>,<userdn>
# (otherwise, the DN is set on each credential)
userdn: "ou=people,dc=<domain>"
# Minimum password age, if the account cannot read the
# directory policy
min_pwd_age: "0s"
# Optional: RDN attribute of accounts under userdn (default: uid)
# userattr: "uid"
# SSH targets (Linux accounts)
VAULT_SELFROTATE_SSH_TARGETS:
# Target name, to select in the credential form
# (the hostname can also serve as the target)
- name: ""
# Server name or IP address, without the port
host: ""
# Pinned host key (line from ssh-keyscan): no password is sent
# if the server presents a different key
host_key: ""
# Optional: SSH port (default: 22)
# port: 22
# Optional: password (default) or keyboard-interactive
# if sshd refuses PasswordAuthentication
# auth_method: "password"
# Optional: minimum age (chage -m), if neither chage -l nor
# passwd -S can be read by the account
# min_pwd_age: "0s"
Important
Certificates and the host key are pinned: if the directory or the SSH server changes its certificate or key, rotation fails until the inventory is updated and the playbook is run again.
When the internal Vault is deployed, the plugin binary is retrieved from git.
Targets cannot be managed from the portal: to add or change one, edit the inventory and run the Ansible playbook again. Once the deployment is complete, the declared targets are offered in the credential creation form (see Enable Automatic Password Rotation).
init.json file path¶
The init.json file (generated by Vault on first startup) is stored on the Ansible machine. Its default path is:
VAULT_INIT_FILE: "{{ playbook_dir }}/secrets/{{ INSTANCE_NAME }}/vault/init.json"
You can override this path in your inventory if needed.
First Deployment¶
On a fresh machine, run the full playbook:
ansible-playbook -i inventory.yml playbook/reemo-infra.yml
The playbook will:
Install/configure Docker and Swarm
Generate the Reemo PKI (CA + client/server certificates)
Deploy the Vault containers
Initialize Vault automatically (first run only)
Display the contents of init.json in the console output
Save
init.jsonon the Ansible runnerAutomatically unseal replicas
Create the CredentialAPI token in Vault (stored as Docker secret)
Deploy CredentialAPI, Portal Credential, and other services
init.json contents¶
The init.json file contains the critical elements for accessing Vault:
{
"unseal_keys_b64": ["PUYWLruPMgw...", "OuhJ7B5hXr...", "TiQpJiv...", "8ZJ8sYM...", "Hb5xNyO..."],
"unseal_keys_hex": ["3d46162ebb8f...", "3ae849ec1e61...", "4e242a262bfc...", "f1927cb1830c...", "1dbe7136e30f..."],
"unseal_shares": 5,
"unseal_threshold": 3,
"root_token": "hvs.xxxxxxxxxxxxxxx"
}
unseal_keys_b64 / unseal_keys_hex: the 5 Shamir keys, in two equivalent formats (base64 and hexadecimal). By default 3 out of 5 are required to unseal Vault after each restart.
root_token: the full Vault admin token. Keep it secure, even though in practice you will no longer need it after the initial bootstrap.
Warning
This file is irreplaceable. Vault CANNOT regenerate it. If you lose it and Vault restarts, you permanently lose access to all your secrets.
Required action after the first run¶
At the end of the first run, you must immediately:
Back up the init.json file to a secure location (password manager, safe, encrypted offline backup).
Encrypt the local file with ansible-vault (see below).
Securing with ansible-vault¶
ansible-vault encrypts files at rest; the playbook decrypts them automatically at runtime.
Initial encryption¶
Immediately after the first run, encrypt the file:
ansible-vault encrypt playbooks/secrets/reemo/vault/init.json
Ansible prompts for a strong passphrase (which should also be saved in your password manager).
Note
The passphrase is different from the contents of init.json. Save both: the contents of init.json AND the ansible-vault passphrase.
Viewing and editing¶
ansible-vault view playbooks/secrets/reemo/vault/init.json
ansible-vault edit playbooks/secrets/reemo/vault/init.json
ansible-vault decrypt playbooks/secrets/reemo/vault/init.json
view: read-onlyedit: temporary edit, re-encrypted on savedecrypt: permanent decryption — avoid
Providing the passphrase to the playbook¶
Three options:
Interactive prompt:
ansible-playbook -i inv playbook/reemo-infra.yml --ask-vault-pass
Passphrase file:
echo "my_passphrase" > ~/.ansible-vault-pass chmod 600 ~/.ansible-vault-pass
Then during the run:
ansible-playbook -i inv playbook/reemo-infra.yml --vault-password-file ~/.ansible-vault-pass
Global config in ansible.cfg:
[defaults] vault_password_file = ~/.ansible-vault-pass