Merge "Ensure python3-hvac is installed for charms with encypt option"
This commit is contained in:
commit
76855185be
|
@ -37,7 +37,19 @@ class VaultKVContext(context.OSContextGenerator):
|
|||
)
|
||||
|
||||
def __call__(self):
|
||||
import hvac
|
||||
try:
|
||||
import hvac
|
||||
except ImportError:
|
||||
# BUG: #1862085 - if the relation is made to vault, but the
|
||||
# 'encrypt' option is not made, then the charm errors with an
|
||||
# import warning. This catches that, logs a warning, and returns
|
||||
# with an empty context.
|
||||
hookenv.log("VaultKVContext: trying to use hvac pythong module "
|
||||
"but it's not available. Is secrets-stroage relation "
|
||||
"made, but encrypt option not set?",
|
||||
level=hookenv.WARNING)
|
||||
# return an emptry context on hvac import error
|
||||
return {}
|
||||
ctxt = {}
|
||||
# NOTE(hopem): see https://bugs.launchpad.net/charm-helpers/+bug/1849323
|
||||
db = unitdata.kv()
|
||||
|
|
|
@ -259,7 +259,7 @@ def config_changed():
|
|||
def install_vaultlocker():
|
||||
"""Determine whether vaultlocker is required and install"""
|
||||
if config('encrypt'):
|
||||
pkgs = ['vaultlocker', 'python-hvac']
|
||||
pkgs = ['vaultlocker']
|
||||
installed = len(filter_installed_packages(pkgs)) == 0
|
||||
if not installed:
|
||||
apt_install(pkgs, fatal=True)
|
||||
|
|
Loading…
Reference in New Issue