| 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_ha |
| 15 |
short_description: HA configuration. |
| 16 |
version_added: "1.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.partial_crud |
| 20 |
options: |
| 21 |
system_ha: |
| 22 |
description: The top level parameters set. |
| 23 |
required: false |
| 24 |
type: dict |
| 25 |
suboptions: |
| 26 |
clusterid: |
| 27 |
type: int |
| 28 |
description: Cluster ID range |
| 29 |
file_quota: |
| 30 |
aliases: ['file-quota'] |
| 31 |
type: int |
| 32 |
description: File quota in MB |
| 33 |
hb_interval: |
| 34 |
aliases: ['hb-interval'] |
| 35 |
type: int |
| 36 |
description: Heartbeat interval |
| 37 |
hb_lost_threshold: |
| 38 |
aliases: ['hb-lost-threshold'] |
| 39 |
type: int |
| 40 |
description: Heartbeat lost threshold |
| 41 |
mode: |
| 42 |
type: str |
| 43 |
description: |
| 44 |
- Mode. |
| 45 |
- standalone - Standalone. |
| 46 |
- master - Master. |
| 47 |
- slave - Slave. |
| 48 |
choices: ['standalone', 'master', 'slave', 'primary', 'secondary'] |
| 49 |
password: |
| 50 |
type: raw |
| 51 |
description: (list) Group password. |
| 52 |
peer: |
| 53 |
type: list |
| 54 |
elements: dict |
| 55 |
description: Peer. |
| 56 |
suboptions: |
| 57 |
id: |
| 58 |
type: int |
| 59 |
description: Id. |
| 60 |
ip: |
| 61 |
type: str |
| 62 |
description: IP address of peer. |
| 63 |
ip6: |
| 64 |
type: str |
| 65 |
description: IP address |
| 66 |
serial_number: |
| 67 |
aliases: ['serial-number'] |
| 68 |
type: str |
| 69 |
description: Serial number of peer. |
| 70 |
status: |
| 71 |
type: str |
| 72 |
description: |
| 73 |
- Peer admin status. |
| 74 |
- disable - Disable. |
| 75 |
- enable - Enable. |
| 76 |
choices: ['disable', 'enable'] |
| 77 |
local_cert: |
| 78 |
aliases: ['local-cert'] |
| 79 |
type: str |
| 80 |
description: Set the ha local certificate. |
| 81 |
failover_mode: |
| 82 |
aliases: ['failover-mode'] |
| 83 |
type: str |
| 84 |
description: |
| 85 |
- HA failover mode. |
| 86 |
- manual - Manual Failove |
| 87 |
- vrrp - Use VRRP |
| 88 |
choices: ['manual', 'vrrp'] |
| 89 |
monitored_interfaces: |
| 90 |
aliases: ['monitored-interfaces'] |
| 91 |
type: list |
| 92 |
elements: dict |
| 93 |
description: Monitored interfaces. |
| 94 |
suboptions: |
| 95 |
interface_name: |
| 96 |
aliases: ['interface-name'] |
| 97 |
type: str |
| 98 |
description: Interface name. |
| 99 |
monitored_ips: |
| 100 |
aliases: ['monitored-ips'] |
| 101 |
type: list |
| 102 |
elements: dict |
| 103 |
description: Monitored ips. |
| 104 |
suboptions: |
| 105 |
id: |
| 106 |
type: int |
| 107 |
description: Id. |
| 108 |
interface: |
| 109 |
type: str |
| 110 |
description: Interface name. |
| 111 |
ip: |
| 112 |
type: str |
| 113 |
description: IP address. |
| 114 |
priority: |
| 115 |
type: int |
| 116 |
description: Runtime priority [1 |
| 117 |
unicast: |
| 118 |
type: str |
| 119 |
description: |
| 120 |
- Use unitcast for VRRP message. |
| 121 |
- disable - Disable. |
| 122 |
- enable - Enable. |
| 123 |
choices: ['disable', 'enable'] |
| 124 |
vip: |
| 125 |
type: str |
| 126 |
description: Virtual IP. |
| 127 |
vrrp_adv_interval: |
| 128 |
aliases: ['vrrp-adv-interval'] |
| 129 |
type: int |
| 130 |
description: VRRP advert interval [1 - 30 seconnds] |
| 131 |
vrrp_interface: |
| 132 |
aliases: ['vrrp-interface'] |
| 133 |
type: str |
| 134 |
description: VRRP and vip interface. |
| 135 |
vip_interface: |
| 136 |
aliases: ['vip-interface'] |
| 137 |
type: str |
| 138 |
description: Vip interface. |
| 139 |
''' |
| 140 |
|
| 141 |
EXAMPLES = ''' |
| 142 |
- name: Example playbook (generated based on argument schema) |
| 143 |
hosts: fortimanagers |
| 144 |
connection: httpapi |
| 145 |
gather_facts: false |
| 146 |
tasks: |
| 147 |
- name: HA configuration. |
| 148 |
fortinet.fortimanager.fmgr_system_ha: |
| 149 |
# workspace_locking_adom: <global or your adom name> |
| 150 |
system_ha: |
| 151 |
# clusterid: <integer> |
| 152 |
# file_quota: <integer> |
| 153 |
# hb_interval: <integer> |
| 154 |
# hb_lost_threshold: <integer> |
| 155 |
# mode: <value in [standalone, master, slave, ...]> |
| 156 |
# password: <list or string> |
| 157 |
# peer: |
| 158 |
# - id: <integer> |
| 159 |
# ip: <string> |
| 160 |
# ip6: <string> |
| 161 |
# serial_number: <string> |
| 162 |
# status: <value in [disable, enable]> |
| 163 |
# local_cert: <string> |
| 164 |
# failover_mode: <value in [manual, vrrp]> |
| 165 |
# monitored_interfaces: |
| 166 |
# - interface_name: <string> |
| 167 |
# monitored_ips: |
| 168 |
# - id: <integer> |
| 169 |
# interface: <string> |
| 170 |
# ip: <string> |
| 171 |
# priority: <integer> |
| 172 |
# unicast: <value in [disable, enable]> |
| 173 |
# vip: <string> |
| 174 |
# vrrp_adv_interval: <integer> |
| 175 |
# vrrp_interface: <string> |
| 176 |
# vip_interface: <string> |
| 177 |
''' |
| 178 |
|
| 179 |
RETURN = ''' |
| 180 |
meta: |
| 181 |
description: The result of the request. |
| 182 |
type: dict |
| 183 |
returned: always |
| 184 |
contains: |
| 185 |
request_url: |
| 186 |
description: The full url requested. |
| 187 |
returned: always |
| 188 |
type: str |
| 189 |
sample: /sys/login/user |
| 190 |
response_code: |
| 191 |
description: The status of api request. |
| 192 |
returned: always |
| 193 |
type: int |
| 194 |
sample: 0 |
| 195 |
response_data: |
| 196 |
description: The api response. |
| 197 |
type: list |
| 198 |
returned: always |
| 199 |
response_message: |
| 200 |
description: The descriptive message of the api response. |
| 201 |
type: str |
| 202 |
returned: always |
| 203 |
sample: OK. |
| 204 |
system_information: |
| 205 |
description: The information of the target system. |
| 206 |
type: dict |
| 207 |
returned: always |
| 208 |
rc: |
| 209 |
description: The status the request. |
| 210 |
type: int |
| 211 |
returned: always |
| 212 |
sample: 0 |
| 213 |
version_check_warning: |
| 214 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 215 |
type: list |
| 216 |
returned: complex |
| 217 |
''' |
| 218 |
from ansible.module_utils.basic import AnsibleModule |
| 219 |
from ansible.module_utils.connection import Connection |
| 220 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 221 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 222 |
|
| 223 |
|
| 224 |
def main(): |
| 225 |
urls_list = [ |
| 226 |
'/cli/global/system/ha' |
| 227 |
] |
| 228 |
module_arg_spec = { |
| 229 |
'system_ha': { |
| 230 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 231 |
'options': { |
| 232 |
'clusterid': {'type': 'int'}, |
| 233 |
'file-quota': {'type': 'int'}, |
| 234 |
'hb-interval': {'type': 'int'}, |
| 235 |
'hb-lost-threshold': {'type': 'int'}, |
| 236 |
'mode': {'choices': ['standalone', 'master', 'slave', 'primary', 'secondary'], 'type': 'str'}, |
| 237 |
'password': {'no_log': True, 'type': 'raw'}, |
| 238 |
'peer': { |
| 239 |
'type': 'list', |
| 240 |
'options': { |
| 241 |
'id': {'type': 'int'}, |
| 242 |
'ip': {'type': 'str'}, |
| 243 |
'ip6': {'type': 'str'}, |
| 244 |
'serial-number': {'type': 'str'}, |
| 245 |
'status': {'choices': ['disable', 'enable'], 'type': 'str'} |
| 246 |
}, |
| 247 |
'elements': 'dict' |
| 248 |
}, |
| 249 |
'local-cert': {'v_range': [['6.2.7', '']], 'type': 'str'}, |
| 250 |
'failover-mode': {'v_range': [['7.2.0', '']], 'choices': ['manual', 'vrrp'], 'type': 'str'}, |
| 251 |
'monitored-interfaces': { |
| 252 |
'v_range': [['7.2.0', '']], |
| 253 |
'type': 'list', |
| 254 |
'options': {'interface-name': {'v_range': [['7.2.0', '']], 'type': 'str'}}, |
| 255 |
'elements': 'dict' |
| 256 |
}, |
| 257 |
'monitored-ips': { |
| 258 |
'v_range': [['7.2.0', '']], |
| 259 |
'type': 'list', |
| 260 |
'options': { |
| 261 |
'id': {'v_range': [['7.2.0', '']], 'type': 'int'}, |
| 262 |
'interface': {'v_range': [['7.2.0', '']], 'type': 'str'}, |
| 263 |
'ip': {'v_range': [['7.2.0', '']], 'type': 'str'} |
| 264 |
}, |
| 265 |
'elements': 'dict' |
| 266 |
}, |
| 267 |
'priority': {'v_range': [['7.2.0', '']], 'type': 'int'}, |
| 268 |
'unicast': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 269 |
'vip': {'v_range': [['7.2.0', '']], 'type': 'str'}, |
| 270 |
'vrrp-adv-interval': {'v_range': [['7.2.0', '']], 'type': 'int'}, |
| 271 |
'vrrp-interface': {'v_range': [['7.2.0', '']], 'type': 'str'}, |
| 272 |
'vip-interface': {'v_range': [['7.2.4', '7.2.12'], ['7.4.1', '']], 'type': 'str'} |
| 273 |
} |
| 274 |
} |
| 275 |
} |
| 276 |
|
| 277 |
module_option_spec = get_module_arg_spec('partial crud') |
| 278 |
module_arg_spec.update(module_option_spec) |
| 279 |
check_galaxy_version(module_arg_spec) |
| 280 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_ha'), |
| 281 |
supports_check_mode=True) |
| 282 |
if not module._socket_path: |
| 283 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 284 |
connection = Connection(module._socket_path) |
| 285 |
fmgr = NAPIManager('partial crud', module_arg_spec, urls_list, |
| 286 |
None, 'data', module, connection) |
| 287 |
fmgr.process_partial_crud() |
| 288 |
module.exit_json(meta=module.params) |
| 289 |
|
| 290 |
|
| 291 |
if __name__ == '__main__': |
| 292 |
main() |