Skip to content

Instantly share code, notes, and snippets.

@dbalduini
Last active April 26, 2019 13:27
Show Gist options
  • Save dbalduini/919de4ee99f21e60ae2e23b440772b72 to your computer and use it in GitHub Desktop.
Save dbalduini/919de4ee99f21e60ae2e23b440772b72 to your computer and use it in GitHub Desktop.
Ansible vault in docker
param (
[switch]$Decrypt = $false,
[switch]$Encrypt = $false,
[string]$Path
)
$Dir = $(pwd)
$Target = "/tmp"
$Image = "<my-image-with-ansible>"
$C = "view"
if ($Decrypt) {
$C = "decrypt"
} elseif ($Encrypt) {
$C = "encrypt"
}
$Path = $Path.replace("\", "/")
write-output "> ansible-vault $C $Path"
docker run --rm -it --entrypoint ansible-vault -w "/tmp" -v "${Dir}:${Target}" ${Image} $C $Path
@dbalduini
Copy link
Author

Usage:

ansible-vault.ps1 -Path "vault.yml" -Encrypt

 ansible-vault.ps1 -Path "vault.yml" -Decrypt

 ansible-vault.ps1 -Path "vault.yml"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment