1
0
Fork 0
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:
Eero Aaltonen 2026-03-01 23:34:17 +02:00
parent 5ae85488a2
commit fa795788cd

View file

@ -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()