Skip to content

Commit

Permalink
Merge pull request #40 from con-f-use/remove_write_secrets.py
Browse files Browse the repository at this point in the history
replace write_secrets.py by shell code
  • Loading branch information
rvem authored May 3, 2024
2 parents 7fc8271 + f85620b commit 8ee4b3e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 39 deletions.
8 changes: 5 additions & 3 deletions modules/script.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ in
json_dump="$(vault kv get -format=json "${cfg.vaultPrefix}/${name}/${secretsKey}" || true)"
if [[ -n "$json_dump" ]]; then
echo "Found secrets at ${cfg.vaultPrefix}/${name}/${secretsKey}" >&2
# call a python script which saves secrets to files in `secretsPath` directory
${../scripts/write_secrets.py} ${optionalString secretsAreBase64 "--base64"} ${lib.escapeShellArg secretsPath} <<< "$json_dump"
jq --raw-output0 '.data.data | to_entries | .[] | "name=" + (.key | @sh) + ";value=" + (.value | @sh)' <<< "$json_dump" |
while IFS= read -rd "" line; do
eval "$line"
cat <<< "$value" ${optionalString secretsAreBase64 " | base64 -d "} > "${secretsPath}/$name"
done
fi
'' + optionalString (environmentKey != null) ''
json_dump="$(vault kv get -format=json "${cfg.vaultPrefix}/${name}/${environmentKey}" || true)"
if [[ -n "$json_dump" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion modules/vault-secrets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ in
config = {
systemd.services = mkMerge ([(flip mapAttrs' cfg.secrets (
name: scfg: nameValuePair "${name}-secrets" {
path = with pkgs; [ getent jq vault-bin python3 ];
path = with pkgs; [ coreutils getent jq vault-bin ];

partOf = map (n: "${n}.service") scfg.services;
wantedBy = optional (scfg.services == []) "multi-user.target" ;
Expand Down
35 changes: 0 additions & 35 deletions scripts/write_secrets.py

This file was deleted.

0 comments on commit 8ee4b3e

Please sign in to comment.