Using module.fail_json(msg=missing_required_lib('requests')) format

* testing with new fail

* Updating all modules with `missing_required_lib`

* Fixing indentation

Co-authored-by: Ishan Jain <ishan.jain@gmail.com>
This commit is contained in:
Ishan Jain 2022-11-01 12:30:40 +05:30 committed by GitHub
parent 14659d6caf
commit 993776a3a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 16 deletions

View File

@ -123,7 +123,7 @@ output:
sample: email sample: email
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
try: try:
import requests import requests
HAS_REQUESTS = True HAS_REQUESTS = True
@ -213,7 +213,7 @@ def main():
) )
if not HAS_REQUESTS: if not HAS_REQUESTS:
module.fail_json("Missing package - `request` ") module.fail_json(msg=missing_required_lib('requests'))
is_error, has_changed, result = choice_map.get( is_error, has_changed, result = choice_map.get(
module.params['state'])(module) module.params['state'])(module)

View File

@ -161,7 +161,7 @@ output:
] ]
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
try: try:
import requests import requests
HAS_REQUESTS = True HAS_REQUESTS = True
@ -208,7 +208,7 @@ def main():
module = AnsibleModule(argument_spec=module_args) module = AnsibleModule(argument_spec=module_args)
if not HAS_REQUESTS: if not HAS_REQUESTS:
module.fail_json("Missing package - `request` ") module.fail_json(msg=missing_required_lib('requests'))
is_error, has_changed, result = alert_notification_policy(module) is_error, has_changed, result = alert_notification_policy(module)

View File

@ -71,7 +71,7 @@ EXAMPLES = '''
state: absent state: absent
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
try: try:
import requests import requests
HAS_REQUESTS = True HAS_REQUESTS = True
@ -132,7 +132,7 @@ def main():
) )
if not HAS_REQUESTS: if not HAS_REQUESTS:
module.fail_json("Missing package - `request` ") module.fail_json(msg=missing_required_lib('requests'))
is_error, has_changed, result = choice_map.get( is_error, has_changed, result = choice_map.get(
module.params['state'])(module) module.params['state'])(module)

View File

@ -92,7 +92,7 @@ RETURN = r'''
sample: "grafana-github-datasource" sample: "grafana-github-datasource"
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
try: try:
import requests import requests
HAS_REQUESTS = True HAS_REQUESTS = True
@ -156,7 +156,7 @@ def main():
) )
if not HAS_REQUESTS: if not HAS_REQUESTS:
module.fail_json("Missing package - `request` ") module.fail_json(msg=missing_required_lib('requests'))
is_error, has_changed, result = choice_map.get( is_error, has_changed, result = choice_map.get(
module.params['state'])(module) module.params['state'])(module)

View File

@ -125,7 +125,7 @@ RETURN = r'''
sample: "https://stackname.grafana.net" sample: "https://stackname.grafana.net"
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
try: try:
import requests import requests
HAS_REQUESTS = True HAS_REQUESTS = True
@ -199,7 +199,7 @@ def main():
) )
if not HAS_REQUESTS: if not HAS_REQUESTS:
module.fail_json("Missing package - `request` ") module.fail_json(msg=missing_required_lib('requests'))
is_error, has_changed, result = choice_map.get( is_error, has_changed, result = choice_map.get(
module.params['state'])(module) module.params['state'])(module)

View File

@ -106,7 +106,7 @@ output:
sample: "Ansible Integration Test" sample: "Ansible Integration Test"
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
try: try:
import requests import requests
HAS_REQUESTS = True HAS_REQUESTS = True
@ -162,7 +162,7 @@ def main():
) )
if not HAS_REQUESTS: if not HAS_REQUESTS:
module.fail_json("Missing package - `request` ") module.fail_json(msg=missing_required_lib('requests'))
is_error, has_changed, result = choice_map.get( is_error, has_changed, result = choice_map.get(
module.params['state'])(module) module.params['state'])(module)

View File

@ -107,7 +107,7 @@ output:
sample: "Datasource added" sample: "Datasource added"
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
try: try:
import requests import requests
HAS_REQUESTS = True HAS_REQUESTS = True
@ -171,7 +171,7 @@ def main():
) )
if not HAS_REQUESTS: if not HAS_REQUESTS:
module.fail_json("Missing package - `request` ") module.fail_json(msg=missing_required_lib('requests'))
is_error, has_changed, result = choice_map.get( is_error, has_changed, result = choice_map.get(
module.params['state'])(module) module.params['state'])(module)

View File

@ -154,7 +154,7 @@ output:
sample: "Folder foldername deleted" sample: "Folder foldername deleted"
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
try: try:
import requests import requests
HAS_REQUESTS = True HAS_REQUESTS = True
@ -226,7 +226,7 @@ def main():
) )
if not HAS_REQUESTS: if not HAS_REQUESTS:
module.fail_json("Missing package - `request` ") module.fail_json(msg=missing_required_lib('requests'))
is_error, has_changed, result = choice_map.get( is_error, has_changed, result = choice_map.get(
module.params['state'])(module) module.params['state'])(module)