mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-23 08:40:22 -07:00
Minor fixes and additions to f5 modules (#39987)
* Fixes to docs * Fix escaping quotes in bigip_command * F5 coding conventions cleanup * “warn” and “chdir” parameters added to bigip_command
This commit is contained in:
parent
fff7915faa
commit
48e5791860
10 changed files with 553 additions and 244 deletions
|
@ -24,7 +24,7 @@ description:
|
|||
configuration to disk. Since the F5 module only manipulate running
|
||||
configuration, it is important that you utilize this module to save
|
||||
that running config.
|
||||
version_added: "2.4"
|
||||
version_added: 2.4
|
||||
options:
|
||||
save:
|
||||
description:
|
||||
|
@ -38,23 +38,25 @@ options:
|
|||
default: no
|
||||
reset:
|
||||
description:
|
||||
- Loads the default configuration on the device. If this option
|
||||
is specified, the default configuration will be loaded before
|
||||
any commands or other provided configuration is run.
|
||||
- Loads the default configuration on the device.
|
||||
- If this option is specified, the default configuration will be
|
||||
loaded before any commands or other provided configuration is run.
|
||||
type: bool
|
||||
default: no
|
||||
merge_content:
|
||||
description:
|
||||
- Loads the specified configuration that you want to merge into
|
||||
the running configuration. This is equivalent to using the
|
||||
C(tmsh) command C(load sys config from-terminal merge). If
|
||||
you need to read configuration from a file or template, use
|
||||
C(tmsh) command C(load sys config from-terminal merge).
|
||||
- If you need to read configuration from a file or template, use
|
||||
Ansible's C(file) or C(template) lookup plugins respectively.
|
||||
verify:
|
||||
description:
|
||||
- Validates the specified configuration to see whether they are
|
||||
valid to replace the running configuration. The running
|
||||
configuration will not be changed.
|
||||
valid to replace the running configuration.
|
||||
- The running configuration will not be changed.
|
||||
- When this parameter is set to C(yes), no change will be reported
|
||||
by the module.
|
||||
type: bool
|
||||
default: no
|
||||
extends_documentation_fragment: f5
|
||||
|
@ -98,7 +100,6 @@ stdout:
|
|||
returned: always
|
||||
type: list
|
||||
sample: ['...', '...']
|
||||
|
||||
stdout_lines:
|
||||
description: The value of stdout split into a list
|
||||
returned: always
|
||||
|
@ -109,43 +110,36 @@ stdout_lines:
|
|||
import os
|
||||
import tempfile
|
||||
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
HAS_DEVEL_IMPORTS = False
|
||||
|
||||
try:
|
||||
# Sideband repository used for dev
|
||||
from library.module_utils.network.f5.bigip import HAS_F5SDK
|
||||
from library.module_utils.network.f5.bigip import F5Client
|
||||
from library.module_utils.network.f5.common import F5ModuleError
|
||||
from library.module_utils.network.f5.common import AnsibleF5Parameters
|
||||
from library.module_utils.network.f5.common import cleanup_tokens
|
||||
from library.module_utils.network.f5.common import fqdn_name
|
||||
from library.module_utils.network.f5.common import f5_argument_spec
|
||||
try:
|
||||
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||
except ImportError:
|
||||
HAS_F5SDK = False
|
||||
HAS_DEVEL_IMPORTS = True
|
||||
except ImportError:
|
||||
# Upstream Ansible
|
||||
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
|
||||
from ansible.module_utils.network.f5.bigip import F5Client
|
||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
||||
from ansible.module_utils.network.f5.common import AnsibleF5Parameters
|
||||
from ansible.module_utils.network.f5.common import cleanup_tokens
|
||||
from ansible.module_utils.network.f5.common import fqdn_name
|
||||
from ansible.module_utils.network.f5.common import f5_argument_spec
|
||||
try:
|
||||
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||
except ImportError:
|
||||
HAS_F5SDK = False
|
||||
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
|
||||
|
||||
class Parameters(AnsibleF5Parameters):
|
||||
returnables = ['stdout', 'stdout_lines']
|
||||
|
@ -182,15 +176,14 @@ class ModuleManager(object):
|
|||
return lines
|
||||
|
||||
def exec_module(self):
|
||||
result = dict()
|
||||
|
||||
result = {}
|
||||
try:
|
||||
self.execute()
|
||||
changed = self.execute()
|
||||
except iControlUnexpectedHTTPError as e:
|
||||
raise F5ModuleError(str(e))
|
||||
|
||||
result.update(**self.changes.to_return())
|
||||
result.update(dict(changed=True))
|
||||
result.update(dict(changed=changed))
|
||||
return result
|
||||
|
||||
def execute(self):
|
||||
|
@ -217,6 +210,9 @@ class ModuleManager(object):
|
|||
'stdout_lines': self._to_lines(responses)
|
||||
}
|
||||
self.changes = Parameters(params=changes)
|
||||
if self.want.verify:
|
||||
return False
|
||||
return True
|
||||
|
||||
def _detect_errors(self, stdout):
|
||||
errors = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue