| 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_profilegroup |
| 15 |
short_description: Configure profile groups. |
| 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_profilegroup: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
application_list: |
| 34 |
aliases: ['application-list'] |
| 35 |
type: str |
| 36 |
description: Name of an existing Application list. |
| 37 |
av_profile: |
| 38 |
aliases: ['av-profile'] |
| 39 |
type: str |
| 40 |
description: Name of an existing Antivirus profile. |
| 41 |
dlp_sensor: |
| 42 |
aliases: ['dlp-sensor'] |
| 43 |
type: str |
| 44 |
description: Name of an existing DLP sensor. |
| 45 |
dnsfilter_profile: |
| 46 |
aliases: ['dnsfilter-profile'] |
| 47 |
type: str |
| 48 |
description: Name of an existing DNS filter profile. |
| 49 |
icap_profile: |
| 50 |
aliases: ['icap-profile'] |
| 51 |
type: str |
| 52 |
description: Name of an existing ICAP profile. |
| 53 |
ips_sensor: |
| 54 |
aliases: ['ips-sensor'] |
| 55 |
type: str |
| 56 |
description: Name of an existing IPS sensor. |
| 57 |
mms_profile: |
| 58 |
aliases: ['mms-profile'] |
| 59 |
type: str |
| 60 |
description: Name of an existing MMS profile. |
| 61 |
name: |
| 62 |
type: str |
| 63 |
description: Profile group name. |
| 64 |
required: true |
| 65 |
profile_protocol_options: |
| 66 |
aliases: ['profile-protocol-options'] |
| 67 |
type: str |
| 68 |
description: Name of an existing Protocol options profile. |
| 69 |
spamfilter_profile: |
| 70 |
aliases: ['spamfilter-profile'] |
| 71 |
type: str |
| 72 |
description: Name of an existing Spam filter profile. |
| 73 |
ssh_filter_profile: |
| 74 |
aliases: ['ssh-filter-profile'] |
| 75 |
type: str |
| 76 |
description: Name of an existing SSH filter profile. |
| 77 |
ssl_ssh_profile: |
| 78 |
aliases: ['ssl-ssh-profile'] |
| 79 |
type: str |
| 80 |
description: Name of an existing SSL SSH profile. |
| 81 |
voip_profile: |
| 82 |
aliases: ['voip-profile'] |
| 83 |
type: str |
| 84 |
description: Name of an existing VoIP profile. |
| 85 |
waf_profile: |
| 86 |
aliases: ['waf-profile'] |
| 87 |
type: str |
| 88 |
description: Name of an existing Web application firewall profile. |
| 89 |
webfilter_profile: |
| 90 |
aliases: ['webfilter-profile'] |
| 91 |
type: str |
| 92 |
description: Name of an existing Web filter profile. |
| 93 |
cifs_profile: |
| 94 |
aliases: ['cifs-profile'] |
| 95 |
type: str |
| 96 |
description: Name of an existing CIFS profile. |
| 97 |
emailfilter_profile: |
| 98 |
aliases: ['emailfilter-profile'] |
| 99 |
type: str |
| 100 |
description: Name of an existing email filter profile. |
| 101 |
casi_profile: |
| 102 |
aliases: ['casi-profile'] |
| 103 |
type: str |
| 104 |
description: CASI profile. |
| 105 |
file_filter_profile: |
| 106 |
aliases: ['file-filter-profile'] |
| 107 |
type: str |
| 108 |
description: Name of an existing file-filter profile. |
| 109 |
videofilter_profile: |
| 110 |
aliases: ['videofilter-profile'] |
| 111 |
type: str |
| 112 |
description: Name of an existing VideoFilter profile. |
| 113 |
dlp_profile: |
| 114 |
aliases: ['dlp-profile'] |
| 115 |
type: str |
| 116 |
description: Name of an existing DLP profile. |
| 117 |
sctp_filter_profile: |
| 118 |
aliases: ['sctp-filter-profile'] |
| 119 |
type: str |
| 120 |
description: Name of an existing SCTP filter profile. |
| 121 |
ips_voip_filter: |
| 122 |
aliases: ['ips-voip-filter'] |
| 123 |
type: str |
| 124 |
description: Name of an existing VoIP |
| 125 |
casb_profile: |
| 126 |
aliases: ['casb-profile'] |
| 127 |
type: str |
| 128 |
description: Name of an existing CASB profile. |
| 129 |
virtual_patch_profile: |
| 130 |
aliases: ['virtual-patch-profile'] |
| 131 |
type: str |
| 132 |
description: Name of an existing virtual-patch profile. |
| 133 |
diameter_filter_profile: |
| 134 |
aliases: ['diameter-filter-profile'] |
| 135 |
type: str |
| 136 |
description: Name of an existing Diameter filter profile. |
| 137 |
telemetry_profile: |
| 138 |
aliases: ['telemetry-profile'] |
| 139 |
type: raw |
| 140 |
description: (list) Name of an existing telemetry profile. |
| 141 |
ia_profile: |
| 142 |
aliases: ['ia-profile'] |
| 143 |
type: raw |
| 144 |
description: (list) Image analyzer profile. |
| 145 |
isolator_profile: |
| 146 |
aliases: ['isolator-profile'] |
| 147 |
type: raw |
| 148 |
description: (list) Isolator profile. |
| 149 |
redirect_profile: |
| 150 |
aliases: ['redirect-profile'] |
| 151 |
type: raw |
| 152 |
description: (list) Redirect profile. |
| 153 |
llm_profile: |
| 154 |
aliases: ['llm-profile'] |
| 155 |
type: raw |
| 156 |
description: (list) Llm profile. |
| 157 |
''' |
| 158 |
|
| 159 |
EXAMPLES = ''' |
| 160 |
- name: Example playbook |
| 161 |
hosts: fortimanagers |
| 162 |
gather_facts: false |
| 163 |
connection: httpapi |
| 164 |
vars: |
| 165 |
ansible_httpapi_use_ssl: true |
| 166 |
ansible_httpapi_validate_certs: false |
| 167 |
ansible_httpapi_port: 443 |
| 168 |
tasks: |
| 169 |
- name: Configure profile groups. |
| 170 |
fortinet.fortimanager.fmgr_firewall_profilegroup: |
| 171 |
bypass_validation: false |
| 172 |
adom: ansible |
| 173 |
state: present |
| 174 |
firewall_profilegroup: |
| 175 |
application_list: "default" # need a valid profile name |
| 176 |
name: "ansible-test" |
| 177 |
|
| 178 |
- name: Gathering fortimanager facts |
| 179 |
hosts: fortimanagers |
| 180 |
gather_facts: false |
| 181 |
connection: httpapi |
| 182 |
vars: |
| 183 |
ansible_httpapi_use_ssl: true |
| 184 |
ansible_httpapi_validate_certs: false |
| 185 |
ansible_httpapi_port: 443 |
| 186 |
tasks: |
| 187 |
- name: Retrieve all the profile groups |
| 188 |
fortinet.fortimanager.fmgr_fact: |
| 189 |
facts: |
| 190 |
selector: "firewall_profilegroup" |
| 191 |
params: |
| 192 |
adom: "ansible" |
| 193 |
profile_group: "your_value" |
| 194 |
''' |
| 195 |
|
| 196 |
RETURN = ''' |
| 197 |
meta: |
| 198 |
description: The result of the request. |
| 199 |
type: dict |
| 200 |
returned: always |
| 201 |
contains: |
| 202 |
request_url: |
| 203 |
description: The full url requested. |
| 204 |
returned: always |
| 205 |
type: str |
| 206 |
sample: /sys/login/user |
| 207 |
response_code: |
| 208 |
description: The status of api request. |
| 209 |
returned: always |
| 210 |
type: int |
| 211 |
sample: 0 |
| 212 |
response_data: |
| 213 |
description: The api response. |
| 214 |
type: list |
| 215 |
returned: always |
| 216 |
response_message: |
| 217 |
description: The descriptive message of the api response. |
| 218 |
type: str |
| 219 |
returned: always |
| 220 |
sample: OK. |
| 221 |
system_information: |
| 222 |
description: The information of the target system. |
| 223 |
type: dict |
| 224 |
returned: always |
| 225 |
rc: |
| 226 |
description: The status the request. |
| 227 |
type: int |
| 228 |
returned: always |
| 229 |
sample: 0 |
| 230 |
version_check_warning: |
| 231 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 232 |
type: list |
| 233 |
returned: complex |
| 234 |
''' |
| 235 |
from ansible.module_utils.basic import AnsibleModule |
| 236 |
from ansible.module_utils.connection import Connection |
| 237 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 238 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 239 |
|
| 240 |
|
| 241 |
def main(): |
| 242 |
urls_list = [ |
| 243 |
'/pm/config/adom/{adom}/obj/firewall/profile-group', |
| 244 |
'/pm/config/global/obj/firewall/profile-group' |
| 245 |
] |
| 246 |
module_arg_spec = { |
| 247 |
'adom': {'required': True, 'type': 'str'}, |
| 248 |
'revision_note': {'type': 'str'}, |
| 249 |
'firewall_profilegroup': { |
| 250 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 251 |
'options': { |
| 252 |
'application-list': {'type': 'str'}, |
| 253 |
'av-profile': {'type': 'str'}, |
| 254 |
'dlp-sensor': {'type': 'str'}, |
| 255 |
'dnsfilter-profile': {'type': 'str'}, |
| 256 |
'icap-profile': {'type': 'str'}, |
| 257 |
'ips-sensor': {'type': 'str'}, |
| 258 |
'mms-profile': {'v_range': [['6.0.0', '7.6.2']], 'type': 'str'}, |
| 259 |
'name': {'required': True, 'type': 'str'}, |
| 260 |
'profile-protocol-options': {'type': 'str'}, |
| 261 |
'spamfilter-profile': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'str'}, |
| 262 |
'ssh-filter-profile': {'type': 'str'}, |
| 263 |
'ssl-ssh-profile': {'type': 'str'}, |
| 264 |
'voip-profile': {'type': 'str'}, |
| 265 |
'waf-profile': {'type': 'str'}, |
| 266 |
'webfilter-profile': {'type': 'str'}, |
| 267 |
'cifs-profile': {'v_range': [['6.2.0', '']], 'type': 'str'}, |
| 268 |
'emailfilter-profile': {'v_range': [['6.2.0', '']], 'type': 'str'}, |
| 269 |
'casi-profile': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'}, |
| 270 |
'file-filter-profile': {'v_range': [['6.4.1', '']], 'type': 'str'}, |
| 271 |
'videofilter-profile': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 272 |
'dlp-profile': {'v_range': [['7.2.0', '']], 'type': 'str'}, |
| 273 |
'sctp-filter-profile': {'v_range': [['7.0.1', '']], 'type': 'str'}, |
| 274 |
'ips-voip-filter': {'v_range': [['7.2.3', '']], 'type': 'str'}, |
| 275 |
'casb-profile': {'v_range': [['7.4.1', '']], 'type': 'str'}, |
| 276 |
'virtual-patch-profile': {'v_range': [['7.4.1', '']], 'type': 'str'}, |
| 277 |
'diameter-filter-profile': {'v_range': [['7.4.2', '']], 'type': 'str'}, |
| 278 |
'telemetry-profile': {'v_range': [['7.6.3', '']], 'type': 'raw'}, |
| 279 |
'ia-profile': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'raw'}, |
| 280 |
'isolator-profile': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'raw'}, |
| 281 |
'redirect-profile': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'raw'}, |
| 282 |
'llm-profile': {'v_range': [['7.6.5', '']], 'type': 'raw'} |
| 283 |
} |
| 284 |
} |
| 285 |
} |
| 286 |
|
| 287 |
module_option_spec = get_module_arg_spec('full crud') |
| 288 |
module_arg_spec.update(module_option_spec) |
| 289 |
check_galaxy_version(module_arg_spec) |
| 290 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_profilegroup'), |
| 291 |
supports_check_mode=True) |
| 292 |
if not module._socket_path: |
| 293 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 294 |
connection = Connection(module._socket_path) |
| 295 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 296 |
'name', 'data', module, connection) |
| 297 |
fmgr.process_crud() |
| 298 |
module.exit_json(meta=module.params) |
| 299 |
|
| 300 |
|
| 301 |
if __name__ == '__main__': |
| 302 |
main() |