mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Update for modules which import json.
Some do not use the json module directly so don't need import json. Some needed to fallback to simplejson with no traceback if neither was installed Fixes #1298
This commit is contained in:
parent
db051ff9d2
commit
ad0d2c1747
22 changed files with 85 additions and 37 deletions
|
@ -95,7 +95,6 @@ task:
|
||||||
sample: "TODO: include sample"
|
sample: "TODO: include sample"
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
import json
|
|
||||||
import boto
|
import boto
|
||||||
import botocore
|
import botocore
|
||||||
HAS_BOTO = True
|
HAS_BOTO = True
|
||||||
|
@ -120,7 +119,7 @@ class EcsExecManager:
|
||||||
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
|
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
|
||||||
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
|
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
|
||||||
except boto.exception.NoAuthHandlerFound, e:
|
except boto.exception.NoAuthHandlerFound, e:
|
||||||
self.module.fail_json(msg=str(e))
|
module.fail_json(msg="Can't authorize connection - "+str(e))
|
||||||
|
|
||||||
def list_tasks(self, cluster_name, service_name, status):
|
def list_tasks(self, cluster_name, service_name, status):
|
||||||
response = self.ecs.list_tasks(
|
response = self.ecs.list_tasks(
|
||||||
|
|
|
@ -93,7 +93,6 @@ taskdefinition:
|
||||||
type: dict inputs plus revision, status, taskDefinitionArn
|
type: dict inputs plus revision, status, taskDefinitionArn
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
import json
|
|
||||||
import boto
|
import boto
|
||||||
import botocore
|
import botocore
|
||||||
HAS_BOTO = True
|
HAS_BOTO = True
|
||||||
|
@ -118,7 +117,7 @@ class EcsTaskManager:
|
||||||
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
|
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
|
||||||
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
|
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
|
||||||
except boto.exception.NoAuthHandlerFound, e:
|
except boto.exception.NoAuthHandlerFound, e:
|
||||||
self.module.fail_json(msg=str(e))
|
module.fail_json(msg="Can't authorize connection - "+str(e))
|
||||||
|
|
||||||
def describe_task(self, task_name):
|
def describe_task(self, task_name):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -160,7 +160,6 @@ EXAMPLES = '''
|
||||||
|
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
import json
|
|
||||||
import boto
|
import boto
|
||||||
import botocore
|
import botocore
|
||||||
HAS_BOTO = True
|
HAS_BOTO = True
|
||||||
|
|
|
@ -130,7 +130,6 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import json
|
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
|
||||||
VALID_RULE_KEYS = ['rule_type', 'original_ip', 'original_port',
|
VALID_RULE_KEYS = ['rule_type', 'original_ip', 'original_port',
|
||||||
|
|
|
@ -190,11 +190,6 @@ EXAMPLES = '''
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import consul
|
import consul
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError
|
||||||
|
|
|
@ -122,11 +122,6 @@ EXAMPLES = '''
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import consul
|
import consul
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError
|
||||||
|
|
|
@ -100,10 +100,15 @@ EXAMPLES = '''
|
||||||
import time
|
import time
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
try:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def ring_check(module, riak_admin_bin):
|
def ring_check(module, riak_admin_bin):
|
||||||
|
|
|
@ -22,7 +22,15 @@ You should have received a copy of the GNU General Public License
|
||||||
along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
import json
|
import json
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -174,16 +174,20 @@ EXAMPLES = '''
|
||||||
sensu_check: name=check_disk_capacity state=absent
|
sensu_check: name=check_disk_capacity state=absent
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
try:
|
||||||
|
import json
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def sensu_check(module, path, name, state='present', backup=False):
|
def sensu_check(module, path, name, state='present', backup=False):
|
||||||
changed = False
|
changed = False
|
||||||
reasons = []
|
reasons = []
|
||||||
|
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
|
|
||||||
stream = None
|
stream = None
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -92,10 +92,16 @@ EXAMPLES = '''
|
||||||
# ===========================================
|
# ===========================================
|
||||||
# Stackdriver module specific support methods.
|
# Stackdriver module specific support methods.
|
||||||
#
|
#
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
try:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def send_deploy_event(module, key, revision_id, deployed_by='Ansible', deployed_to=None, repository=None):
|
def send_deploy_event(module, key, revision_id, deployed_by='Ansible', deployed_to=None, repository=None):
|
||||||
"""Send a deploy event to Stackdriver"""
|
"""Send a deploy event to Stackdriver"""
|
||||||
|
|
|
@ -64,7 +64,15 @@ EXAMPLES = '''
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
try:
|
||||||
import json
|
import json
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,12 @@ ipify_public_ip:
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
try:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class IpifyFacts(object):
|
class IpifyFacts(object):
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,12 @@ import re
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
try:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def parse_out(string):
|
def parse_out(string):
|
||||||
return re.sub("\s+", " ", string).strip()
|
return re.sub("\s+", " ", string).strip()
|
||||||
|
|
|
@ -107,7 +107,12 @@ import os
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
try:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Npm(object):
|
class Npm(object):
|
||||||
def __init__(self, module, **kwargs):
|
def __init__(self, module, **kwargs):
|
||||||
|
|
|
@ -109,7 +109,6 @@ EXAMPLES = '''
|
||||||
- pacman: name=baz state=absent force=yes
|
- pacman: name=baz state=absent force=yes
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import json
|
|
||||||
import shlex
|
import shlex
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -63,7 +63,6 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
import json
|
|
||||||
import shlex
|
import shlex
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -85,7 +85,6 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
import json
|
|
||||||
import shlex
|
import shlex
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -58,7 +58,6 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
import json
|
|
||||||
import shlex
|
import shlex
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -73,7 +73,6 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
import json
|
|
||||||
import shlex
|
import shlex
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -18,7 +18,15 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
try:
|
||||||
import json
|
import json
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
|
|
|
@ -22,7 +22,12 @@ import stat
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
try:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
|
|
@ -160,7 +160,15 @@ EXAMPLES = """
|
||||||
issue={{issue.meta.key}} operation=transition status="Done"
|
issue={{issue.meta.key}} operation=transition status="Done"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
import json
|
import json
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
def request(url, user, passwd, data=None, method=None):
|
def request(url, user, passwd, data=None, method=None):
|
||||||
|
|
Loading…
Reference in a new issue