Created
September 27, 2018 10:37
-
-
Save jnahelou/2497084266d0372e752a58154d874913 to your computer and use it in GitHub Desktop.
Dump all Vault KV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use JSON -support_by_pp; | |
use Data::Dumper; | |
# Don't forget to login to vault first | |
sub rec { | |
my ($path) = @_; | |
my $json = JSON->new->pretty; | |
my $json_text = `vault list -format=json $path`; | |
my $json_object = $json->decode($json_text); | |
for my $item( @{$json_object} ){ | |
if (substr($item, -1) eq "/") { | |
#It's a folder, deep dive into | |
rec("$path$item") | |
} else { | |
#It's a key, let's read it | |
print `vault read -format=json $path$item` | |
} | |
} | |
} | |
rec("secret/"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment