Skip to content

Commit

Permalink
Fix vault ext pillar return data for KV v2
Browse files Browse the repository at this point in the history
  • Loading branch information
lkubb authored and Megan Wilhite committed Sep 26, 2022
1 parent 468ebed commit 46339d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog/62651.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed vault ext pillar return data for KV v2
17 changes: 9 additions & 8 deletions salt/pillar/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@

import logging

log = logging.getLogger(__name__)
from requests.exceptions import HTTPError

__func_alias__ = {"set_": "set"}
log = logging.getLogger(__name__)


def __virtual__():
Expand Down Expand Up @@ -162,12 +162,13 @@ def ext_pillar(

url = "v1/{}".format(path)
response = __utils__["vault.make_request"]("GET", url)
if response.status_code == 200:
vault_pillar = response.json().get("data", {})
else:
log.info("Vault secret not found for: %s", path)
except KeyError:
log.error("No such path in Vault: %s", path)
response.raise_for_status()
vault_pillar = response.json().get("data", {})

if vault_pillar and version2["v2"]:
vault_pillar = vault_pillar["data"]
except HTTPError:
log.info("Vault secret not found for: %s", path)

if nesting_key:
vault_pillar = {nesting_key: vault_pillar}
Expand Down

0 comments on commit 46339d9

Please sign in to comment.