mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-22 05:09:12 +00:00
fixup handle import errors as instructed in devguide
https://docs.ansible.com/projects/ansible-core/devel/dev_guide/testing/sanity/import.html#in-plugins
This commit is contained in:
parent
5ae85488a2
commit
fa795788cd
1 changed files with 7 additions and 2 deletions
|
|
@ -18,8 +18,10 @@ from ansible.plugins.action import ActionBase
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pgpy
|
import pgpy
|
||||||
except Exception as e:
|
except ImportError as imp_exc:
|
||||||
raise AnsibleError('PGPym~=0.6.1 must be installed to use pgp_keyring plugin') from e
|
PGPY_IMPORT_ERROR = imp_exc
|
||||||
|
else:
|
||||||
|
PGPY_IMPORT_ERROR = None
|
||||||
|
|
||||||
|
|
||||||
class ActionModule(ActionBase):
|
class ActionModule(ActionBase):
|
||||||
|
|
@ -29,6 +31,9 @@ class ActionModule(ActionBase):
|
||||||
def run(self, tmp=None, task_vars=None):
|
def run(self, tmp=None, task_vars=None):
|
||||||
""" Install PGP keyrings in binary format """
|
""" Install PGP keyrings in binary format """
|
||||||
|
|
||||||
|
if PGPY_IMPORT_ERROR:
|
||||||
|
raise AnsibleError('PGPym~=0.6.1 must be installed to use pgp_keyring plugin') from PGPY_IMPORT_ERROR
|
||||||
|
|
||||||
if task_vars is None:
|
if task_vars is None:
|
||||||
task_vars = dict()
|
task_vars = dict()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue