mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Update validate-modules (#20932)
* Update validate-modules * Validates ANSIBLE_METADATA * Ensures imports happen after documentation vars * Some pep8 cleanup * Clean up some left over unneeded code * Update modules for new module guidelines and validate-modules checks * Update imports for ec2_vpc_route_table and ec2_vpc_nat_gateway
This commit is contained in:
@@ -22,13 +22,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Import Datadog
|
||||
try:
|
||||
from datadog import initialize, api
|
||||
HAS_DATADOG = True
|
||||
except:
|
||||
HAS_DATADOG = False
|
||||
|
||||
ANSIBLE_METADATA = {'status': ['preview'],
|
||||
'supported_by': 'community',
|
||||
'version': '1.0'}
|
||||
@@ -115,6 +108,13 @@ EXAMPLES = '''
|
||||
'''
|
||||
|
||||
# Import Datadog
|
||||
try:
|
||||
from datadog import initialize, api
|
||||
HAS_DATADOG = True
|
||||
except:
|
||||
HAS_DATADOG = False
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
|
||||
@@ -1,58 +1,21 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"""LogicMonitor Ansible module for managing Collectors, Hosts and Hostgroups
|
||||
Copyright (C) 2015 LogicMonitor
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA"""
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import platform
|
||||
import socket
|
||||
import sys
|
||||
import types
|
||||
import urllib
|
||||
|
||||
HAS_LIB_JSON = True
|
||||
try:
|
||||
import json
|
||||
# Detect the python-json library which is incompatible
|
||||
# Look for simplejson if that's the case
|
||||
try:
|
||||
if (
|
||||
not isinstance(json.loads, types.FunctionType) or
|
||||
not isinstance(json.dumps, types.FunctionType)
|
||||
):
|
||||
raise ImportError
|
||||
except AttributeError:
|
||||
raise ImportError
|
||||
except ImportError:
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
print(
|
||||
'\n{"msg": "Error: ansible requires the stdlib json or ' +
|
||||
'simplejson module, neither was found!", "failed": true}'
|
||||
)
|
||||
HAS_LIB_JSON = False
|
||||
except SyntaxError:
|
||||
print(
|
||||
'\n{"msg": "SyntaxError: probably due to installed simplejson ' +
|
||||
'being for a different python version", "failed": true}'
|
||||
)
|
||||
HAS_LIB_JSON = False
|
||||
# LogicMonitor Ansible module for managing Collectors, Hosts and Hostgroups
|
||||
# Copyright (C) 2015 LogicMonitor
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
RETURN = '''
|
||||
---
|
||||
@@ -555,6 +518,36 @@ EXAMPLES = '''
|
||||
delegate_to: localhost
|
||||
'''
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import platform
|
||||
import socket
|
||||
import sys
|
||||
import types
|
||||
import urllib
|
||||
|
||||
HAS_LIB_JSON = True
|
||||
try:
|
||||
import json
|
||||
# Detect the python-json library which is incompatible
|
||||
# Look for simplejson if that's the case
|
||||
try:
|
||||
if (
|
||||
not isinstance(json.loads, types.FunctionType) or
|
||||
not isinstance(json.dumps, types.FunctionType)
|
||||
):
|
||||
raise ImportError
|
||||
except AttributeError:
|
||||
raise ImportError
|
||||
except ImportError:
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
HAS_LIB_JSON = False
|
||||
except SyntaxError:
|
||||
HAS_LIB_JSON = False
|
||||
|
||||
|
||||
|
||||
class LogicMonitor(object):
|
||||
|
||||
|
||||
@@ -1,56 +1,21 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"""LogicMonitor Ansible module for managing Collectors, Hosts and Hostgroups
|
||||
Copyright (C) 2015 LogicMonitor
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA"""
|
||||
|
||||
|
||||
import socket
|
||||
import types
|
||||
import urllib
|
||||
|
||||
HAS_LIB_JSON = True
|
||||
try:
|
||||
import json
|
||||
# Detect the python-json library which is incompatible
|
||||
# Look for simplejson if that's the case
|
||||
try:
|
||||
if (
|
||||
not isinstance(json.loads, types.FunctionType) or
|
||||
not isinstance(json.dumps, types.FunctionType)
|
||||
):
|
||||
raise ImportError
|
||||
except AttributeError:
|
||||
raise ImportError
|
||||
except ImportError:
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
print(
|
||||
'\n{"msg": "Error: ansible requires the stdlib json or ' +
|
||||
'simplejson module, neither was found!", "failed": true}'
|
||||
)
|
||||
HAS_LIB_JSON = False
|
||||
except SyntaxError:
|
||||
print(
|
||||
'\n{"msg": "SyntaxError: probably due to installed simplejson ' +
|
||||
'being for a different python version", "failed": true}'
|
||||
)
|
||||
HAS_LIB_JSON = False
|
||||
|
||||
# LogicMonitor Ansible module for managing Collectors, Hosts and Hostgroups
|
||||
# Copyright (C) 2015 LogicMonitor
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
ANSIBLE_METADATA = {'status': ['preview'],
|
||||
'supported_by': 'community',
|
||||
@@ -167,6 +132,31 @@ RETURN = '''
|
||||
...
|
||||
'''
|
||||
|
||||
import socket
|
||||
import types
|
||||
import urllib
|
||||
|
||||
HAS_LIB_JSON = True
|
||||
try:
|
||||
import json
|
||||
# Detect the python-json library which is incompatible
|
||||
# Look for simplejson if that's the case
|
||||
try:
|
||||
if (
|
||||
not isinstance(json.loads, types.FunctionType) or
|
||||
not isinstance(json.dumps, types.FunctionType)
|
||||
):
|
||||
raise ImportError
|
||||
except AttributeError:
|
||||
raise ImportError
|
||||
except ImportError:
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
HAS_LIB_JSON = False
|
||||
except SyntaxError:
|
||||
HAS_LIB_JSON = False
|
||||
|
||||
|
||||
class LogicMonitor(object):
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import time
|
||||
|
||||
ANSIBLE_METADATA = {'status': ['preview'],
|
||||
'supported_by': 'community',
|
||||
@@ -62,6 +61,9 @@ EXAMPLES = '''
|
||||
state: started
|
||||
'''
|
||||
|
||||
import time
|
||||
|
||||
|
||||
def main():
|
||||
arg_spec = dict(
|
||||
name=dict(required=True),
|
||||
|
||||
Reference in New Issue
Block a user