Skip to content

Instantly share code, notes, and snippets.

View dlepenven's full-sized avatar

David LE PENVEN dlepenven

View GitHub Profile
@dlepenven
dlepenven / vault-ssh-ca-ansible
Created January 28, 2022 07:50 — forked from kawsark/vault-ssh-ca-ansible
Steps to setup Vault SSH CA secrets engine for use with Ansible
# 1. (Optional) Disable SSH and Key/Value secrets engine if they existed.
# NOTE: THIS WILL ERASE PREVIOUSLY CONFIGURED ENGINES AT THIS PATH
export VAULT_TOKEN=<Admin-or-Root-key>
vault secrets disable ssh
vault secrets disable kv
# 2. Enable SSH secrets engine (Client signer role) and generate a CA
vault secrets enable -path=ssh ssh
vault write -format=json ssh/config/ca generate_signing_key=true | jq -r '.data.public_key' > ./trusted-user-ca-keys.pem
@dlepenven
dlepenven / vault-jenkins-approle.md
Created January 27, 2022 11:04 — forked from kawsark/vault-jenkins-approle.md
Example Jenkins integration for Vault using AppRole and curl

Example Jenkins integration for Vault

This snippet provides an example Jenkinsfile that performs an AppRole authentication using curl utility. The objective is to allow Jenkins to Authenticate to Vault, then use a temporary token to retrieve a secret. It does not rely on a plugin and therefore offers more flexibility.

AppRole authentication relies on a ROLE_ID and SECRET_ID to login and retrieve a Vault token. There are two ways to provide the SECRET_ID to Jenkins. Both of these are expanded upon below.

  1. Pre-created SECRET_ID as a Jenkins secret. An out-of-band workflow will need to refresh the SECRET_ID periodically so Jenkins continues to perform AppRole logins successfully.
  2. Alternative AppRole design: Give Jenkins the ability to refresh the SECRET_ID by itself.

1. Pre-created Secret ID

@dlepenven
dlepenven / example-vault-admin-policy.hcl
Created January 26, 2022 15:10 — forked from kawsark/example-vault-admin-policy.hcl
An example Vault admin policy with capability to manage leses
# Allow managing leases
path "sys/leases/*"
{
capabilities = ["create", "read", "update", "delete", "list", "sudo"]
}
# Manage auth methods broadly across Vault
path "auth/*"
{
capabilities = ["create", "read", "update", "delete", "list", "sudo"]