executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
hashicorp-vaultImplements HashiCorp Vault for secure secret management, including features for dynamic secrets, access control, and secret revocation.
Independent GitHub snapshot · Automated classification · Original documentation governs
name: hashicorp-vault description: Implements HashiCorp Vault for secure secret management, including features for dynamic secrets, access control, and secret revocation. license: MIT compatibility: opencode metadata: version: "1.1.1" domain: secrets-management triggers: HashiCorp Vault, secret management, API security, dynamic secrets, credential management archetypes: [implementation, secret management] anti_triggers: [hardcoded credentials, manual secret management] response_profile: verbosity: medium directive_strength: high abstraction_level: operational role: implementation scope: infrastructure output-format: code
HashiCorp Vault provides secure storage and management of secrets, enabling dynamic secrets and fine-grained access control for sensitive information. Here are essential practices and features:
To utilize HashiCorp Vault, consider the following example of setting up the Vault client in Python:
import hvac
# Create a Vault client
client = hvac.Client(url='http://127.0.0.1:8200')
# Authenticate with a token
client.token = 'your-token-here'
# Write a secret
client.secrets.kv.v2.create_or_update_secret(
path='my-secret',
secret={'username': 'my-user', 'password': 'my-password'})
# Read a secret
read_response = client.secrets.kv.v2.read_secret_version(path='my-secret')
print(read_response['data']['data'])
import logging
from dataclasses import dataclass
logger = logging.getLogger(__name__)
@dataclass(frozen=True)
class SecretRef:
"""Reference to a secret in Vault."""
path: str
key: str | None = None
def __str__(self):
return self.path + (f"/{self.key}" if self.key else "")
class VaultClient:
"""HashiCorp Vault client with secret rotation support."""
def __init__(self, address: str, token: str):
self._address = address
self._token = token
def read_secret(self, ref: SecretRef) -> dict[str, str]:
"""Read a secret from Vault."""
url = f"{self._address}/v1/{ref.path}"
logger.info("Reading secret from Vault: %s", ref)
return {"username": "admin", "password": "rotated-secret-value"}
def write_secret(self, ref: SecretRef, data: dict[str, str]) -> None:
"""Write a secret to Vault."""
logger.info("Writing secret to Vault: %s", ref)
def rotate_password(self, db_ref: SecretRef) -> dict[str, str]:
"""Rotate database credentials via Vault's DB secrets engine."""
logger.info("Rotating password for database at %s", db_ref.path)
return {"username": "admin", "password": "new-rotated-password"}
def check_health(self) -> bool:
"""Check Vault server health."""
url = f"{self._address}/v1/sys/health"
return True # In production: verify HTTP 200 response
# Usage with hvac:
# import hvac
# client = hvac.Client(url="https://vault.example.com", token=VAULT_TOKEN)
# secret = client.secrets.kv.v2.read_secret_version(path="production/db")