mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Various errors and formatting fixes (#33503)
* Various errors and formatting fixes Mostly formatting fixes and small changes to better support debugging * Fixes upstream errors
This commit is contained in:
parent
9f544cf926
commit
18aca48075
6 changed files with 142 additions and 150 deletions
|
@ -5,81 +5,79 @@
|
||||||
# Copyright (c) 2015 Michael Perzel
|
# Copyright (c) 2015 Michael Perzel
|
||||||
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
'status': ['preview'],
|
'status': ['preview'],
|
||||||
'supported_by': 'community'}
|
'supported_by': 'community'}
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: bigip_gtm_virtual_server
|
module: bigip_gtm_virtual_server
|
||||||
short_description: "Manages F5 BIG-IP GTM virtual servers"
|
short_description: Manages F5 BIG-IP GTM virtual servers
|
||||||
description:
|
description:
|
||||||
- "Manages F5 BIG-IP GTM virtual servers"
|
- Manages F5 BIG-IP GTM virtual servers.
|
||||||
version_added: "2.2"
|
version_added: "2.2"
|
||||||
author:
|
|
||||||
- Michael Perzel (@perzizzle)
|
|
||||||
- Tim Rupp (@caphrim007)
|
|
||||||
notes:
|
|
||||||
- "Requires BIG-IP software version >= 11.4"
|
|
||||||
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
|
|
||||||
- "Best run as a local_action in your playbook"
|
|
||||||
- "Tested with manager and above account privilege level"
|
|
||||||
|
|
||||||
requirements:
|
|
||||||
- bigsuds
|
|
||||||
options:
|
options:
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Virtual server state
|
- Virtual server state.
|
||||||
required: false
|
default: present
|
||||||
default: present
|
choices: ['present', 'absent','enabled','disabled']
|
||||||
choices: ['present', 'absent','enabled','disabled']
|
virtual_server_name:
|
||||||
virtual_server_name:
|
description:
|
||||||
description:
|
- Virtual server name.
|
||||||
- Virtual server name
|
required: True
|
||||||
required: True
|
virtual_server_server:
|
||||||
virtual_server_server:
|
description:
|
||||||
description:
|
- Virtual server server.
|
||||||
- Virtual server server
|
required: true
|
||||||
required: true
|
host:
|
||||||
host:
|
description:
|
||||||
description:
|
- Virtual server host.
|
||||||
- Virtual server host
|
aliases: ['address']
|
||||||
required: false
|
port:
|
||||||
default: None
|
description:
|
||||||
aliases: ['address']
|
- Virtual server port.
|
||||||
port:
|
|
||||||
description:
|
|
||||||
- Virtual server port
|
|
||||||
required: false
|
|
||||||
default: None
|
|
||||||
extends_documentation_fragment: f5
|
extends_documentation_fragment: f5
|
||||||
|
notes:
|
||||||
|
- Requires BIG-IP software version >= 11.4
|
||||||
|
- F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
|
||||||
|
- Best run as a local_action in your playbook
|
||||||
|
- Tested with manager and above account privilege level
|
||||||
|
requirements:
|
||||||
|
- bigsuds
|
||||||
|
author:
|
||||||
|
- Michael Perzel (@perzizzle)
|
||||||
|
- Tim Rupp (@caphrim007)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = r'''
|
||||||
- name: Enable virtual server
|
- name: Enable virtual server
|
||||||
local_action: >
|
bigip_gtm_virtual_server:
|
||||||
bigip_gtm_virtual_server
|
server: lb.mydomain.com
|
||||||
server=192.0.2.1
|
user: admin
|
||||||
user=admin
|
password: secret
|
||||||
password=mysecret
|
virtual_server_name: myname
|
||||||
virtual_server_name=myname
|
virtual_server_server: myserver
|
||||||
virtual_server_server=myserver
|
state: enabled
|
||||||
state=enabled
|
delegate_to: localhost
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''# '''
|
RETURN = '''# '''
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import bigsuds
|
import bigsuds
|
||||||
except ImportError:
|
except ImportError:
|
||||||
bigsuds_found = False
|
pass # Handled by f5_utils.bigsuds_found
|
||||||
else:
|
|
||||||
bigsuds_found = True
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
from ansible.module_utils.f5_utils import bigip_api, bigsuds_found, f5_argument_spec
|
||||||
from ansible.module_utils.f5_utils import bigip_api, f5_argument_spec
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
|
|
||||||
def server_exists(api, server):
|
def server_exists(api, server):
|
||||||
|
@ -88,9 +86,8 @@ def server_exists(api, server):
|
||||||
try:
|
try:
|
||||||
api.GlobalLB.Server.get_object_status([server])
|
api.GlobalLB.Server.get_object_status([server])
|
||||||
result = True
|
result = True
|
||||||
except bigsuds.OperationFailed:
|
except bigsuds.OperationFailed as e:
|
||||||
e = get_exception()
|
if "was not found" in to_native(e):
|
||||||
if "was not found" in str(e):
|
|
||||||
result = False
|
result = False
|
||||||
else:
|
else:
|
||||||
# genuine exception
|
# genuine exception
|
||||||
|
@ -105,9 +102,8 @@ def virtual_server_exists(api, name, server):
|
||||||
virtual_server_id = {'name': name, 'server': server}
|
virtual_server_id = {'name': name, 'server': server}
|
||||||
api.GlobalLB.VirtualServerV2.get_object_status([virtual_server_id])
|
api.GlobalLB.VirtualServerV2.get_object_status([virtual_server_id])
|
||||||
result = True
|
result = True
|
||||||
except bigsuds.OperationFailed:
|
except bigsuds.OperationFailed as e:
|
||||||
e = get_exception()
|
if "was not found" in to_native(e):
|
||||||
if "was not found" in str(e):
|
|
||||||
result = False
|
result = False
|
||||||
else:
|
else:
|
||||||
# genuine exception
|
# genuine exception
|
||||||
|
@ -219,9 +215,8 @@ def main():
|
||||||
else:
|
else:
|
||||||
result = {'changed': True}
|
result = {'changed': True}
|
||||||
|
|
||||||
except Exception:
|
except Exception as e:
|
||||||
e = get_exception()
|
module.fail_json(msg="received exception: %s" % to_native(e), exception=traceback.format_exc())
|
||||||
module.fail_json(msg="received exception: %s" % e)
|
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ EXAMPLES = r'''
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
failed_when:
|
failed_when:
|
||||||
- result is not successful
|
- result is not success
|
||||||
- "'referenced by one or more applications' not in result.msg"
|
- "'referenced by one or more applications' not in result.msg"
|
||||||
|
|
||||||
- name: Configure a service using more complicated parameters
|
- name: Configure a service using more complicated parameters
|
||||||
|
|
|
@ -48,6 +48,7 @@ notes:
|
||||||
requirements:
|
requirements:
|
||||||
- f5-sdk >= 2.2.3
|
- f5-sdk >= 2.2.3
|
||||||
- Requires BIG-IP >= 12.1.0
|
- Requires BIG-IP >= 12.1.0
|
||||||
|
- The 'rpm' tool installed on the Ansible controller
|
||||||
extends_documentation_fragment: f5
|
extends_documentation_fragment: f5
|
||||||
author:
|
author:
|
||||||
- Tim Rupp (@caphrim007)
|
- Tim Rupp (@caphrim007)
|
||||||
|
@ -134,14 +135,12 @@ class Parameters(AnsibleF5Parameters):
|
||||||
|
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
p = subprocess.Popen(
|
cmd = ['rpm', '-qp', '--queryformat', '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}', self.package]
|
||||||
['rpm', '-qp', '--queryformat', '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}', self.package],
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
stdout=subprocess.PIPE
|
|
||||||
)
|
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
if not stdout:
|
if not stdout:
|
||||||
return self.package_file
|
return str(self.package_file)
|
||||||
return stdout
|
return stdout.decode('utf-8')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def package_root(self):
|
def package_root(self):
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017 F5 Networks Inc.
|
# Copyright (c) 2016 F5 Networks Inc.
|
||||||
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
'status': ['preview'],
|
'status': ['preview'],
|
||||||
'supported_by': 'community'}
|
'supported_by': 'community'}
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: bigip_sys_global
|
module: bigip_sys_global
|
||||||
short_description: Manage BIG-IP global settings.
|
short_description: Manage BIG-IP global settings
|
||||||
description:
|
description:
|
||||||
- Manage BIG-IP global settings.
|
- Manage BIG-IP global settings.
|
||||||
version_added: "2.3"
|
version_added: "2.3"
|
||||||
|
@ -84,75 +88,80 @@ author:
|
||||||
- Tim Rupp (@caphrim007)
|
- Tim Rupp (@caphrim007)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = r'''
|
||||||
- name: Disable the setup utility
|
- name: Disable the setup utility
|
||||||
bigip_sys_global:
|
bigip_sys_global:
|
||||||
gui_setup: "disabled"
|
gui_setup: disabled
|
||||||
password: "secret"
|
password: secret
|
||||||
server: "lb.mydomain.com"
|
server: lb.mydomain.com
|
||||||
user: "admin"
|
user: admin
|
||||||
state: "present"
|
state: present
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = r'''
|
||||||
banner_text:
|
banner_text:
|
||||||
description: The new text to present in the advisory banner.
|
description: The new text to present in the advisory banner.
|
||||||
returned: changed
|
returned: changed
|
||||||
type: string
|
type: string
|
||||||
sample: "This is a corporate device. Do not touch."
|
sample: This is a corporate device. Do not touch.
|
||||||
console_timeout:
|
console_timeout:
|
||||||
description: >
|
description: >
|
||||||
The new number of seconds of inactivity before the system
|
The new number of seconds of inactivity before the system
|
||||||
logs off a user that is logged on.
|
logs off a user that is logged on.
|
||||||
returned: changed
|
returned: changed
|
||||||
type: int
|
type: int
|
||||||
sample: 600
|
sample: 600
|
||||||
gui_setup:
|
gui_setup:
|
||||||
description: The new setting for the Setup utility.
|
description: The new setting for the Setup utility.
|
||||||
returned: changed
|
returned: changed
|
||||||
type: string
|
type: string
|
||||||
sample: enabled
|
sample: enabled
|
||||||
lcd_display:
|
lcd_display:
|
||||||
description: The new setting for displaying the system menu on the LCD.
|
description: The new setting for displaying the system menu on the LCD.
|
||||||
returned: changed
|
returned: changed
|
||||||
type: string
|
type: string
|
||||||
sample: enabled
|
sample: enabled
|
||||||
mgmt_dhcp:
|
mgmt_dhcp:
|
||||||
description: >
|
description: The new setting for whether the mgmt interface should DHCP or not.
|
||||||
The new setting for whether the mgmt interface should DHCP
|
returned: changed
|
||||||
or not
|
type: string
|
||||||
returned: changed
|
sample: enabled
|
||||||
type: string
|
|
||||||
sample: enabled
|
|
||||||
net_reboot:
|
net_reboot:
|
||||||
description: >
|
description: The new setting for whether the system should boot to an ISO on the network or not.
|
||||||
The new setting for whether the system should boot to an ISO on the
|
returned: changed
|
||||||
network or not
|
type: string
|
||||||
returned: changed
|
sample: enabled
|
||||||
type: string
|
|
||||||
sample: enabled
|
|
||||||
quiet_boot:
|
quiet_boot:
|
||||||
description: >
|
description: >
|
||||||
The new setting for whether the system should suppress information to
|
The new setting for whether the system should suppress information to
|
||||||
the console during boot or not.
|
the console during boot or not.
|
||||||
returned: changed
|
returned: changed
|
||||||
type: string
|
type: string
|
||||||
sample: enabled
|
sample: enabled
|
||||||
security_banner:
|
security_banner:
|
||||||
description: >
|
description: >
|
||||||
The new setting for whether the system should display an advisory message
|
The new setting for whether the system should display an advisory message
|
||||||
on the login screen or not
|
on the login screen or not.
|
||||||
returned: changed
|
returned: changed
|
||||||
type: string
|
type: string
|
||||||
sample: enabled
|
sample: enabled
|
||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from f5.bigip.contexts import TransactionContextManager
|
from f5.bigip.contexts import TransactionContextManager
|
||||||
from f5.bigip import ManagementRoot
|
from f5.bigip import ManagementRoot
|
||||||
from icontrol.session import iControlUnexpectedHTTPError
|
except ImportError:
|
||||||
HAS_F5SDK = True
|
pass # Handled via f5_utils.HAS_F5SDK
|
||||||
|
|
||||||
|
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
|
||||||
|
from ansible.module_utils.f5_utils import HAS_F5SDK
|
||||||
|
from ansible.module_utils.f5_utils import f5_argument_spec
|
||||||
|
|
||||||
|
try:
|
||||||
|
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_F5SDK = False
|
HAS_F5SDK = False
|
||||||
|
|
||||||
|
@ -345,35 +354,23 @@ class BigIpSysGlobalModuleConfig(object):
|
||||||
def initialize_meta_args(self):
|
def initialize_meta_args(self):
|
||||||
args = dict(
|
args = dict(
|
||||||
security_banner=dict(
|
security_banner=dict(
|
||||||
required=False,
|
choices=self.on_off_choices
|
||||||
choices=self.on_off_choices,
|
|
||||||
default=None
|
|
||||||
),
|
),
|
||||||
banner_text=dict(required=False, default=None),
|
banner_text=dict(),
|
||||||
gui_setup=dict(
|
gui_setup=dict(
|
||||||
required=False,
|
choices=self.on_off_choices
|
||||||
choices=self.on_off_choices,
|
|
||||||
default=None
|
|
||||||
),
|
),
|
||||||
lcd_display=dict(
|
lcd_display=dict(
|
||||||
required=False,
|
choices=self.on_off_choices
|
||||||
choices=self.on_off_choices,
|
|
||||||
default=None
|
|
||||||
),
|
),
|
||||||
mgmt_dhcp=dict(
|
mgmt_dhcp=dict(
|
||||||
required=False,
|
choices=self.on_off_choices
|
||||||
choices=self.on_off_choices,
|
|
||||||
default=None
|
|
||||||
),
|
),
|
||||||
net_reboot=dict(
|
net_reboot=dict(
|
||||||
required=False,
|
choices=self.on_off_choices
|
||||||
choices=self.on_off_choices,
|
|
||||||
default=None
|
|
||||||
),
|
),
|
||||||
quiet_boot=dict(
|
quiet_boot=dict(
|
||||||
required=False,
|
choices=self.on_off_choices
|
||||||
choices=self.on_off_choices,
|
|
||||||
default=None
|
|
||||||
),
|
),
|
||||||
console_timeout=dict(required=False, type='int', default=None),
|
console_timeout=dict(required=False, type='int', default=None),
|
||||||
state=dict(default='present', choices=['present'])
|
state=dict(default='present', choices=['present'])
|
||||||
|
@ -408,9 +405,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()
|
||||||
|
|
|
@ -15,21 +15,23 @@ if sys.version_info < (2, 7):
|
||||||
raise SkipTest("F5 Ansible modules require Python >= 2.7")
|
raise SkipTest("F5 Ansible modules require Python >= 2.7")
|
||||||
|
|
||||||
from ansible.compat.tests import unittest
|
from ansible.compat.tests import unittest
|
||||||
from ansible.compat.tests.mock import patch, Mock
|
from ansible.compat.tests.mock import Mock
|
||||||
|
from ansible.compat.tests.mock import patch
|
||||||
from ansible.module_utils.f5_utils import AnsibleF5Client
|
from ansible.module_utils.f5_utils import AnsibleF5Client
|
||||||
from units.modules.utils import set_module_args
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from library.bigip_iapp_service import Parameters
|
from library.bigip_iapp_service import Parameters
|
||||||
from library.bigip_iapp_service import ModuleManager
|
from library.bigip_iapp_service import ModuleManager
|
||||||
from library.bigip_iapp_service import ArgumentSpec
|
from library.bigip_iapp_service import ArgumentSpec
|
||||||
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||||
|
from test.unit.modules.utils import set_module_args
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from ansible.modules.network.f5.bigip_iapp_service import Parameters
|
from ansible.modules.network.f5.bigip_iapp_service import Parameters
|
||||||
from ansible.modules.network.f5.bigip_iapp_service import ModuleManager
|
from ansible.modules.network.f5.bigip_iapp_service import ModuleManager
|
||||||
from ansible.modules.network.f5.bigip_iapp_service import ArgumentSpec
|
from ansible.modules.network.f5.bigip_iapp_service import ArgumentSpec
|
||||||
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||||
|
from units.modules.utils import set_module_args
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
|
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
|
||||||
|
|
||||||
|
|
|
@ -15,21 +15,23 @@ if sys.version_info < (2, 7):
|
||||||
raise SkipTest("F5 Ansible modules require Python >= 2.7")
|
raise SkipTest("F5 Ansible modules require Python >= 2.7")
|
||||||
|
|
||||||
from ansible.compat.tests import unittest
|
from ansible.compat.tests import unittest
|
||||||
from ansible.compat.tests.mock import patch, Mock
|
from ansible.compat.tests.mock import Mock
|
||||||
|
from ansible.compat.tests.mock import patch
|
||||||
from ansible.module_utils.f5_utils import AnsibleF5Client
|
from ansible.module_utils.f5_utils import AnsibleF5Client
|
||||||
from units.modules.utils import set_module_args
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from library.bigip_iapp_template import Parameters
|
from library.bigip_iapp_template import Parameters
|
||||||
from library.bigip_iapp_template import ModuleManager
|
from library.bigip_iapp_template import ModuleManager
|
||||||
from library.bigip_iapp_template import ArgumentSpec
|
from library.bigip_iapp_template import ArgumentSpec
|
||||||
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||||
|
from test.unit.modules.utils import set_module_args
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from ansible.modules.network.f5.bigip_iapp_template import Parameters
|
from ansible.modules.network.f5.bigip_iapp_template import Parameters
|
||||||
from ansible.modules.network.f5.bigip_iapp_template import ArgumentSpec
|
from ansible.modules.network.f5.bigip_iapp_template import ArgumentSpec
|
||||||
from ansible.modules.network.f5.bigip_iapp_template import ModuleManager
|
from ansible.modules.network.f5.bigip_iapp_template import ModuleManager
|
||||||
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||||
|
from units.modules.utils import set_module_args
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
|
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue