mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-21 20:59:10 +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:
|
||||
import pgpy
|
||||
except Exception as e:
|
||||
raise AnsibleError('PGPym~=0.6.1 must be installed to use pgp_keyring plugin') from e
|
||||
except ImportError as imp_exc:
|
||||
PGPY_IMPORT_ERROR = imp_exc
|
||||
else:
|
||||
PGPY_IMPORT_ERROR = None
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
|
@ -29,6 +31,9 @@ class ActionModule(ActionBase):
|
|||
def run(self, tmp=None, task_vars=None):
|
||||
""" 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:
|
||||
task_vars = dict()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue