| 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_ippool6 |
| 15 |
short_description: Configure IPv6 IP pools. |
| 16 |
version_added: "1.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 |
firewall_ippool6: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
comments: |
| 34 |
type: str |
| 35 |
description: Comment. |
| 36 |
dynamic_mapping: |
| 37 |
type: list |
| 38 |
elements: dict |
| 39 |
description: Dynamic mapping. |
| 40 |
suboptions: |
| 41 |
_scope: |
| 42 |
type: list |
| 43 |
elements: dict |
| 44 |
description: Scope. |
| 45 |
suboptions: |
| 46 |
name: |
| 47 |
type: str |
| 48 |
description: Name. |
| 49 |
vdom: |
| 50 |
type: str |
| 51 |
description: Vdom. |
| 52 |
comments: |
| 53 |
type: str |
| 54 |
description: Comments. |
| 55 |
endip: |
| 56 |
type: str |
| 57 |
description: Endip. |
| 58 |
startip: |
| 59 |
type: str |
| 60 |
description: Startip. |
| 61 |
add_nat46_route: |
| 62 |
aliases: ['add-nat46-route'] |
| 63 |
type: str |
| 64 |
description: Enable/disable adding NAT46 route. |
| 65 |
choices: ['disable', 'enable'] |
| 66 |
nat46: |
| 67 |
type: str |
| 68 |
description: Enable/disable NAT46. |
| 69 |
choices: ['disable', 'enable'] |
| 70 |
external_prefix: |
| 71 |
aliases: ['external-prefix'] |
| 72 |
type: str |
| 73 |
description: |
| 74 |
- Support meta variable |
| 75 |
- External NPTv6 prefix length |
| 76 |
internal_prefix: |
| 77 |
aliases: ['internal-prefix'] |
| 78 |
type: str |
| 79 |
description: |
| 80 |
- Support meta variable |
| 81 |
- Internal NPTv6 prefix length |
| 82 |
type: |
| 83 |
type: str |
| 84 |
description: Configure IPv6 pool type |
| 85 |
choices: ['overload', 'nptv6'] |
| 86 |
endip: |
| 87 |
type: str |
| 88 |
description: Final IPv6 address |
| 89 |
name: |
| 90 |
type: str |
| 91 |
description: IPv6 IP pool name. |
| 92 |
required: true |
| 93 |
startip: |
| 94 |
type: str |
| 95 |
description: First IPv6 address |
| 96 |
add_nat46_route: |
| 97 |
aliases: ['add-nat46-route'] |
| 98 |
type: str |
| 99 |
description: Enable/disable adding NAT46 route. |
| 100 |
choices: ['disable', 'enable'] |
| 101 |
nat46: |
| 102 |
type: str |
| 103 |
description: Enable/disable NAT46. |
| 104 |
choices: ['disable', 'enable'] |
| 105 |
external_prefix: |
| 106 |
aliases: ['external-prefix'] |
| 107 |
type: str |
| 108 |
description: |
| 109 |
- Support meta variable |
| 110 |
- External NPTv6 prefix length |
| 111 |
internal_prefix: |
| 112 |
aliases: ['internal-prefix'] |
| 113 |
type: str |
| 114 |
description: |
| 115 |
- Support meta variable |
| 116 |
- Internal NPTv6 prefix length |
| 117 |
type: |
| 118 |
type: str |
| 119 |
description: Configure IPv6 pool type |
| 120 |
choices: ['overload', 'nptv6'] |
| 121 |
''' |
| 122 |
|
| 123 |
EXAMPLES = ''' |
| 124 |
- name: Example playbook |
| 125 |
hosts: fortimanagers |
| 126 |
gather_facts: false |
| 127 |
connection: httpapi |
| 128 |
vars: |
| 129 |
ansible_httpapi_use_ssl: true |
| 130 |
ansible_httpapi_validate_certs: false |
| 131 |
ansible_httpapi_port: 443 |
| 132 |
tasks: |
| 133 |
- name: Configure IPv6 IP pools. |
| 134 |
fortinet.fortimanager.fmgr_firewall_ippool6: |
| 135 |
bypass_validation: false |
| 136 |
adom: ansible |
| 137 |
state: present |
| 138 |
firewall_ippool6: |
| 139 |
comments: "ansible-comment" |
| 140 |
endip: "2001::101" |
| 141 |
name: "ansible-test" |
| 142 |
startip: "2001::0" |
| 143 |
|
| 144 |
- name: Gathering fortimanager facts |
| 145 |
hosts: fortimanagers |
| 146 |
gather_facts: false |
| 147 |
connection: httpapi |
| 148 |
vars: |
| 149 |
ansible_httpapi_use_ssl: true |
| 150 |
ansible_httpapi_validate_certs: false |
| 151 |
ansible_httpapi_port: 443 |
| 152 |
tasks: |
| 153 |
- name: Retrieve all the IPv6 IP pools |
| 154 |
fortinet.fortimanager.fmgr_fact: |
| 155 |
facts: |
| 156 |
selector: "firewall_ippool6" |
| 157 |
params: |
| 158 |
adom: "ansible" |
| 159 |
ippool6: "your_value" |
| 160 |
''' |
| 161 |
|
| 162 |
RETURN = ''' |
| 163 |
meta: |
| 164 |
description: The result of the request. |
| 165 |
type: dict |
| 166 |
returned: always |
| 167 |
contains: |
| 168 |
request_url: |
| 169 |
description: The full url requested. |
| 170 |
returned: always |
| 171 |
type: str |
| 172 |
sample: /sys/login/user |
| 173 |
response_code: |
| 174 |
description: The status of api request. |
| 175 |
returned: always |
| 176 |
type: int |
| 177 |
sample: 0 |
| 178 |
response_data: |
| 179 |
description: The api response. |
| 180 |
type: list |
| 181 |
returned: always |
| 182 |
response_message: |
| 183 |
description: The descriptive message of the api response. |
| 184 |
type: str |
| 185 |
returned: always |
| 186 |
sample: OK. |
| 187 |
system_information: |
| 188 |
description: The information of the target system. |
| 189 |
type: dict |
| 190 |
returned: always |
| 191 |
rc: |
| 192 |
description: The status the request. |
| 193 |
type: int |
| 194 |
returned: always |
| 195 |
sample: 0 |
| 196 |
version_check_warning: |
| 197 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 198 |
type: list |
| 199 |
returned: complex |
| 200 |
''' |
| 201 |
from ansible.module_utils.basic import AnsibleModule |
| 202 |
from ansible.module_utils.connection import Connection |
| 203 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 204 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 205 |
|
| 206 |
|
| 207 |
def main(): |
| 208 |
urls_list = [ |
| 209 |
'/pm/config/adom/{adom}/obj/firewall/ippool6', |
| 210 |
'/pm/config/global/obj/firewall/ippool6' |
| 211 |
] |
| 212 |
module_arg_spec = { |
| 213 |
'adom': {'required': True, 'type': 'str'}, |
| 214 |
'revision_note': {'type': 'str'}, |
| 215 |
'firewall_ippool6': { |
| 216 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 217 |
'options': { |
| 218 |
'comments': {'type': 'str'}, |
| 219 |
'dynamic_mapping': { |
| 220 |
'type': 'list', |
| 221 |
'options': { |
| 222 |
'_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'}, |
| 223 |
'comments': {'type': 'str'}, |
| 224 |
'endip': {'type': 'str'}, |
| 225 |
'startip': {'type': 'str'}, |
| 226 |
'add-nat46-route': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 227 |
'nat46': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 228 |
'external-prefix': {'v_range': [['7.6.0', '']], 'type': 'str'}, |
| 229 |
'internal-prefix': {'v_range': [['7.6.0', '']], 'type': 'str'}, |
| 230 |
'type': {'v_range': [['7.6.0', '']], 'choices': ['overload', 'nptv6'], 'type': 'str'} |
| 231 |
}, |
| 232 |
'elements': 'dict' |
| 233 |
}, |
| 234 |
'endip': {'type': 'str'}, |
| 235 |
'name': {'required': True, 'type': 'str'}, |
| 236 |
'startip': {'type': 'str'}, |
| 237 |
'add-nat46-route': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 238 |
'nat46': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 239 |
'external-prefix': {'v_range': [['7.6.0', '']], 'type': 'str'}, |
| 240 |
'internal-prefix': {'v_range': [['7.6.0', '']], 'type': 'str'}, |
| 241 |
'type': {'v_range': [['7.6.0', '']], 'choices': ['overload', 'nptv6'], 'type': 'str'} |
| 242 |
} |
| 243 |
} |
| 244 |
} |
| 245 |
|
| 246 |
module_option_spec = get_module_arg_spec('full crud') |
| 247 |
module_arg_spec.update(module_option_spec) |
| 248 |
check_galaxy_version(module_arg_spec) |
| 249 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_ippool6'), |
| 250 |
supports_check_mode=True) |
| 251 |
if not module._socket_path: |
| 252 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 253 |
connection = Connection(module._socket_path) |
| 254 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 255 |
'name', 'data', module, connection) |
| 256 |
fmgr.process_crud() |
| 257 |
module.exit_json(meta=module.params) |
| 258 |
|
| 259 |
|
| 260 |
if __name__ == '__main__': |
| 261 |
main() |