| 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_fmupdate_fwmsetting |
| 15 |
short_description: Configure firmware management settings. |
| 16 |
version_added: "2.1.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.partial_crud |
| 20 |
options: |
| 21 |
fmupdate_fwmsetting: |
| 22 |
description: The top level parameters set. |
| 23 |
required: false |
| 24 |
type: dict |
| 25 |
suboptions: |
| 26 |
fds_image_timeout: |
| 27 |
aliases: ['fds-image-timeout'] |
| 28 |
type: int |
| 29 |
description: Timer for fgt download image from fortiguard |
| 30 |
max_fds_retry: |
| 31 |
aliases: ['max-fds-retry'] |
| 32 |
type: int |
| 33 |
description: The retries when fgt download from fds fail |
| 34 |
multiple_steps_interval: |
| 35 |
aliases: ['multiple-steps-interval'] |
| 36 |
type: int |
| 37 |
description: Waiting time between multiple steps upgrade |
| 38 |
skip_disk_check: |
| 39 |
aliases: ['skip-disk-check'] |
| 40 |
type: str |
| 41 |
description: |
| 42 |
- skip disk check when upgrade image. |
| 43 |
- disable - Disable setting. |
| 44 |
- enable - Enable setting. |
| 45 |
choices: ['disable', 'enable'] |
| 46 |
auto_scan_fgt_disk: |
| 47 |
aliases: ['auto-scan-fgt-disk'] |
| 48 |
type: str |
| 49 |
description: |
| 50 |
- auto scan fgt disk if needed. |
| 51 |
- disable - Disable setting. |
| 52 |
- enable - Enable setting. |
| 53 |
choices: ['disable', 'enable'] |
| 54 |
check_fgt_disk: |
| 55 |
aliases: ['check-fgt-disk'] |
| 56 |
type: str |
| 57 |
description: |
| 58 |
- check fgt disk before upgrade image. |
| 59 |
- disable - Disable setting. |
| 60 |
- enable - Enable setting. |
| 61 |
choices: ['disable', 'enable'] |
| 62 |
fds_failover_fmg: |
| 63 |
aliases: ['fds-failover-fmg'] |
| 64 |
type: str |
| 65 |
description: |
| 66 |
- using fmg local image file is download from fds fails. |
| 67 |
- disable - Disable setting. |
| 68 |
- enable - Enable setting. |
| 69 |
choices: ['disable', 'enable'] |
| 70 |
immx_source: |
| 71 |
aliases: ['immx-source'] |
| 72 |
type: str |
| 73 |
description: |
| 74 |
- Configure which of IMMX file to be used for choosing upgrade pach. |
| 75 |
- fmg - Use IMMX file for FortiManager |
| 76 |
- fgt - Use IMMX file for FortiGate |
| 77 |
- cloud - Use IMMX file for FortiCloud |
| 78 |
choices: ['fmg', 'fgt', 'cloud'] |
| 79 |
log: |
| 80 |
type: str |
| 81 |
description: |
| 82 |
- Configure log setting for fwm daemon |
| 83 |
- fwm - FWM daemon log |
| 84 |
- fwm_dm - FWM and Deployment service log |
| 85 |
- fwm_dm_json - FWM and Deployment service log with JSON data between FMG-FGT |
| 86 |
choices: ['fwm', 'fwm_dm', 'fwm_dm_json'] |
| 87 |
upgrade_timeout: |
| 88 |
aliases: ['upgrade-timeout'] |
| 89 |
type: dict |
| 90 |
description: Upgrade timeout. |
| 91 |
suboptions: |
| 92 |
check_status_timeout: |
| 93 |
aliases: ['check-status-timeout'] |
| 94 |
type: int |
| 95 |
description: Timeout for checking status after tunnnel is up. |
| 96 |
ctrl_check_status_timeout: |
| 97 |
aliases: ['ctrl-check-status-timeout'] |
| 98 |
type: int |
| 99 |
description: Timeout for checking fap/fsw/fext status after request upgrade. |
| 100 |
ctrl_put_image_by_fds_timeout: |
| 101 |
aliases: ['ctrl-put-image-by-fds-timeout'] |
| 102 |
type: int |
| 103 |
description: Timeout for waiting device get fap/fsw/fext image from fortiguard. |
| 104 |
ha_sync_timeout: |
| 105 |
aliases: ['ha-sync-timeout'] |
| 106 |
type: int |
| 107 |
description: Timeout for waiting HA sync. |
| 108 |
license_check_timeout: |
| 109 |
aliases: ['license-check-timeout'] |
| 110 |
type: int |
| 111 |
description: Timeout for waiting fortigate check license. |
| 112 |
prepare_image_timeout: |
| 113 |
aliases: ['prepare-image-timeout'] |
| 114 |
type: int |
| 115 |
description: Timeout for preparing image. |
| 116 |
put_image_by_fds_timeout: |
| 117 |
aliases: ['put-image-by-fds-timeout'] |
| 118 |
type: int |
| 119 |
description: Timeout for waiting device get image from fortiguard. |
| 120 |
put_image_timeout: |
| 121 |
aliases: ['put-image-timeout'] |
| 122 |
type: int |
| 123 |
description: Timeout for waiting send image over tunnel. |
| 124 |
reboot_of_fsck_timeout: |
| 125 |
aliases: ['reboot-of-fsck-timeout'] |
| 126 |
type: int |
| 127 |
description: Timeout for waiting fortigate reboot. |
| 128 |
reboot_of_upgrade_timeout: |
| 129 |
aliases: ['reboot-of-upgrade-timeout'] |
| 130 |
type: int |
| 131 |
description: Timeout for waiting fortigate reboot after image upgrade. |
| 132 |
retrieve_timeout: |
| 133 |
aliases: ['retrieve-timeout'] |
| 134 |
type: int |
| 135 |
description: Timeout for waiting retrieve. |
| 136 |
rpc_timeout: |
| 137 |
aliases: ['rpc-timeout'] |
| 138 |
type: int |
| 139 |
description: Timeout for waiting fortigate rpc response. |
| 140 |
total_timeout: |
| 141 |
aliases: ['total-timeout'] |
| 142 |
type: int |
| 143 |
description: Timeout for the whole fortigate upgrade |
| 144 |
health_check_timeout: |
| 145 |
aliases: ['health-check-timeout'] |
| 146 |
type: int |
| 147 |
description: Timeout for waiting retrieve. |
| 148 |
retry_interval: |
| 149 |
aliases: ['retry-interval'] |
| 150 |
type: int |
| 151 |
description: Waiting time for resending request to device |
| 152 |
retry_max: |
| 153 |
aliases: ['retry-max'] |
| 154 |
type: int |
| 155 |
description: Max retry times |
| 156 |
health_check: |
| 157 |
aliases: ['health-check'] |
| 158 |
type: str |
| 159 |
description: |
| 160 |
- do health check after upgrade |
| 161 |
- disable - Disable setting. |
| 162 |
- enable - Enable setting. |
| 163 |
choices: ['disable', 'enable'] |
| 164 |
max_device_history: |
| 165 |
aliases: ['max-device-history'] |
| 166 |
type: int |
| 167 |
description: Max number of device upgrade report |
| 168 |
max_profile_history: |
| 169 |
aliases: ['max-profile-history'] |
| 170 |
type: int |
| 171 |
description: Max number of profile upgrade report |
| 172 |
retrieve: |
| 173 |
type: str |
| 174 |
description: |
| 175 |
- do retrieve after upgrade |
| 176 |
- disable - Disable setting. |
| 177 |
- enable - Enable setting. |
| 178 |
choices: ['disable', 'enable'] |
| 179 |
revision_diff: |
| 180 |
aliases: ['revision-diff'] |
| 181 |
type: str |
| 182 |
description: |
| 183 |
- calculate diff script after upgrade |
| 184 |
- disable - Disable setting. |
| 185 |
- enable - Enable setting. |
| 186 |
choices: ['disable', 'enable'] |
| 187 |
send_image_retry: |
| 188 |
aliases: ['send-image-retry'] |
| 189 |
type: int |
| 190 |
description: Retry send image when failed |
| 191 |
''' |
| 192 |
|
| 193 |
EXAMPLES = ''' |
| 194 |
- name: Example playbook (generated based on argument schema) |
| 195 |
hosts: fortimanagers |
| 196 |
connection: httpapi |
| 197 |
gather_facts: false |
| 198 |
tasks: |
| 199 |
- name: Configure firmware management settings. |
| 200 |
fortinet.fortimanager.fmgr_fmupdate_fwmsetting: |
| 201 |
# workspace_locking_adom: <global or your adom name> |
| 202 |
fmupdate_fwmsetting: |
| 203 |
# fds_image_timeout: <integer> |
| 204 |
# max_fds_retry: <integer> |
| 205 |
# multiple_steps_interval: <integer> |
| 206 |
# skip_disk_check: <value in [disable, enable]> |
| 207 |
# auto_scan_fgt_disk: <value in [disable, enable]> |
| 208 |
# check_fgt_disk: <value in [disable, enable]> |
| 209 |
# fds_failover_fmg: <value in [disable, enable]> |
| 210 |
# immx_source: <value in [fmg, fgt, cloud]> |
| 211 |
# log: <value in [fwm, fwm_dm, fwm_dm_json]> |
| 212 |
# upgrade_timeout: |
| 213 |
# check_status_timeout: <integer> |
| 214 |
# ctrl_check_status_timeout: <integer> |
| 215 |
# ctrl_put_image_by_fds_timeout: <integer> |
| 216 |
# ha_sync_timeout: <integer> |
| 217 |
# license_check_timeout: <integer> |
| 218 |
# prepare_image_timeout: <integer> |
| 219 |
# put_image_by_fds_timeout: <integer> |
| 220 |
# put_image_timeout: <integer> |
| 221 |
# reboot_of_fsck_timeout: <integer> |
| 222 |
# reboot_of_upgrade_timeout: <integer> |
| 223 |
# retrieve_timeout: <integer> |
| 224 |
# rpc_timeout: <integer> |
| 225 |
# total_timeout: <integer> |
| 226 |
# health_check_timeout: <integer> |
| 227 |
# retry_interval: <integer> |
| 228 |
# retry_max: <integer> |
| 229 |
# health_check: <value in [disable, enable]> |
| 230 |
# max_device_history: <integer> |
| 231 |
# max_profile_history: <integer> |
| 232 |
# retrieve: <value in [disable, enable]> |
| 233 |
# revision_diff: <value in [disable, enable]> |
| 234 |
# send_image_retry: <integer> |
| 235 |
''' |
| 236 |
|
| 237 |
RETURN = ''' |
| 238 |
meta: |
| 239 |
description: The result of the request. |
| 240 |
type: dict |
| 241 |
returned: always |
| 242 |
contains: |
| 243 |
request_url: |
| 244 |
description: The full url requested. |
| 245 |
returned: always |
| 246 |
type: str |
| 247 |
sample: /sys/login/user |
| 248 |
response_code: |
| 249 |
description: The status of api request. |
| 250 |
returned: always |
| 251 |
type: int |
| 252 |
sample: 0 |
| 253 |
response_data: |
| 254 |
description: The api response. |
| 255 |
type: list |
| 256 |
returned: always |
| 257 |
response_message: |
| 258 |
description: The descriptive message of the api response. |
| 259 |
type: str |
| 260 |
returned: always |
| 261 |
sample: OK. |
| 262 |
system_information: |
| 263 |
description: The information of the target system. |
| 264 |
type: dict |
| 265 |
returned: always |
| 266 |
rc: |
| 267 |
description: The status the request. |
| 268 |
type: int |
| 269 |
returned: always |
| 270 |
sample: 0 |
| 271 |
version_check_warning: |
| 272 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 273 |
type: list |
| 274 |
returned: complex |
| 275 |
''' |
| 276 |
from ansible.module_utils.basic import AnsibleModule |
| 277 |
from ansible.module_utils.connection import Connection |
| 278 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 279 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 280 |
|
| 281 |
|
| 282 |
def main(): |
| 283 |
urls_list = [ |
| 284 |
'/cli/global/fmupdate/fwm-setting' |
| 285 |
] |
| 286 |
module_arg_spec = { |
| 287 |
'fmupdate_fwmsetting': { |
| 288 |
'type': 'dict', 'v_range': [['6.2.2', '']], |
| 289 |
'options': { |
| 290 |
'fds-image-timeout': {'v_range': [['6.2.2', '']], 'type': 'int'}, |
| 291 |
'max-fds-retry': {'v_range': [['6.2.2', '6.2.3']], 'type': 'int'}, |
| 292 |
'multiple-steps-interval': {'v_range': [['6.2.2', '']], 'type': 'int'}, |
| 293 |
'skip-disk-check': {'v_range': [['6.2.2', '6.2.3']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 294 |
'auto-scan-fgt-disk': {'v_range': [['6.2.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 295 |
'check-fgt-disk': {'v_range': [['6.2.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 296 |
'fds-failover-fmg': {'v_range': [['6.2.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 297 |
'immx-source': {'v_range': [['6.4.2', '']], 'choices': ['fmg', 'fgt', 'cloud'], 'type': 'str'}, |
| 298 |
'log': {'v_range': [['6.4.8', '6.4.15'], ['7.0.1', '']], 'choices': ['fwm', 'fwm_dm', 'fwm_dm_json'], 'type': 'str'}, |
| 299 |
'upgrade-timeout': { |
| 300 |
'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], |
| 301 |
'type': 'dict', |
| 302 |
'options': { |
| 303 |
'check-status-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 304 |
'ctrl-check-status-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 305 |
'ctrl-put-image-by-fds-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 306 |
'ha-sync-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 307 |
'license-check-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 308 |
'prepare-image-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 309 |
'put-image-by-fds-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 310 |
'put-image-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 311 |
'reboot-of-fsck-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 312 |
'reboot-of-upgrade-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 313 |
'retrieve-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 314 |
'rpc-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 315 |
'total-timeout': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'type': 'int'}, |
| 316 |
'health-check-timeout': {'v_range': [['7.4.2', '']], 'type': 'int'} |
| 317 |
} |
| 318 |
}, |
| 319 |
'retry-interval': {'v_range': [['7.0.10', '7.0.16'], ['7.2.5', '7.2.12'], ['7.4.2', '']], 'type': 'int'}, |
| 320 |
'retry-max': {'v_range': [['7.0.10', '7.0.16'], ['7.2.5', '7.2.12'], ['7.4.2', '']], 'type': 'int'}, |
| 321 |
'health-check': {'v_range': [['7.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 322 |
'max-device-history': {'v_range': [['7.4.2', '']], 'type': 'int'}, |
| 323 |
'max-profile-history': {'v_range': [['7.4.2', '']], 'type': 'int'}, |
| 324 |
'retrieve': {'v_range': [['7.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 325 |
'revision-diff': {'v_range': [['7.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 326 |
'send-image-retry': {'v_range': [['7.2.6', '7.2.12'], ['7.4.4', '7.4.10'], ['7.6.2', '']], 'type': 'int'} |
| 327 |
} |
| 328 |
} |
| 329 |
} |
| 330 |
|
| 331 |
module_option_spec = get_module_arg_spec('partial crud') |
| 332 |
module_arg_spec.update(module_option_spec) |
| 333 |
check_galaxy_version(module_arg_spec) |
| 334 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'fmupdate_fwmsetting'), |
| 335 |
supports_check_mode=True) |
| 336 |
if not module._socket_path: |
| 337 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 338 |
connection = Connection(module._socket_path) |
| 339 |
fmgr = NAPIManager('partial crud', module_arg_spec, urls_list, |
| 340 |
None, 'data', module, connection) |
| 341 |
fmgr.process_partial_crud() |
| 342 |
module.exit_json(meta=module.params) |
| 343 |
|
| 344 |
|
| 345 |
if __name__ == '__main__': |
| 346 |
main() |