This Terraform provider allows you to access secrets from an Ansible Vault from Terraform.
Made with ❤️ by MeilleursAgents
Thanks to ansible-vault-go repository for having done the hardest part.
If you have Golang installed
go install github.com/MeilleursAgents/terraform-provider-ansiblevault
mkdir -p "~/.terraform.d/plugins/$(go env GOHOSTOS)_$(go env GOHOSTARCH)/"
cp ${GOPATH}/bin/terraform-provider-ansiblevault "~/.terraform.d/plugins/$(go env GOHOSTOS)_$(go env GOHOSTARCH)/"
or
In the repository
make build
make install
PLUGIN_VERSION="1.0.1"
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
if [[ "${ARCH}" = "x86_64" ]]; then
ARCH="amd64"
fi
pushd $HOME
mkdir -p ".terraform.d/plugins/${OS}_${ARCH}/"
cd ".terraform.d/plugins/${OS}_${ARCH}/"
curl -o "terraform-provider-ansiblevault_v${PLUGIN_VERSION}" "https://github.com/MeilleursAgents/terraform-provider-ansiblevault/releases/download/v${PLUGIN_VERSION}/terraform-provider-ansiblevault_${OS}-${ARCH}_v${PLUGIN_VERSION}"
popd
ansiblevault_env example:
provider "ansiblevault" {
vault_pass = "/home/username/.vault_pass.txt"
root_folder = "/home/username/infra/ansible/"
}
data "ansiblevault_env" "api_key" {
env = "prod"
key = "SECRET_API_KEY"
}
${data.ansiblevault_env.api_key.value}
ansiblevault_path example:
provider "ansiblevault" {
vault_pass = "/home/username/.vault_pass.txt"
root_folder = "/home/username/infra/ansible/"
}
data "ansiblevault_path" "api_key" {
path = "./passwords.yml"
key = "USER_PASSWORD"
}
${data.ansiblevault_path.api_key.value}
You need following environment variables for doing a release. If not set, the release
script will ask you.
Name | Description |
---|---|
GITHUB_OAUTH_TOKEN | A Github Token with repos access |
GITHUB_REPOSITORY | The repository name for uploading assets (e.g. MeilleursAgents/terraform-provider-ansiblevault) |
GIT_TAG | The new version to release (e.g. v1.0.0) |
RELEASE_NAME | The version name (most of the time, the git tag) |
git tag "${GIT_TAG}"
GITHUB_REPOSITORY=MeilleursAgents/terraform-provider-ansiblevault ./script/release
You have to enable Go modules for compiling this project.
This project is licensed under the MIT license (see LICENSE file).