| 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_firewall_address6_dynamicmapping |
| 15 |
short_description: Configure IPv6 firewall addresses. |
| 16 |
version_added: "2.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.full_crud |
| 20 |
options: |
| 21 |
revision_note: |
| 22 |
description: The change note that can be specified when an object is created or updated. |
| 23 |
type: str |
| 24 |
adom: |
| 25 |
description: The parameter (adom) in requested url. |
| 26 |
type: str |
| 27 |
required: true |
| 28 |
address6: |
| 29 |
description: The parameter (address6) in requested url. |
| 30 |
type: str |
| 31 |
required: true |
| 32 |
firewall_address6_dynamicmapping: |
| 33 |
description: The top level parameters set. |
| 34 |
required: false |
| 35 |
type: dict |
| 36 |
suboptions: |
| 37 |
_scope: |
| 38 |
type: list |
| 39 |
elements: dict |
| 40 |
description: Scope. |
| 41 |
suboptions: |
| 42 |
name: |
| 43 |
type: str |
| 44 |
description: Name. |
| 45 |
vdom: |
| 46 |
type: str |
| 47 |
description: Vdom. |
| 48 |
cache_ttl: |
| 49 |
aliases: ['cache-ttl'] |
| 50 |
type: int |
| 51 |
description: Cache ttl. |
| 52 |
color: |
| 53 |
type: int |
| 54 |
description: Color. |
| 55 |
comment: |
| 56 |
type: str |
| 57 |
description: Comment. |
| 58 |
end_ip: |
| 59 |
aliases: ['end-ip'] |
| 60 |
type: str |
| 61 |
description: End ip. |
| 62 |
fqdn: |
| 63 |
type: str |
| 64 |
description: Fqdn. |
| 65 |
host: |
| 66 |
type: str |
| 67 |
description: Host. |
| 68 |
host_type: |
| 69 |
aliases: ['host-type'] |
| 70 |
type: str |
| 71 |
description: Host type. |
| 72 |
choices: ['any', 'specific'] |
| 73 |
ip6: |
| 74 |
type: str |
| 75 |
description: Ip6. |
| 76 |
obj_id: |
| 77 |
aliases: ['obj-id'] |
| 78 |
type: str |
| 79 |
description: Obj id. |
| 80 |
sdn: |
| 81 |
type: str |
| 82 |
description: Sdn. |
| 83 |
choices: ['nsx'] |
| 84 |
start_ip: |
| 85 |
aliases: ['start-ip'] |
| 86 |
type: str |
| 87 |
description: Start ip. |
| 88 |
tags: |
| 89 |
type: raw |
| 90 |
description: (list or str) Tags. |
| 91 |
template: |
| 92 |
type: str |
| 93 |
description: Template. |
| 94 |
type: |
| 95 |
type: str |
| 96 |
description: Type. |
| 97 |
choices: ['ipprefix', 'iprange', 'nsx', 'dynamic', 'fqdn', 'template', 'mac', |
| 98 |
'geography', 'route-tag', 'wildcard'] |
| 99 |
uuid: |
| 100 |
type: str |
| 101 |
description: Uuid. |
| 102 |
visibility: |
| 103 |
type: str |
| 104 |
description: Visibility. |
| 105 |
choices: ['disable', 'enable'] |
| 106 |
subnet_segment: |
| 107 |
aliases: ['subnet-segment'] |
| 108 |
type: list |
| 109 |
elements: dict |
| 110 |
description: Subnet segment. |
| 111 |
suboptions: |
| 112 |
name: |
| 113 |
type: str |
| 114 |
description: Name. |
| 115 |
type: |
| 116 |
type: str |
| 117 |
description: Type. |
| 118 |
choices: ['any', 'specific'] |
| 119 |
value: |
| 120 |
type: str |
| 121 |
description: Value. |
| 122 |
_image_base64: |
| 123 |
aliases: ['_image-base64'] |
| 124 |
type: str |
| 125 |
description: Image base64. |
| 126 |
end_mac: |
| 127 |
aliases: ['end-mac'] |
| 128 |
type: str |
| 129 |
description: End mac. |
| 130 |
start_mac: |
| 131 |
aliases: ['start-mac'] |
| 132 |
type: str |
| 133 |
description: Start mac. |
| 134 |
country: |
| 135 |
type: str |
| 136 |
description: Country. |
| 137 |
global_object: |
| 138 |
aliases: ['global-object'] |
| 139 |
type: int |
| 140 |
description: Global object. |
| 141 |
fabric_object: |
| 142 |
aliases: ['fabric-object'] |
| 143 |
type: str |
| 144 |
description: Security Fabric global object setting. |
| 145 |
choices: ['disable', 'enable'] |
| 146 |
macaddr: |
| 147 |
type: raw |
| 148 |
description: (list) Multiple MAC address ranges. |
| 149 |
epg_name: |
| 150 |
aliases: ['epg-name'] |
| 151 |
type: str |
| 152 |
description: Endpoint group name. |
| 153 |
sdn_tag: |
| 154 |
aliases: ['sdn-tag'] |
| 155 |
type: str |
| 156 |
description: SDN Tag. |
| 157 |
tenant: |
| 158 |
type: str |
| 159 |
description: Tenant. |
| 160 |
route_tag: |
| 161 |
aliases: ['route-tag'] |
| 162 |
type: int |
| 163 |
description: Route-tag address. |
| 164 |
filter: |
| 165 |
type: str |
| 166 |
description: Match criteria filter. |
| 167 |
sdn_addr_type: |
| 168 |
aliases: ['sdn-addr-type'] |
| 169 |
type: str |
| 170 |
description: Type of addresses to collect. |
| 171 |
choices: ['all', 'private', 'public'] |
| 172 |
wildcard: |
| 173 |
type: str |
| 174 |
description: IPv6 address and wildcard netmask. |
| 175 |
passive_fqdn_learning: |
| 176 |
aliases: ['passive-fqdn-learning'] |
| 177 |
type: str |
| 178 |
description: Enable/disable passive learning of FQDNs. |
| 179 |
choices: ['disable', 'enable'] |
| 180 |
''' |
| 181 |
|
| 182 |
EXAMPLES = ''' |
| 183 |
- name: Example playbook |
| 184 |
hosts: fortimanagers |
| 185 |
gather_facts: false |
| 186 |
connection: httpapi |
| 187 |
vars: |
| 188 |
ansible_httpapi_use_ssl: true |
| 189 |
ansible_httpapi_validate_certs: false |
| 190 |
ansible_httpapi_port: 443 |
| 191 |
tasks: |
| 192 |
- name: Configure dynamic mappings of IPv6 address |
| 193 |
fortinet.fortimanager.fmgr_firewall_address6_dynamicmapping: |
| 194 |
bypass_validation: false |
| 195 |
adom: ansible |
| 196 |
address6: "ansible-test" # name |
| 197 |
state: present |
| 198 |
firewall_address6_dynamicmapping: |
| 199 |
_scope: |
| 200 |
- name: FGT_AWS # need a valid device name |
| 201 |
vdom: root # need a valid vdom name under the device |
| 202 |
cache_ttl: 0 |
| 203 |
color: 22 |
| 204 |
comment: "ansible-test-comment" |
| 205 |
end_ip: "::100" |
| 206 |
host: "::" |
| 207 |
host_type: any # <value in [any, specific]> |
| 208 |
ip6: "::/128" |
| 209 |
start_ip: "::" |
| 210 |
type: iprange # <value in [ipprefix, iprange, nsx, ...]> |
| 211 |
visibility: enable |
| 212 |
|
| 213 |
- name: Gathering fortimanager facts |
| 214 |
hosts: fortimanagers |
| 215 |
gather_facts: false |
| 216 |
connection: httpapi |
| 217 |
vars: |
| 218 |
ansible_httpapi_use_ssl: true |
| 219 |
ansible_httpapi_validate_certs: false |
| 220 |
ansible_httpapi_port: 443 |
| 221 |
tasks: |
| 222 |
- name: Retrieve all the dynamic mappings of IPv6 address |
| 223 |
fortinet.fortimanager.fmgr_fact: |
| 224 |
facts: |
| 225 |
selector: "firewall_address6_dynamicmapping" |
| 226 |
params: |
| 227 |
adom: "ansible" |
| 228 |
address6: "ansible-test" # name |
| 229 |
dynamic_mapping: "your_value" |
| 230 |
''' |
| 231 |
|
| 232 |
RETURN = ''' |
| 233 |
meta: |
| 234 |
description: The result of the request. |
| 235 |
type: dict |
| 236 |
returned: always |
| 237 |
contains: |
| 238 |
request_url: |
| 239 |
description: The full url requested. |
| 240 |
returned: always |
| 241 |
type: str |
| 242 |
sample: /sys/login/user |
| 243 |
response_code: |
| 244 |
description: The status of api request. |
| 245 |
returned: always |
| 246 |
type: int |
| 247 |
sample: 0 |
| 248 |
response_data: |
| 249 |
description: The api response. |
| 250 |
type: list |
| 251 |
returned: always |
| 252 |
response_message: |
| 253 |
description: The descriptive message of the api response. |
| 254 |
type: str |
| 255 |
returned: always |
| 256 |
sample: OK. |
| 257 |
system_information: |
| 258 |
description: The information of the target system. |
| 259 |
type: dict |
| 260 |
returned: always |
| 261 |
rc: |
| 262 |
description: The status the request. |
| 263 |
type: int |
| 264 |
returned: always |
| 265 |
sample: 0 |
| 266 |
version_check_warning: |
| 267 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 268 |
type: list |
| 269 |
returned: complex |
| 270 |
''' |
| 271 |
from ansible.module_utils.basic import AnsibleModule |
| 272 |
from ansible.module_utils.connection import Connection |
| 273 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 274 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 275 |
|
| 276 |
|
| 277 |
def main(): |
| 278 |
urls_list = [ |
| 279 |
'/pm/config/adom/{adom}/obj/firewall/address6/{address6}/dynamic_mapping', |
| 280 |
'/pm/config/global/obj/firewall/address6/{address6}/dynamic_mapping' |
| 281 |
] |
| 282 |
module_arg_spec = { |
| 283 |
'adom': {'required': True, 'type': 'str'}, |
| 284 |
'address6': {'required': True, 'type': 'str'}, |
| 285 |
'revision_note': {'type': 'str'}, |
| 286 |
'firewall_address6_dynamicmapping': { |
| 287 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 288 |
'options': { |
| 289 |
'_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'}, |
| 290 |
'cache-ttl': {'type': 'int'}, |
| 291 |
'color': {'type': 'int'}, |
| 292 |
'comment': {'type': 'str'}, |
| 293 |
'end-ip': {'type': 'str'}, |
| 294 |
'fqdn': {'type': 'str'}, |
| 295 |
'host': {'type': 'str'}, |
| 296 |
'host-type': {'choices': ['any', 'specific'], 'type': 'str'}, |
| 297 |
'ip6': {'type': 'str'}, |
| 298 |
'obj-id': {'type': 'str'}, |
| 299 |
'sdn': {'choices': ['nsx'], 'type': 'str'}, |
| 300 |
'start-ip': {'type': 'str'}, |
| 301 |
'tags': {'type': 'raw'}, |
| 302 |
'template': {'type': 'str'}, |
| 303 |
'type': { |
| 304 |
'choices': ['ipprefix', 'iprange', 'nsx', 'dynamic', 'fqdn', 'template', 'mac', 'geography', 'route-tag', 'wildcard'], |
| 305 |
'type': 'str' |
| 306 |
}, |
| 307 |
'uuid': {'type': 'str'}, |
| 308 |
'visibility': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 309 |
'subnet-segment': { |
| 310 |
'v_range': [['6.2.1', '']], |
| 311 |
'type': 'list', |
| 312 |
'options': { |
| 313 |
'name': {'v_range': [['6.2.1', '']], 'type': 'str'}, |
| 314 |
'type': {'v_range': [['6.2.1', '']], 'choices': ['any', 'specific'], 'type': 'str'}, |
| 315 |
'value': {'v_range': [['6.2.1', '']], 'type': 'str'} |
| 316 |
}, |
| 317 |
'elements': 'dict' |
| 318 |
}, |
| 319 |
'_image-base64': {'v_range': [['6.2.2', '']], 'type': 'str'}, |
| 320 |
'end-mac': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'}, |
| 321 |
'start-mac': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'}, |
| 322 |
'country': {'v_range': [['6.4.0', '']], 'type': 'str'}, |
| 323 |
'global-object': {'v_range': [['6.4.0', '']], 'type': 'int'}, |
| 324 |
'fabric-object': {'v_range': [['6.4.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 325 |
'macaddr': {'v_range': [['7.0.0', '']], 'type': 'raw'}, |
| 326 |
'epg-name': {'v_range': [['7.2.1', '']], 'type': 'str'}, |
| 327 |
'sdn-tag': {'v_range': [['7.2.1', '']], 'type': 'str'}, |
| 328 |
'tenant': {'v_range': [['7.2.1', '']], 'type': 'str'}, |
| 329 |
'route-tag': {'v_range': [['7.4.0', '']], 'type': 'int'}, |
| 330 |
'filter': {'v_range': [['7.4.4', '7.4.10'], ['7.6.2', '']], 'type': 'str'}, |
| 331 |
'sdn-addr-type': {'v_range': [['7.4.4', '7.4.10'], ['7.6.2', '']], 'choices': ['all', 'private', 'public'], 'type': 'str'}, |
| 332 |
'wildcard': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 333 |
'passive-fqdn-learning': {'v_range': [['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'} |
| 334 |
} |
| 335 |
} |
| 336 |
} |
| 337 |
|
| 338 |
module_option_spec = get_module_arg_spec('full crud') |
| 339 |
module_arg_spec.update(module_option_spec) |
| 340 |
check_galaxy_version(module_arg_spec) |
| 341 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_address6_dynamicmapping'), |
| 342 |
supports_check_mode=True) |
| 343 |
if not module._socket_path: |
| 344 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 345 |
connection = Connection(module._socket_path) |
| 346 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 347 |
'complex:{{module}}["_scope"][0]["name"]+"/"+{{module}}["_scope"][0]["vdom"]', 'data', module, connection) |
| 348 |
fmgr.process_crud() |
| 349 |
module.exit_json(meta=module.params) |
| 350 |
|
| 351 |
|
| 352 |
if __name__ == '__main__': |
| 353 |
main() |