mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -07:00
start getting modules to use shared import error code (#51787)
This commit is contained in:
parent
0924a8cf67
commit
0f0d33a954
46 changed files with 230 additions and 108 deletions
|
@ -72,13 +72,16 @@ old_value:
|
|||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
try:
|
||||
import etcd3
|
||||
etcd_found = True
|
||||
HAS_ETCD = True
|
||||
except ImportError:
|
||||
etcd_found = False
|
||||
ETCD_IMP_ERR = traceback.format_exc()
|
||||
HAS_ETCD = False
|
||||
|
||||
|
||||
def run_module():
|
||||
|
@ -112,8 +115,8 @@ def run_module():
|
|||
|
||||
result['key'] = module.params.get('key')
|
||||
|
||||
if not etcd_found:
|
||||
module.fail_json(msg="the python etcd3 module is required")
|
||||
if not HAS_ETCD:
|
||||
module.fail_json(msg=missing_required_lib('etcd3'), exception=ETCD_IMP_ERR)
|
||||
|
||||
allowed_keys = ['host', 'port', 'ca_cert', 'cert_key', 'cert_cert',
|
||||
'timeout', 'user', 'password']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue