Fix modules' use of BOOLEANS*
* The canonical location of BOOLEANS has moved. Switch imports to use that. * clean up argument_spec use of booleans. * Clean up imports to not use wildcards * Remove usage of get_exceptionpull/4420/head
parent
ff22528b07
commit
d64e291274
|
@ -140,20 +140,24 @@ import json
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import boto3
|
import botocore
|
||||||
HAS_BOTO3 = True
|
HAS_BOTO3 = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_BOTO3 = False
|
HAS_BOTO3 = False
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
|
||||||
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = ec2_argument_spec()
|
argument_spec = ec2_argument_spec()
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
name = dict(),
|
name = dict(),
|
||||||
function_arn = dict(),
|
function_arn = dict(),
|
||||||
wait = dict(choices=BOOLEANS, default=True, type='bool'),
|
wait = dict(default=True, type='bool'),
|
||||||
tail_log = dict(choices=BOOLEANS, default=False, type='bool'),
|
tail_log = dict(default=False, type='bool'),
|
||||||
dry_run = dict(choices=BOOLEANS, default=False, type='bool'),
|
dry_run = dict(default=False, type='bool'),
|
||||||
version_qualifier = dict(),
|
version_qualifier = dict(),
|
||||||
payload = dict(default={}, type='dict'),
|
payload = dict(default={}, type='dict'),
|
||||||
))
|
))
|
||||||
|
@ -192,7 +196,7 @@ def main():
|
||||||
client = boto3_conn(module, conn_type='client', resource='lambda',
|
client = boto3_conn(module, conn_type='client', resource='lambda',
|
||||||
region=region, endpoint=ec2_url, **aws_connect_kwargs)
|
region=region, endpoint=ec2_url, **aws_connect_kwargs)
|
||||||
except (botocore.exceptions.ClientError, botocore.exceptions.ValidationError) as e:
|
except (botocore.exceptions.ClientError, botocore.exceptions.ValidationError) as e:
|
||||||
module.fail_json(msg="Failure connecting boto3 to AWS", exception=traceback.format_exc())
|
module.fail_json(msg="Failure connecting boto3 to AWS: %s" % to_native(e), exception=traceback.format_exc())
|
||||||
|
|
||||||
invoke_params = {}
|
invoke_params = {}
|
||||||
|
|
||||||
|
@ -282,9 +286,6 @@ def main():
|
||||||
|
|
||||||
module.exit_json(changed=True, result=results)
|
module.exit_json(changed=True, result=results)
|
||||||
|
|
||||||
# import module snippets
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
from ansible.module_utils.ec2 import *
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -352,7 +352,7 @@ def main():
|
||||||
healthchecks=dict(type='list', required=True),
|
healthchecks=dict(type='list', required=True),
|
||||||
service_account_email=dict(),
|
service_account_email=dict(),
|
||||||
service_account_permissions=dict(type='list'),
|
service_account_permissions=dict(type='list'),
|
||||||
enable_cdn=dict(type='bool', choices=[True, False]),
|
enable_cdn=dict(type='bool'),
|
||||||
port_name=dict(type='str'),
|
port_name=dict(type='str'),
|
||||||
protocol=dict(type='str', default='TCP',
|
protocol=dict(type='str', default='TCP',
|
||||||
choices=['HTTP', 'HTTPS', 'SSL', 'TCP']),
|
choices=['HTTP', 'HTTPS', 'SSL', 'TCP']),
|
||||||
|
|
|
@ -431,7 +431,13 @@ lxc_container:
|
||||||
sample: True
|
sample: True
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import lxc
|
import lxc
|
||||||
|
@ -440,6 +446,10 @@ except ImportError:
|
||||||
else:
|
else:
|
||||||
HAS_LXC = True
|
HAS_LXC = True
|
||||||
|
|
||||||
|
# import module bits
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
|
||||||
|
|
||||||
|
|
||||||
# LXC_COMPRESSION_MAP is a map of available compression types when creating
|
# LXC_COMPRESSION_MAP is a map of available compression types when creating
|
||||||
# an archive of a container.
|
# an archive of a container.
|
||||||
|
@ -562,11 +572,6 @@ def create_script(command):
|
||||||
:type command: ``str``
|
:type command: ``str``
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
|
||||||
import os.path as path
|
|
||||||
import subprocess
|
|
||||||
import tempfile
|
|
||||||
|
|
||||||
(fd, script_file) = tempfile.mkstemp(prefix='lxc-attach-script')
|
(fd, script_file) = tempfile.mkstemp(prefix='lxc-attach-script')
|
||||||
f = os.fdopen(fd, 'wb')
|
f = os.fdopen(fd, 'wb')
|
||||||
try:
|
try:
|
||||||
|
@ -682,7 +687,7 @@ class LxcContainerManagement(object):
|
||||||
variables.pop(v, None)
|
variables.pop(v, None)
|
||||||
|
|
||||||
return_dict = dict()
|
return_dict = dict()
|
||||||
false_values = [None, ''] + BOOLEANS_FALSE
|
false_values = BOOLEANS_FALSE.union([None, ''])
|
||||||
for k, v in variables.items():
|
for k, v in variables.items():
|
||||||
_var = self.module.params.get(k)
|
_var = self.module.params.get(k)
|
||||||
if _var not in false_values:
|
if _var not in false_values:
|
||||||
|
@ -1761,7 +1766,5 @@ def main():
|
||||||
lxc_manage.run()
|
lxc_manage.run()
|
||||||
|
|
||||||
|
|
||||||
# import module bits
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -531,7 +531,10 @@ import socket
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
from ansible.module_utils.urls import open_url
|
||||||
|
|
||||||
|
|
||||||
HAS_LIB_JSON = True
|
HAS_LIB_JSON = True
|
||||||
try:
|
try:
|
||||||
|
@ -604,8 +607,7 @@ class LogicMonitor(object):
|
||||||
self.fail(msg="Error: " + resp["errmsg"])
|
self.fail(msg="Error: " + resp["errmsg"])
|
||||||
else:
|
else:
|
||||||
return raw
|
return raw
|
||||||
except IOError:
|
except IOError as ioe:
|
||||||
ioe = get_exception()
|
|
||||||
self.fail(msg="Error: Exception making RPC call to " +
|
self.fail(msg="Error: Exception making RPC call to " +
|
||||||
"https://" + self.company + "." + self.lm_url +
|
"https://" + self.company + "." + self.lm_url +
|
||||||
"/rpc/" + action + "\nException" + str(ioe))
|
"/rpc/" + action + "\nException" + str(ioe))
|
||||||
|
@ -633,8 +635,7 @@ class LogicMonitor(object):
|
||||||
"https://" + self.company + "." + self.lm_url +
|
"https://" + self.company + "." + self.lm_url +
|
||||||
"/do/" + action + "?" + param_str)
|
"/do/" + action + "?" + param_str)
|
||||||
return f.read()
|
return f.read()
|
||||||
except IOError:
|
except IOError as ioe:
|
||||||
ioe = get_exception()
|
|
||||||
self.fail(msg="Error: Exception making RPC call to " +
|
self.fail(msg="Error: Exception making RPC call to " +
|
||||||
"https://" + self.company + "." + self.lm_url +
|
"https://" + self.company + "." + self.lm_url +
|
||||||
"/do/" + action + "\nException" + str(ioe))
|
"/do/" + action + "\nException" + str(ioe))
|
||||||
|
@ -2171,7 +2172,7 @@ def main():
|
||||||
duration=dict(required=False, default=30),
|
duration=dict(required=False, default=30),
|
||||||
properties=dict(required=False, default={}, type="dict"),
|
properties=dict(required=False, default={}, type="dict"),
|
||||||
groups=dict(required=False, default=[], type="list"),
|
groups=dict(required=False, default=[], type="list"),
|
||||||
alertenable=dict(required=False, default="true", choices=BOOLEANS)
|
alertenable=dict(required=False, default="true", type="bool")
|
||||||
),
|
),
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
@ -2182,10 +2183,5 @@ def main():
|
||||||
selector(module)
|
selector(module)
|
||||||
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
from ansible.module_utils.urls import *
|
|
||||||
from ansible.module_utils.urls import open_url
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -216,6 +216,12 @@ msg:
|
||||||
sample: "interface bond0 config updated"
|
sample: "interface bond0 config updated"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
# handy helper for calling system calls.
|
# handy helper for calling system calls.
|
||||||
# calls AnsibleModule.run_command and prints a more appropriate message
|
# calls AnsibleModule.run_command and prints a more appropriate message
|
||||||
|
@ -437,9 +443,9 @@ def main():
|
||||||
virtual_mac=dict(type='str'),
|
virtual_mac=dict(type='str'),
|
||||||
vids=dict(type='list'),
|
vids=dict(type='list'),
|
||||||
pvid=dict(type='str'),
|
pvid=dict(type='str'),
|
||||||
mstpctl_portnetwork=dict(type='bool', choices=BOOLEANS),
|
mstpctl_portnetwork=dict(type='bool'),
|
||||||
mstpctl_portadminedge=dict(type='bool', choices=BOOLEANS),
|
mstpctl_portadminedge=dict(type='bool'),
|
||||||
mstpctl_bpduguard=dict(type='bool', choices=BOOLEANS),
|
mstpctl_bpduguard=dict(type='bool'),
|
||||||
clag_id=dict(type='str'),
|
clag_id=dict(type='str'),
|
||||||
min_links=dict(type='int', default=1),
|
min_links=dict(type='int', default=1),
|
||||||
mode=dict(type='str', default='802.3ad'),
|
mode=dict(type='str', default='802.3ad'),
|
||||||
|
@ -484,11 +490,6 @@ def main():
|
||||||
|
|
||||||
module.exit_json(changed=_changed, msg=_msg)
|
module.exit_json(changed=_changed, msg=_msg)
|
||||||
|
|
||||||
# import module snippets
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
import tempfile
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -164,6 +164,12 @@ msg:
|
||||||
sample: "interface bond0 config updated"
|
sample: "interface bond0 config updated"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
# handy helper for calling system calls.
|
# handy helper for calling system calls.
|
||||||
# calls AnsibleModule.run_command and prints a more appropriate message
|
# calls AnsibleModule.run_command and prints a more appropriate message
|
||||||
|
@ -373,8 +379,8 @@ def main():
|
||||||
vids=dict(type='list'),
|
vids=dict(type='list'),
|
||||||
pvid=dict(type='str'),
|
pvid=dict(type='str'),
|
||||||
mstpctl_treeprio=dict(type='str'),
|
mstpctl_treeprio=dict(type='str'),
|
||||||
vlan_aware=dict(type='bool', choices=BOOLEANS),
|
vlan_aware=dict(type='bool'),
|
||||||
stp=dict(type='bool', default='yes', choices=BOOLEANS),
|
stp=dict(type='bool', default='yes'),
|
||||||
location=dict(type='str',
|
location=dict(type='str',
|
||||||
default='/etc/network/interfaces.d')
|
default='/etc/network/interfaces.d')
|
||||||
),
|
),
|
||||||
|
@ -410,11 +416,6 @@ def main():
|
||||||
|
|
||||||
module.exit_json(changed=_changed, msg=_msg)
|
module.exit_json(changed=_changed, msg=_msg)
|
||||||
|
|
||||||
# import module snippets
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
import tempfile
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -110,6 +110,14 @@ msg:
|
||||||
sample: "interface bond0 config updated"
|
sample: "interface bond0 config updated"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import re
|
||||||
|
from urlparse import urlparse
|
||||||
|
|
||||||
|
# import module snippets
|
||||||
|
from ansible.module_utils.basic import AnsibleModule, platform
|
||||||
|
# incompatible with ansible 1.4.4 - ubuntu 12.04 version
|
||||||
|
# from ansible.module_utils.urls import *
|
||||||
|
|
||||||
|
|
||||||
def check_url(module, url):
|
def check_url(module, url):
|
||||||
parsed_url = urlparse(url)
|
parsed_url = urlparse(url)
|
||||||
|
@ -124,8 +132,7 @@ def check_url(module, url):
|
||||||
def run_cl_cmd(module, cmd, check_rc=True):
|
def run_cl_cmd(module, cmd, check_rc=True):
|
||||||
try:
|
try:
|
||||||
(rc, out, err) = module.run_command(cmd, check_rc=check_rc)
|
(rc, out, err) = module.run_command(cmd, check_rc=check_rc)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
e = get_exception()
|
|
||||||
module.fail_json(msg=e.strerror)
|
module.fail_json(msg=e.strerror)
|
||||||
# trim last line as it is always empty
|
# trim last line as it is always empty
|
||||||
ret = out.splitlines()
|
ret = out.splitlines()
|
||||||
|
@ -301,7 +308,7 @@ def main():
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
src=dict(required=True, type='str'),
|
src=dict(required=True, type='str'),
|
||||||
version=dict(type='str'),
|
version=dict(type='str'),
|
||||||
switch_slot=dict(type='bool', choices=BOOLEANS, default=False),
|
switch_slot=dict(type='bool', default=False),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -315,12 +322,5 @@ def main():
|
||||||
install_img(module)
|
install_img(module)
|
||||||
|
|
||||||
|
|
||||||
# import module snippets
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
# incompatible with ansible 1.4.4 - ubuntu 12.04 version
|
|
||||||
# from ansible.module_utils.urls import *
|
|
||||||
from urlparse import urlparse
|
|
||||||
import re
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -209,6 +209,13 @@ msg:
|
||||||
sample: "interface bond0 config updated"
|
sample: "interface bond0 config updated"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import re
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
# handy helper for calling system calls.
|
# handy helper for calling system calls.
|
||||||
# calls AnsibleModule.run_command and prints a more appropriate message
|
# calls AnsibleModule.run_command and prints a more appropriate message
|
||||||
|
@ -401,10 +408,10 @@ def main():
|
||||||
virtual_mac=dict(type='str'),
|
virtual_mac=dict(type='str'),
|
||||||
vids=dict(type='list'),
|
vids=dict(type='list'),
|
||||||
pvid=dict(type='str'),
|
pvid=dict(type='str'),
|
||||||
mstpctl_portnetwork=dict(type='bool', choices=BOOLEANS),
|
mstpctl_portnetwork=dict(type='bool'),
|
||||||
mstpctl_portadminedge=dict(type='bool', choices=BOOLEANS),
|
mstpctl_portadminedge=dict(type='bool'),
|
||||||
mstpctl_bpduguard=dict(type='bool', choices=BOOLEANS),
|
mstpctl_bpduguard=dict(type='bool'),
|
||||||
clagd_enable=dict(type='bool', choices=BOOLEANS),
|
clagd_enable=dict(type='bool'),
|
||||||
clagd_priority=dict(type='str'),
|
clagd_priority=dict(type='str'),
|
||||||
clagd_peer_ip=dict(type='str'),
|
clagd_peer_ip=dict(type='str'),
|
||||||
clagd_sys_mac=dict(type='str'),
|
clagd_sys_mac=dict(type='str'),
|
||||||
|
@ -446,10 +453,6 @@ def main():
|
||||||
|
|
||||||
module.exit_json(changed=_changed, msg=_msg)
|
module.exit_json(changed=_changed, msg=_msg)
|
||||||
|
|
||||||
# import module snippets
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
import tempfile
|
|
||||||
import os
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -107,6 +107,9 @@ msg:
|
||||||
sample: "interface bond0 config updated"
|
sample: "interface bond0 config updated"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
# import module snippets
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
CL_LICENSE_PATH='/usr/cumulus/bin/cl-license'
|
CL_LICENSE_PATH='/usr/cumulus/bin/cl-license'
|
||||||
|
|
||||||
def install_license(module):
|
def install_license(module):
|
||||||
|
@ -121,8 +124,7 @@ def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
src=dict(required=True, type='str'),
|
src=dict(required=True, type='str'),
|
||||||
force=dict(type='bool', choices=BOOLEANS,
|
force=dict(type='bool', default=False)
|
||||||
default=False)
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -142,9 +144,5 @@ def main():
|
||||||
module.exit_json(changed=module.changed, msg=module.msg)
|
module.exit_json(changed=module.changed, msg=module.msg)
|
||||||
|
|
||||||
|
|
||||||
# import module snippets
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
# from ansible.module_utils.urls import *
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -146,7 +146,6 @@ from ansible.module_utils.f5_utils import (
|
||||||
iteritems,
|
iteritems,
|
||||||
defaultdict
|
defaultdict
|
||||||
)
|
)
|
||||||
from ansible.module_utils.basic import BOOLEANS
|
|
||||||
|
|
||||||
|
|
||||||
class Parameters(AnsibleF5Parameters):
|
class Parameters(AnsibleF5Parameters):
|
||||||
|
|
|
@ -118,6 +118,10 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_F5SDK = False
|
HAS_F5SDK = False
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils.ec2 import camel_dict_to_snake_dict
|
||||||
|
from ansible.module_utils.f5_utils import F5ModuleError, f5_argument_spec
|
||||||
|
|
||||||
|
|
||||||
class BigIpGtmDatacenter(object):
|
class BigIpGtmDatacenter(object):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -346,7 +350,7 @@ def main():
|
||||||
meta_args = dict(
|
meta_args = dict(
|
||||||
contact=dict(required=False, default=None),
|
contact=dict(required=False, default=None),
|
||||||
description=dict(required=False, default=None),
|
description=dict(required=False, default=None),
|
||||||
enabled=dict(required=False, type='bool', default=None, choices=BOOLEANS),
|
enabled=dict(required=False, type='bool', default=None),
|
||||||
location=dict(required=False, default=None),
|
location=dict(required=False, default=None),
|
||||||
name=dict(required=True)
|
name=dict(required=True)
|
||||||
)
|
)
|
||||||
|
@ -365,9 +369,6 @@ def main():
|
||||||
except F5ModuleError as e:
|
except F5ModuleError as e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
from ansible.module_utils.ec2 import camel_dict_to_snake_dict
|
|
||||||
from ansible.module_utils.f5_utils import *
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -118,7 +118,15 @@ RETURN = '''
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from ansible.module_utils.basic import BOOLEANS
|
try:
|
||||||
|
from StringIO import StringIO
|
||||||
|
except ImportError:
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
|
from f5.utils.iapp_parser import (
|
||||||
|
NonextantTemplateNameException
|
||||||
|
)
|
||||||
|
|
||||||
from ansible.module_utils.f5_utils import (
|
from ansible.module_utils.f5_utils import (
|
||||||
AnsibleF5Client,
|
AnsibleF5Client,
|
||||||
AnsibleF5Parameters,
|
AnsibleF5Parameters,
|
||||||
|
@ -128,14 +136,6 @@ from ansible.module_utils.f5_utils import (
|
||||||
defaultdict,
|
defaultdict,
|
||||||
iControlUnexpectedHTTPError
|
iControlUnexpectedHTTPError
|
||||||
)
|
)
|
||||||
from f5.utils.iapp_parser import (
|
|
||||||
NonextantTemplateNameException
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from StringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from io import StringIO
|
|
||||||
|
|
||||||
|
|
||||||
class Parameters(AnsibleF5Parameters):
|
class Parameters(AnsibleF5Parameters):
|
||||||
|
@ -453,7 +453,6 @@ class ArgumentSpec(object):
|
||||||
choices=['present', 'absent']
|
choices=['present', 'absent']
|
||||||
),
|
),
|
||||||
force=dict(
|
force=dict(
|
||||||
choices=BOOLEANS,
|
|
||||||
type='bool'
|
type='bool'
|
||||||
),
|
),
|
||||||
content=dict()
|
content=dict()
|
||||||
|
|
|
@ -138,6 +138,10 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_NETADDR = False
|
HAS_NETADDR = False
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils.ec2 import camel_dict_to_snake_dict
|
||||||
|
from ansible.module_utils.f5_utils import F5ModuleError, f5_argument_spec
|
||||||
|
|
||||||
|
|
||||||
class BigIpSnatPoolManager(object):
|
class BigIpSnatPoolManager(object):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -363,7 +367,6 @@ class BigIpSnatPoolModuleConfig(object):
|
||||||
append=dict(
|
append=dict(
|
||||||
default=False,
|
default=False,
|
||||||
type='bool',
|
type='bool',
|
||||||
choices=BOOLEANS
|
|
||||||
),
|
),
|
||||||
name=dict(required=True),
|
name=dict(required=True),
|
||||||
members=dict(
|
members=dict(
|
||||||
|
@ -410,9 +413,6 @@ def main():
|
||||||
except F5ModuleError as e:
|
except F5ModuleError as e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
from ansible.module_utils.ec2 import camel_dict_to_snake_dict
|
|
||||||
from ansible.module_utils.f5_utils import *
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -196,8 +196,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_NETADDR = False
|
HAS_NETADDR = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import BOOLEANS_TRUE
|
|
||||||
from ansible.module_utils.basic import BOOLEANS_FALSE
|
|
||||||
from ansible.module_utils.f5_utils import (
|
from ansible.module_utils.f5_utils import (
|
||||||
AnsibleF5Client,
|
AnsibleF5Client,
|
||||||
AnsibleF5Parameters,
|
AnsibleF5Parameters,
|
||||||
|
@ -205,6 +203,7 @@ from ansible.module_utils.f5_utils import (
|
||||||
F5ModuleError,
|
F5ModuleError,
|
||||||
iControlUnexpectedHTTPError
|
iControlUnexpectedHTTPError
|
||||||
)
|
)
|
||||||
|
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
|
||||||
|
|
||||||
|
|
||||||
class Parameters(AnsibleF5Parameters):
|
class Parameters(AnsibleF5Parameters):
|
||||||
|
|
|
@ -231,7 +231,7 @@ def main():
|
||||||
link=dict(required=True, default=None, type='str', aliases=['nic', 'interface']),
|
link=dict(required=True, default=None, type='str', aliases=['nic', 'interface']),
|
||||||
property=dict(required=True, type='str', aliases=['name']),
|
property=dict(required=True, type='str', aliases=['name']),
|
||||||
value=dict(required=False, type='str'),
|
value=dict(required=False, type='str'),
|
||||||
temporary=dict(default=False, type='bool', choices=BOOLEANS),
|
temporary=dict(default=False, type='bool'),
|
||||||
state=dict(
|
state=dict(
|
||||||
default='present', choices=['absent', 'present', 'reset']),
|
default='present', choices=['absent', 'present', 'reset']),
|
||||||
),
|
),
|
||||||
|
@ -298,6 +298,5 @@ def main():
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -104,8 +104,7 @@ RETURN = '''
|
||||||
...
|
...
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, BOOLEANS_TRUE
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
|
||||||
|
|
||||||
|
|
||||||
class GConf2Preference(object):
|
class GConf2Preference(object):
|
||||||
|
@ -165,8 +164,7 @@ class GConf2Preference(object):
|
||||||
else:
|
else:
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
except OSError:
|
except OSError as exception:
|
||||||
exception = get_exception()
|
|
||||||
self.ansible.fail_json(msg='gconftool-2 failed with exception: '
|
self.ansible.fail_json(msg='gconftool-2 failed with exception: '
|
||||||
'%s' % exception)
|
'%s' % exception)
|
||||||
return changed, out.rstrip()
|
return changed, out.rstrip()
|
||||||
|
@ -193,7 +191,6 @@ def main():
|
||||||
|
|
||||||
state_values = {"present": "set", "absent": "unset", "get": "get"}
|
state_values = {"present": "set", "absent": "unset", "get": "get"}
|
||||||
|
|
||||||
direct = False
|
|
||||||
# Assign module values to dictionary values
|
# Assign module values to dictionary values
|
||||||
key = module.params['key']
|
key = module.params['key']
|
||||||
value_type = module.params['value_type']
|
value_type = module.params['value_type']
|
||||||
|
@ -205,8 +202,7 @@ def main():
|
||||||
value = module.params['value']
|
value = module.params['value']
|
||||||
|
|
||||||
state = state_values[module.params['state']]
|
state = state_values[module.params['state']]
|
||||||
if module.params['direct'] in BOOLEANS_TRUE:
|
direct = module.params['direct']
|
||||||
direct = True
|
|
||||||
config_source = module.params['config_source']
|
config_source = module.params['config_source']
|
||||||
|
|
||||||
# Initialize some variables for later
|
# Initialize some variables for later
|
||||||
|
|
|
@ -118,8 +118,10 @@ EXAMPLES = '''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
from ansible.module_utils.basic import get_platform, get_exception, AnsibleModule, BOOLEANS_TRUE, BOOLEANS_FALSE
|
|
||||||
|
from ansible.module_utils.basic import get_platform, AnsibleModule
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import string_types
|
||||||
|
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
|
||||||
|
|
||||||
|
|
||||||
class SysctlModule(object):
|
class SysctlModule(object):
|
||||||
|
@ -309,8 +311,7 @@ class SysctlModule(object):
|
||||||
f = open(self.sysctl_file, "r")
|
f = open(self.sysctl_file, "r")
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
except IOError:
|
except IOError as e:
|
||||||
e = get_exception()
|
|
||||||
self.module.fail_json(msg="Failed to open %s: %s" % (self.sysctl_file, str(e)))
|
self.module.fail_json(msg="Failed to open %s: %s" % (self.sysctl_file, str(e)))
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
@ -335,7 +336,7 @@ class SysctlModule(object):
|
||||||
self.fixed_lines.append(line)
|
self.fixed_lines.append(line)
|
||||||
continue
|
continue
|
||||||
tmpline = line.strip()
|
tmpline = line.strip()
|
||||||
k, v = line.split('=',1)
|
k, v = tmpline.split('=',1)
|
||||||
k = k.strip()
|
k = k.strip()
|
||||||
v = v.strip()
|
v = v.strip()
|
||||||
if k not in checked:
|
if k not in checked:
|
||||||
|
@ -360,8 +361,7 @@ class SysctlModule(object):
|
||||||
try:
|
try:
|
||||||
for l in self.fixed_lines:
|
for l in self.fixed_lines:
|
||||||
f.write(l.strip() + "\n")
|
f.write(l.strip() + "\n")
|
||||||
except IOError:
|
except IOError as e:
|
||||||
e = get_exception()
|
|
||||||
self.module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, str(e)))
|
self.module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, str(e)))
|
||||||
f.flush()
|
f.flush()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
Loading…
Reference in New Issue