| 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_pkg_firewall_localinpolicy6 |
| 15 |
short_description: Configure user defined IPv6 local-in policies. |
| 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 |
pkg: |
| 29 |
description: The parameter (pkg) in requested url. |
| 30 |
type: str |
| 31 |
required: true |
| 32 |
pkg_firewall_localinpolicy6: |
| 33 |
description: The top level parameters set. |
| 34 |
required: false |
| 35 |
type: dict |
| 36 |
suboptions: |
| 37 |
action: |
| 38 |
type: str |
| 39 |
description: Action performed on traffic matching the policy |
| 40 |
choices: ['deny', 'accept'] |
| 41 |
dstaddr: |
| 42 |
type: raw |
| 43 |
description: (list or str) Destination address object from available options. |
| 44 |
intf: |
| 45 |
type: raw |
| 46 |
description: Incoming interface name from available options. |
| 47 |
policyid: |
| 48 |
type: int |
| 49 |
description: User defined local in policy ID. |
| 50 |
required: true |
| 51 |
schedule: |
| 52 |
type: str |
| 53 |
description: Schedule object from available options. |
| 54 |
service: |
| 55 |
type: raw |
| 56 |
description: (list or str) Service object from available options. |
| 57 |
srcaddr: |
| 58 |
type: raw |
| 59 |
description: (list or str) Source address object from available options. |
| 60 |
status: |
| 61 |
type: str |
| 62 |
description: Enable/disable this local-in policy. |
| 63 |
choices: ['disable', 'enable'] |
| 64 |
comments: |
| 65 |
type: str |
| 66 |
description: Comment. |
| 67 |
uuid: |
| 68 |
type: str |
| 69 |
description: Universally Unique Identifier |
| 70 |
dstaddr_negate: |
| 71 |
aliases: ['dstaddr-negate'] |
| 72 |
type: str |
| 73 |
description: When enabled dstaddr specifies what the destination address must NOT be. |
| 74 |
choices: ['disable', 'enable'] |
| 75 |
service_negate: |
| 76 |
aliases: ['service-negate'] |
| 77 |
type: str |
| 78 |
description: When enabled service specifies what the service must NOT be. |
| 79 |
choices: ['disable', 'enable'] |
| 80 |
srcaddr_negate: |
| 81 |
aliases: ['srcaddr-negate'] |
| 82 |
type: str |
| 83 |
description: When enabled srcaddr specifies what the source address must NOT be. |
| 84 |
choices: ['disable', 'enable'] |
| 85 |
virtual_patch: |
| 86 |
aliases: ['virtual-patch'] |
| 87 |
type: str |
| 88 |
description: Enable/disable the virtual patching feature. |
| 89 |
choices: ['disable', 'enable'] |
| 90 |
internet_service6_src: |
| 91 |
aliases: ['internet-service6-src'] |
| 92 |
type: str |
| 93 |
description: Enable/disable use of IPv6 Internet Services in source for this local-in policy. |
| 94 |
choices: ['disable', 'enable'] |
| 95 |
internet_service6_src_custom: |
| 96 |
aliases: ['internet-service6-src-custom'] |
| 97 |
type: raw |
| 98 |
description: (list) Custom IPv6 Internet Service source name. |
| 99 |
internet_service6_src_custom_group: |
| 100 |
aliases: ['internet-service6-src-custom-group'] |
| 101 |
type: raw |
| 102 |
description: (list) Custom Internet Service6 source group name. |
| 103 |
internet_service6_src_group: |
| 104 |
aliases: ['internet-service6-src-group'] |
| 105 |
type: raw |
| 106 |
description: (list) Internet Service6 source group name. |
| 107 |
internet_service6_src_name: |
| 108 |
aliases: ['internet-service6-src-name'] |
| 109 |
type: raw |
| 110 |
description: (list) IPv6 Internet Service source name. |
| 111 |
internet_service6_src_negate: |
| 112 |
aliases: ['internet-service6-src-negate'] |
| 113 |
type: str |
| 114 |
description: When enabled internet-service6-src specifies what the service must NOT be. |
| 115 |
choices: ['disable', 'enable'] |
| 116 |
logtraffic: |
| 117 |
type: str |
| 118 |
description: Enable/disable local-in traffic logging. |
| 119 |
choices: ['disable', 'enable'] |
| 120 |
internet_service6_src_fortiguard: |
| 121 |
aliases: ['internet-service6-src-fortiguard'] |
| 122 |
type: raw |
| 123 |
description: (list) FortiGuard IPv6 Internet Service source name. |
| 124 |
''' |
| 125 |
|
| 126 |
EXAMPLES = ''' |
| 127 |
- name: Example playbook |
| 128 |
hosts: fortimanagers |
| 129 |
gather_facts: false |
| 130 |
connection: httpapi |
| 131 |
vars: |
| 132 |
ansible_httpapi_use_ssl: true |
| 133 |
ansible_httpapi_validate_certs: false |
| 134 |
ansible_httpapi_port: 443 |
| 135 |
tasks: |
| 136 |
- name: Configure user defined IPv6 local-in policies. |
| 137 |
fortinet.fortimanager.fmgr_pkg_firewall_localinpolicy6: |
| 138 |
bypass_validation: false |
| 139 |
adom: ansible |
| 140 |
pkg: ansible # package name |
| 141 |
state: present |
| 142 |
pkg_firewall_localinpolicy6: |
| 143 |
action: deny # <value in [deny, accept]> |
| 144 |
dstaddr: all |
| 145 |
intf: any |
| 146 |
policyid: 1 |
| 147 |
schedule: always |
| 148 |
service: ALL |
| 149 |
srcaddr: all |
| 150 |
status: disable |
| 151 |
|
| 152 |
- name: Gathering fortimanager facts |
| 153 |
hosts: fortimanagers |
| 154 |
gather_facts: false |
| 155 |
connection: httpapi |
| 156 |
vars: |
| 157 |
ansible_httpapi_use_ssl: true |
| 158 |
ansible_httpapi_validate_certs: false |
| 159 |
ansible_httpapi_port: 443 |
| 160 |
tasks: |
| 161 |
- name: Retrieve all the user defined IPv6 local-in policies |
| 162 |
fortinet.fortimanager.fmgr_fact: |
| 163 |
facts: |
| 164 |
selector: "pkg_firewall_localinpolicy6" |
| 165 |
params: |
| 166 |
adom: "ansible" |
| 167 |
pkg: "ansible" # package name |
| 168 |
local_in_policy6: "your_value" |
| 169 |
''' |
| 170 |
|
| 171 |
RETURN = ''' |
| 172 |
meta: |
| 173 |
description: The result of the request. |
| 174 |
type: dict |
| 175 |
returned: always |
| 176 |
contains: |
| 177 |
request_url: |
| 178 |
description: The full url requested. |
| 179 |
returned: always |
| 180 |
type: str |
| 181 |
sample: /sys/login/user |
| 182 |
response_code: |
| 183 |
description: The status of api request. |
| 184 |
returned: always |
| 185 |
type: int |
| 186 |
sample: 0 |
| 187 |
response_data: |
| 188 |
description: The api response. |
| 189 |
type: list |
| 190 |
returned: always |
| 191 |
response_message: |
| 192 |
description: The descriptive message of the api response. |
| 193 |
type: str |
| 194 |
returned: always |
| 195 |
sample: OK. |
| 196 |
system_information: |
| 197 |
description: The information of the target system. |
| 198 |
type: dict |
| 199 |
returned: always |
| 200 |
rc: |
| 201 |
description: The status the request. |
| 202 |
type: int |
| 203 |
returned: always |
| 204 |
sample: 0 |
| 205 |
version_check_warning: |
| 206 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 207 |
type: list |
| 208 |
returned: complex |
| 209 |
''' |
| 210 |
from ansible.module_utils.basic import AnsibleModule |
| 211 |
from ansible.module_utils.connection import Connection |
| 212 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 213 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 214 |
|
| 215 |
|
| 216 |
def main(): |
| 217 |
urls_list = [ |
| 218 |
'/pm/config/adom/{adom}/pkg/{pkg}/firewall/local-in-policy6' |
| 219 |
] |
| 220 |
module_arg_spec = { |
| 221 |
'adom': {'required': True, 'type': 'str'}, |
| 222 |
'pkg': {'required': True, 'type': 'str'}, |
| 223 |
'revision_note': {'type': 'str'}, |
| 224 |
'pkg_firewall_localinpolicy6': { |
| 225 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 226 |
'options': { |
| 227 |
'action': {'choices': ['deny', 'accept'], 'type': 'str'}, |
| 228 |
'dstaddr': {'type': 'raw'}, |
| 229 |
'intf': {'type': 'raw'}, |
| 230 |
'policyid': {'required': True, 'type': 'int'}, |
| 231 |
'schedule': {'type': 'str'}, |
| 232 |
'service': {'type': 'raw'}, |
| 233 |
'srcaddr': {'type': 'raw'}, |
| 234 |
'status': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 235 |
'comments': {'v_range': [['6.2.0', '']], 'type': 'str'}, |
| 236 |
'uuid': {'v_range': [['6.2.1', '']], 'type': 'str'}, |
| 237 |
'dstaddr-negate': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 238 |
'service-negate': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 239 |
'srcaddr-negate': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 240 |
'virtual-patch': {'v_range': [['7.2.6', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 241 |
'internet-service6-src': {'v_range': [['7.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 242 |
'internet-service6-src-custom': {'v_range': [['7.4.3', '']], 'type': 'raw'}, |
| 243 |
'internet-service6-src-custom-group': {'v_range': [['7.4.3', '']], 'type': 'raw'}, |
| 244 |
'internet-service6-src-group': {'v_range': [['7.4.3', '']], 'type': 'raw'}, |
| 245 |
'internet-service6-src-name': {'v_range': [['7.4.3', '']], 'type': 'raw'}, |
| 246 |
'internet-service6-src-negate': {'v_range': [['7.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 247 |
'logtraffic': {'v_range': [['7.6.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 248 |
'internet-service6-src-fortiguard': {'v_range': [['7.6.4', '']], 'type': 'raw'} |
| 249 |
} |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
module_option_spec = get_module_arg_spec('full crud') |
| 254 |
module_arg_spec.update(module_option_spec) |
| 255 |
check_galaxy_version(module_arg_spec) |
| 256 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pkg_firewall_localinpolicy6'), |
| 257 |
supports_check_mode=True) |
| 258 |
if not module._socket_path: |
| 259 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 260 |
connection = Connection(module._socket_path) |
| 261 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 262 |
'policyid', 'data', module, connection) |
| 263 |
fmgr.process_crud() |
| 264 |
module.exit_json(meta=module.params) |
| 265 |
|
| 266 |
|
| 267 |
if __name__ == '__main__': |
| 268 |
main() |