Hashicorp Vault - Get Vault Leader Status using Python hvac
by
Jeremy Canfield |
Updated: April 15 2024
| Hashicorp Vault articles
This assumes you are familiar with the Python hvac client. If not, check out my article Hashicorp Vault - Getting Started with Python hvac.
This assumes the following has already been done.
- Hashicorp Vault has been installed
- Hashicorp Vault has been initialized
- Hashicorp Vault has been unsealed
Here is how you can login to the vault using Python hvac approle.
Check out my article Hashicorp Vault - Error Handling using Python hvac for details on how to include Error Handling.
#!/usr/bin/python3
import hvac
client = hvac.Client(url='http://vault.example.com:8200')
response = client.sys.read_leader_status()
for key in response :
print(f"{key} = {response [key]}")
Something like this should be returned.
ha_enabled = True
is_self = True
active_time = 2024-02-28T16:05:50.595461064Z
leader_address = http://10.11.12.13:8200
leader_cluster_address = https://10.11.12.13:8201
performance_standby = False
performance_standby_last_remote_wal = 0
last_wal = 7943623
raft_committed_index = 24855834
raft_applied_index = 24855834
Did you find this article helpful?
If so, consider buying me a coffee over at