| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
__metaclass__ = type |
| 7 |
|
| 8 |
ANSIBLE_METADATA = {'status': ['preview'], |
| 9 |
'supported_by': 'community', |
| 10 |
'metadata_version': '1.1'} |
| 11 |
|
| 12 |
DOCUMENTATION = ''' |
| 13 |
--- |
| 14 |
module: fmgr_system_dm |
| 15 |
short_description: Configure dm. |
| 16 |
version_added: "2.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.partial_crud |
| 20 |
options: |
| 21 |
system_dm: |
| 22 |
description: The top level parameters set. |
| 23 |
required: false |
| 24 |
type: dict |
| 25 |
suboptions: |
| 26 |
concurrent_install_image_limit: |
| 27 |
aliases: ['concurrent-install-image-limit'] |
| 28 |
type: int |
| 29 |
description: Maximum number of concurrent install image |
| 30 |
concurrent_install_limit: |
| 31 |
aliases: ['concurrent-install-limit'] |
| 32 |
type: int |
| 33 |
description: Maximum number of concurrent installs |
| 34 |
concurrent_install_script_limit: |
| 35 |
aliases: ['concurrent-install-script-limit'] |
| 36 |
type: int |
| 37 |
description: Maximum number of concurrent install scripts |
| 38 |
discover_timeout: |
| 39 |
aliases: ['discover-timeout'] |
| 40 |
type: int |
| 41 |
description: Check connection timeout when discover device |
| 42 |
dpm_logsize: |
| 43 |
aliases: ['dpm-logsize'] |
| 44 |
type: int |
| 45 |
description: Maximum dpm log size per device |
| 46 |
fgfm_sock_timeout: |
| 47 |
aliases: ['fgfm-sock-timeout'] |
| 48 |
type: int |
| 49 |
description: Maximum FGFM socket idle time |
| 50 |
fgfm_keepalive_itvl: |
| 51 |
type: int |
| 52 |
description: FGFM protocol keep alive interval |
| 53 |
force_remote_diff: |
| 54 |
aliases: ['force-remote-diff'] |
| 55 |
type: str |
| 56 |
description: |
| 57 |
- Always use remote diff when installing. |
| 58 |
- disable - Disable. |
| 59 |
- enable - Enable. |
| 60 |
choices: ['disable', 'enable'] |
| 61 |
fortiap_refresh_cnt: |
| 62 |
aliases: ['fortiap-refresh-cnt'] |
| 63 |
type: int |
| 64 |
description: Max auto refresh FortiAP number each time |
| 65 |
fortiap_refresh_itvl: |
| 66 |
aliases: ['fortiap-refresh-itvl'] |
| 67 |
type: int |
| 68 |
description: Auto refresh FortiAP status interval |
| 69 |
fortiext_refresh_cnt: |
| 70 |
aliases: ['fortiext-refresh-cnt'] |
| 71 |
type: int |
| 72 |
description: Max device number for FortiExtender auto refresh |
| 73 |
install_image_timeout: |
| 74 |
aliases: ['install-image-timeout'] |
| 75 |
type: int |
| 76 |
description: Maximum waiting time for image transfer and device upgrade |
| 77 |
install_tunnel_retry_itvl: |
| 78 |
aliases: ['install-tunnel-retry-itvl'] |
| 79 |
type: int |
| 80 |
description: Time to re-establish tunnel during install |
| 81 |
max_revs: |
| 82 |
aliases: ['max-revs'] |
| 83 |
type: int |
| 84 |
description: Maximum number of revisions saved |
| 85 |
nr_retry: |
| 86 |
aliases: ['nr-retry'] |
| 87 |
type: int |
| 88 |
description: Number of retries. |
| 89 |
retry: |
| 90 |
type: str |
| 91 |
description: |
| 92 |
- Enable/disable configuration install retry. |
| 93 |
- disable - Disable. |
| 94 |
- enable - Enable. |
| 95 |
choices: ['disable', 'enable'] |
| 96 |
retry_intvl: |
| 97 |
aliases: ['retry-intvl'] |
| 98 |
type: int |
| 99 |
description: Retry interval. |
| 100 |
rollback_allow_reboot: |
| 101 |
aliases: ['rollback-allow-reboot'] |
| 102 |
type: str |
| 103 |
description: |
| 104 |
- Enable/disable FortiGate reboot to rollback when installing script/config. |
| 105 |
- disable - Disable. |
| 106 |
- enable - Enable. |
| 107 |
choices: ['disable', 'enable'] |
| 108 |
script_logsize: |
| 109 |
aliases: ['script-logsize'] |
| 110 |
type: int |
| 111 |
description: Maximum script log size per device |
| 112 |
skip_scep_check: |
| 113 |
aliases: ['skip-scep-check'] |
| 114 |
type: str |
| 115 |
description: |
| 116 |
- Enable/disable installing scep related objects even if scep url is configured. |
| 117 |
- disable - Disable. |
| 118 |
- enable - Enable. |
| 119 |
choices: ['disable', 'enable'] |
| 120 |
skip_tunnel_fcp_req: |
| 121 |
aliases: ['skip-tunnel-fcp-req'] |
| 122 |
type: str |
| 123 |
description: |
| 124 |
- Enable/disable skip the fcp request sent from fgfm tunnel |
| 125 |
- disable - Disable. |
| 126 |
- enable - Enable. |
| 127 |
choices: ['disable', 'enable'] |
| 128 |
verify_install: |
| 129 |
aliases: ['verify-install'] |
| 130 |
type: str |
| 131 |
description: |
| 132 |
- Verify install against remote configuration. |
| 133 |
- disable - Disable. |
| 134 |
- optimal - Verify installation for command errors. |
| 135 |
- enable - Always verify installation. |
| 136 |
choices: ['disable', 'optimal', 'enable'] |
| 137 |
fgfm_install_refresh_count: |
| 138 |
aliases: ['fgfm-install-refresh-count'] |
| 139 |
type: int |
| 140 |
description: Maximum FGFM install refresh attempt. |
| 141 |
conf_merge_after_script: |
| 142 |
aliases: ['conf-merge-after-script'] |
| 143 |
type: str |
| 144 |
description: |
| 145 |
- Merge config after run script on remote device, instead of full retrieve. |
| 146 |
- disable - Disable. |
| 147 |
- enable - Enable. |
| 148 |
choices: ['disable', 'enable'] |
| 149 |
log_autoupdate: |
| 150 |
aliases: ['log-autoupdate'] |
| 151 |
type: str |
| 152 |
description: |
| 153 |
- Enable/disable autoupdate debug logging. |
| 154 |
- disable - Disable. |
| 155 |
- enable - Enable. |
| 156 |
choices: ['disable', 'enable'] |
| 157 |
fgfm_auto_retrieve_timeout: |
| 158 |
aliases: ['fgfm-auto-retrieve-timeout'] |
| 159 |
type: int |
| 160 |
description: Maximum waiting time for auto retrieve |
| 161 |
install_fds_timeout: |
| 162 |
aliases: ['install-fds-timeout'] |
| 163 |
type: int |
| 164 |
description: Maximum waiting time for fgt update during install |
| 165 |
handle_nonhasync_config: |
| 166 |
aliases: ['handle-nonhasync-config'] |
| 167 |
type: str |
| 168 |
description: |
| 169 |
- Enable/disable nonhasync config handling. |
| 170 |
- disable - Disable. |
| 171 |
- enable - Enable. |
| 172 |
choices: ['disable', 'enable'] |
| 173 |
autoupdate_merge_revision: |
| 174 |
aliases: ['autoupdate-merge-revision'] |
| 175 |
type: str |
| 176 |
description: Autoupdate merge revision. |
| 177 |
choices: ['disable', 'enable'] |
| 178 |
''' |
| 179 |
|
| 180 |
EXAMPLES = ''' |
| 181 |
- name: Example playbook (generated based on argument schema) |
| 182 |
hosts: fortimanagers |
| 183 |
connection: httpapi |
| 184 |
gather_facts: false |
| 185 |
tasks: |
| 186 |
- name: Configure dm. |
| 187 |
fortinet.fortimanager.fmgr_system_dm: |
| 188 |
# workspace_locking_adom: <global or your adom name> |
| 189 |
system_dm: |
| 190 |
# concurrent_install_image_limit: <integer> |
| 191 |
# concurrent_install_limit: <integer> |
| 192 |
# concurrent_install_script_limit: <integer> |
| 193 |
# discover_timeout: <integer> |
| 194 |
# dpm_logsize: <integer> |
| 195 |
# fgfm_sock_timeout: <integer> |
| 196 |
# fgfm_keepalive_itvl: <integer> |
| 197 |
# force_remote_diff: <value in [disable, enable]> |
| 198 |
# fortiap_refresh_cnt: <integer> |
| 199 |
# fortiap_refresh_itvl: <integer> |
| 200 |
# fortiext_refresh_cnt: <integer> |
| 201 |
# install_image_timeout: <integer> |
| 202 |
# install_tunnel_retry_itvl: <integer> |
| 203 |
# max_revs: <integer> |
| 204 |
# nr_retry: <integer> |
| 205 |
# retry: <value in [disable, enable]> |
| 206 |
# retry_intvl: <integer> |
| 207 |
# rollback_allow_reboot: <value in [disable, enable]> |
| 208 |
# script_logsize: <integer> |
| 209 |
# skip_scep_check: <value in [disable, enable]> |
| 210 |
# skip_tunnel_fcp_req: <value in [disable, enable]> |
| 211 |
# verify_install: <value in [disable, optimal, enable]> |
| 212 |
# fgfm_install_refresh_count: <integer> |
| 213 |
# conf_merge_after_script: <value in [disable, enable]> |
| 214 |
# log_autoupdate: <value in [disable, enable]> |
| 215 |
# fgfm_auto_retrieve_timeout: <integer> |
| 216 |
# install_fds_timeout: <integer> |
| 217 |
# handle_nonhasync_config: <value in [disable, enable]> |
| 218 |
# autoupdate_merge_revision: <value in [disable, enable]> |
| 219 |
''' |
| 220 |
|
| 221 |
RETURN = ''' |
| 222 |
meta: |
| 223 |
description: The result of the request. |
| 224 |
type: dict |
| 225 |
returned: always |
| 226 |
contains: |
| 227 |
request_url: |
| 228 |
description: The full url requested. |
| 229 |
returned: always |
| 230 |
type: str |
| 231 |
sample: /sys/login/user |
| 232 |
response_code: |
| 233 |
description: The status of api request. |
| 234 |
returned: always |
| 235 |
type: int |
| 236 |
sample: 0 |
| 237 |
response_data: |
| 238 |
description: The api response. |
| 239 |
type: list |
| 240 |
returned: always |
| 241 |
response_message: |
| 242 |
description: The descriptive message of the api response. |
| 243 |
type: str |
| 244 |
returned: always |
| 245 |
sample: OK. |
| 246 |
system_information: |
| 247 |
description: The information of the target system. |
| 248 |
type: dict |
| 249 |
returned: always |
| 250 |
rc: |
| 251 |
description: The status the request. |
| 252 |
type: int |
| 253 |
returned: always |
| 254 |
sample: 0 |
| 255 |
version_check_warning: |
| 256 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 257 |
type: list |
| 258 |
returned: complex |
| 259 |
''' |
| 260 |
from ansible.module_utils.basic import AnsibleModule |
| 261 |
from ansible.module_utils.connection import Connection |
| 262 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 263 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 264 |
|
| 265 |
|
| 266 |
def main(): |
| 267 |
urls_list = [ |
| 268 |
'/cli/global/system/dm' |
| 269 |
] |
| 270 |
module_arg_spec = { |
| 271 |
'system_dm': { |
| 272 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 273 |
'options': { |
| 274 |
'concurrent-install-image-limit': {'type': 'int'}, |
| 275 |
'concurrent-install-limit': {'type': 'int'}, |
| 276 |
'concurrent-install-script-limit': {'type': 'int'}, |
| 277 |
'discover-timeout': {'type': 'int'}, |
| 278 |
'dpm-logsize': {'type': 'int'}, |
| 279 |
'fgfm-sock-timeout': {'type': 'int'}, |
| 280 |
'fgfm_keepalive_itvl': {'type': 'int'}, |
| 281 |
'force-remote-diff': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 282 |
'fortiap-refresh-cnt': {'type': 'int'}, |
| 283 |
'fortiap-refresh-itvl': {'type': 'int'}, |
| 284 |
'fortiext-refresh-cnt': {'type': 'int'}, |
| 285 |
'install-image-timeout': {'type': 'int'}, |
| 286 |
'install-tunnel-retry-itvl': {'type': 'int'}, |
| 287 |
'max-revs': {'type': 'int'}, |
| 288 |
'nr-retry': {'type': 'int'}, |
| 289 |
'retry': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 290 |
'retry-intvl': {'type': 'int'}, |
| 291 |
'rollback-allow-reboot': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 292 |
'script-logsize': {'type': 'int'}, |
| 293 |
'skip-scep-check': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 294 |
'skip-tunnel-fcp-req': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 295 |
'verify-install': {'choices': ['disable', 'optimal', 'enable'], 'type': 'str'}, |
| 296 |
'fgfm-install-refresh-count': {'v_range': [['6.2.5', '']], 'type': 'int'}, |
| 297 |
'conf-merge-after-script': {'v_range': [['6.2.7', '6.2.13'], ['6.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 298 |
'log-autoupdate': { |
| 299 |
'v_range': [['6.4.12', '6.4.15'], ['7.0.9', '7.0.16'], ['7.2.4', '7.2.12'], ['7.4.1', '']], |
| 300 |
'choices': ['disable', 'enable'], |
| 301 |
'type': 'str' |
| 302 |
}, |
| 303 |
'fgfm-auto-retrieve-timeout': {'v_range': [['6.4.13', '6.4.15'], ['7.0.9', '7.0.16'], ['7.2.4', '7.2.12'], ['7.4.1', '']], 'type': 'int'}, |
| 304 |
'install-fds-timeout': {'v_range': [['7.2.6', '7.2.12'], ['7.4.1', '']], 'type': 'int'}, |
| 305 |
'handle-nonhasync-config': { |
| 306 |
'v_range': [['7.2.11', '7.2.12'], ['7.4.7', '7.4.10'], ['7.6.3', '']], |
| 307 |
'choices': ['disable', 'enable'], |
| 308 |
'type': 'str' |
| 309 |
}, |
| 310 |
'autoupdate-merge-revision': {'v_range': [['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'} |
| 311 |
} |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 315 |
module_option_spec = get_module_arg_spec('partial crud') |
| 316 |
module_arg_spec.update(module_option_spec) |
| 317 |
check_galaxy_version(module_arg_spec) |
| 318 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_dm'), |
| 319 |
supports_check_mode=True) |
| 320 |
if not module._socket_path: |
| 321 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 322 |
connection = Connection(module._socket_path) |
| 323 |
fmgr = NAPIManager('partial crud', module_arg_spec, urls_list, |
| 324 |
None, 'data', module, connection) |
| 325 |
fmgr.process_partial_crud() |
| 326 |
module.exit_json(meta=module.params) |
| 327 |
|
| 328 |
|
| 329 |
if __name__ == '__main__': |
| 330 |
main() |