fortinet.fortios.fortios_firewall_policy – Configure IPv4 policies in Fortinet’s FortiOS and FortiGate.
Note
This plugin is part of the fortinet.fortios collection (version 2.1.3).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install fortinet.fortios
.
To use it in a playbook, specify: fortinet.fortios.fortios_firewall_policy
.
New in version 2.10: of fortinet.fortios
Synopsis
This module is able to configure a FortiGate or FortiOS (FOS) device by allowing the user to set and modify firewall feature and policy category. Examples include all parameters and values need to be adjusted to datasources before usage. Tested with FOS v6.0.0
Requirements
The below requirements are needed on the host that executes this module.
ansible>=2.9.0
Parameters
Parameter |
Comments |
---|---|
Token-based authentication. Generated from GUI of Fortigate. |
|
the action indiactor to move an object in the list Choices:
|
|
mkey of target identifier |
|
mkey of target identifier |
|
Enable/Disable logging for task. Choices:
|
|
Configure IPv4 policies. |
|
Policy action (allow/deny/ipsec). Choices:
|
|
Enable/disable anti-replay check. Choices:
|
|
Application category ID list. |
|
Category IDs. |
|
Application group names. |
|
Application group names. Source application.group.name. |
|
Application ID list. |
|
Application IDs. |
|
Name of an existing Application list. Source application.list.name. |
|
HTTPS server certificate for policy authentication. Source vpn.certificate.local.name. |
|
Enable/disable authentication-based routing. Choices:
|
|
HTTP-to-HTTPS redirect address for firewall authentication. |
|
Enable/disable offloading security profile processing to CP processors. Choices:
|
|
Name of an existing Antivirus profile. Source antivirus.profile.name. |
|
Enable/disable block notification. Choices:
|
|
Enable to exempt some users from the captive portal. Choices:
|
|
Enable/disable capture packets. Choices:
|
|
Name of an existing CIFS profile. Source cifs.profile.name. |
|
Comment. |
|
Custom fields to append to log messages for this policy. |
|
Custom log field. Source log.custom-field.id. |
|
Decrypted traffic mirror. Source firewall.decrypted-traffic-mirror.name. |
|
Enable TCP NPU session delay to guarantee packet order of 3-way handshake. Choices:
|
|
Names of devices or device groups that can be matched by the policy. |
|
Device or group name. Source user.device.alias user.device-group.name user.device-category.name. |
|
Enable to change packet”s DiffServ values to the specified diffservcode-forward value. Choices:
|
|
Enable to change packet”s reverse (reply) DiffServ values to the specified diffservcode-rev value. Choices:
|
|
Change packet”s DiffServ to this value. |
|
Change packet”s reverse (reply) DiffServ to this value. |
|
Enable/disable user authentication disclaimer. Choices:
|
|
Name of an existing DLP sensor. Source dlp.sensor.name. |
|
Name of an existing DNS filter profile. Source dnsfilter.profile.name. |
|
Enable DSCP check. Choices:
|
|
Enable negated DSCP match. Choices:
|
|
DSCP value. |
|
Enable DSRI to ignore HTTP server responses. Choices:
|
|
Destination address and address group names. |
|
Address name. Source firewall.address.name firewall.addrgrp.name firewall.vip.name firewall.vipgrp.name. |
|
Destination IPv6 address name and address group names. |
|
Address name. Source firewall.address6.name firewall.addrgrp6.name firewall.vipgrp6.name firewall.vip6.name system .external-resource.name. |
|
When enabled dstaddr specifies what the destination address must NOT be. Choices:
|
|
Outgoing (egress) interface. |
|
Interface name. Source system.interface.name system.zone.name. |
|
Enable/disable dynamic RADIUS defined traffic shaping. Choices:
|
|
Enable/disable email collection. Choices:
|
|
Name of an existing email filter profile. Source emailfilter.profile.name. |
|
Name of an existing file-filter profile. Source file-filter.profile.name. |
|
How to handle sessions if the configuration of this firewall policy changes. Choices:
|
|
Enable to prevent source NAT from changing a session”s source port. Choices:
|
|
Enable/disable Fortinet Single Sign-On. Choices:
|
|
FSSO agent to use for NTLM authentication. Source user.fsso.name. |
|
Names of FSSO groups. |
|
Names of FSSO groups. Source user.adgrp.name. |
|
Enable/disable recognition of anycast IP addresses using the geography IP database. Choices:
|
|
Match geography address based either on its physical location or registered location. Choices:
|
|
Label for the policy that appears when the GUI is in Global View mode. |
|
Names of user groups that can authenticate with this policy. |
|
Group name. Source user.group.name. |
|
GTP profile. Source firewall.gtp.name. |
|
Redirect HTTP(S) traffic to matching transparent web proxy policy. Choices:
|
|
Name of an existing ICAP profile. Source icap.profile.name. |
|
Name of identity-based routing rule. Source firewall.identity-based-route.name. |
|
Policy-based IPsec VPN: only traffic from the remote network can initiate a VPN. Choices:
|
|
Policy inspection mode (Flow/proxy). Default is Flow mode. Choices:
|
|
Enable/disable use of Internet Services for this policy. If enabled, destination address and service are not used. Choices:
|
|
Custom Internet Service name. |
|
Custom Internet Service name. Source firewall.internet-service-custom.name. |
|
Custom Internet Service group name. |
|
Custom Internet Service group name. Source firewall.internet-service-custom-group.name. |
|
Internet Service group name. |
|
Internet Service group name. Source firewall.internet-service-group.name. |
|
Internet Service ID. |
|
Internet Service ID. Source firewall.internet-service.id. |
|
Internet Service name. |
|
Internet Service name. Source firewall.internet-service-name.name. |
|
When enabled internet-service specifies what the service must NOT be. Choices:
|
|
Enable/disable use of Internet Services in source for this policy. If enabled, source address is not used. Choices:
|
|
Custom Internet Service source name. |
|
Custom Internet Service name. Source firewall.internet-service-custom.name. |
|
Custom Internet Service source group name. |
|
Custom Internet Service group name. Source firewall.internet-service-custom-group.name. |
|
Internet Service source group name. |
|
Internet Service group name. Source firewall.internet-service-group.name. |
|
Internet Service source ID. |
|
Internet Service ID. Source firewall.internet-service.id. |
|
Internet Service source name. |
|
Internet Service name. Source firewall.internet-service-name.name. |
|
When enabled internet-service-src specifies what the service must NOT be. Choices:
|
|
Enable to use IP Pools for source NAT. Choices:
|
|
Name of an existing IPS sensor. Source ips.sensor.name. |
|
Label for the policy that appears when the GUI is in Section View mode. |
|
Enable to allow everything, but log all of the meaningful data for security information gathering. A learning report will be generated. Choices:
|
|
Enable or disable logging. Log all sessions or security profile sessions. Choices:
|
|
Record logs when a session starts and ends. Choices:
|
|
Enable to match packets that have had their destination addresses changed by a VIP. Choices:
|
|
Enable/disable matching of only those packets that have had their destination addresses changed by a VIP. Choices:
|
|
Name of an existing MMS profile. Source firewall.mms-profile.name. |
|
Policy name. |
|
Enable/disable source NAT. Choices:
|
|
Enable/disable NAT46. Choices:
|
|
Enable/disable NAT64. Choices:
|
|
Policy-based IPsec VPN: apply destination NAT to inbound traffic. Choices:
|
|
Policy-based IPsec VPN: source NAT IP address for outgoing traffic. |
|
Policy-based IPsec VPN: apply source NAT to outbound traffic. Choices:
|
|
Enable/disable UTM Network Processor acceleration. Choices:
|
|
Enable/disable NTLM authentication. Choices:
|
|
HTTP-User-Agent value of supported browsers. |
|
User agent string. |
|
Enable/disable NTLM guest user access. Choices:
|
|
Policy-based IPsec VPN: only traffic from the internal network can initiate a VPN. Choices:
|
|
Enable/disable passive WAN health measurement. When enabled, auto-asic-offload is disabled. Choices:
|
|
Per-IP traffic shaper. Source firewall.shaper.per-ip-shaper.name. |
|
Accept UDP packets from any host. Choices:
|
|
Accept UDP packets from any Session Traversal Utilities for NAT (STUN) host. Choices:
|
|
PFCP profile. Source firewall.pfcp.name. |
|
Policy ID. |
|
IP Pool names. |
|
IP pool name. Source firewall.ippool.name. |
|
IPv6 pool names. |
|
IPv6 pool name. Source firewall.ippool6.name. |
|
Name of profile group. Source firewall.profile-group.name. |
|
Name of an existing Protocol options profile. Source firewall.profile-protocol-options.name. |
|
Determine whether the firewall policy allows security profile groups or single profiles only. Choices:
|
|
Enable MAC authentication bypass. The bypassed MAC address must be received from RADIUS server. Choices:
|
|
URL users are directed to after seeing and accepting the disclaimer or authenticating. |
|
Override the default replacement message group for this policy. Source system.replacemsg-group.name. |
|
Direction of the initial traffic for reputation to take effect. Choices:
|
|
Minimum Reputation to take action. Source firewall.internet-service-reputation.id. |
|
Enable/disable RADIUS single sign-on (RSSO). Choices:
|
|
Address names if this is an RTP NAT policy. |
|
Address name. Source firewall.address.name firewall.addrgrp.name. |
|
Enable Real Time Protocol (RTP) NAT. Choices:
|
|
Block or monitor connections to Botnet servers or disable Botnet scanning. Choices:
|
|
Schedule name. Source firewall.schedule.onetime.name firewall.schedule.recurring.name firewall.schedule.group.name. |
|
Enable to force current sessions to end when the schedule object times out. Disable allows them to end from inactivity. Choices:
|
|
Name of an existing SCTP filter profile. Source sctp-filter.profile.name. |
|
Enable to send a reply when a session is denied or blocked by a firewall policy. Choices:
|
|
Service and service group names. |
|
Service and service group names. Source firewall.service.custom.name firewall.service.group.name. |
|
When enabled service specifies what the service must NOT be. Choices:
|
|
TTL in seconds for sessions accepted by this policy (0 means use the system ). |
|
Security group tags. |
|
Security group tag. |
|
Enable/disable security group tags (SGT) check. Choices:
|
|
Name of an existing Spam filter profile. Source spamfilter.profile.name. |
|
Vendor MAC source ID. |
|
Vendor MAC ID. Source firewall.vendor-mac.id. |
|
Source address and address group names. |
|
Address name. Source firewall.address.name firewall.addrgrp.name. |
|
Source IPv6 address name and address group names. |
|
Address name. Source firewall.address6.name firewall.addrgrp6.name system.external-resource.name. |
|
When enabled srcaddr specifies what the source address must NOT be. Choices:
|
|
Incoming (ingress) interface. |
|
Interface name. Source system.interface.name system.zone.name. |
|
Name of an existing SSH filter profile. Source ssh-filter.profile.name. |
|
Redirect SSH traffic to matching transparent proxy policy. Choices:
|
|
Enable to copy decrypted SSL traffic to a FortiGate interface (called SSL mirroring). Choices:
|
|
SSL mirror interface name. |
|
Mirror Interface name. Source system.interface.name system.zone.name. |
|
Name of an existing SSL SSH profile. Source firewall.ssl-ssh-profile.name. |
|
Enable or disable this policy. Choices:
|
|
Receiver TCP maximum segment size (MSS). |
|
Sender TCP maximum segment size (MSS). |
|
Enable/disable creation of TCP session without SYN flag. Choices:
|
|
Enable/disable sending RST packets when TCP sessions expire. Choices:
|
|
ToS (Type of Service) value used for comparison. |
|
Non-zero bit positions are used for comparison while zero bit positions are ignored. |
|
Enable negated TOS match. Choices:
|
|
Traffic shaper. Source firewall.shaper.traffic-shaper.name. |
|
Reverse traffic shaper. Source firewall.shaper.traffic-shaper.name. |
|
URL category ID list. |
|
URL category ID. |
|
Names of individual users that can authenticate with this policy. |
|
Names of individual users that can authenticate with this policy. Source user.local.name. |
|
Enable to add one or more security profiles (AV, IPS, etc.) to the firewall policy. Choices:
|
|
Universally Unique Identifier (UUID; automatically assigned but can be manually reset). |
|
Name of an existing VideoFilter profile. Source videofilter.profile.name. |
|
VLAN forward direction user priority: 255 passthrough, 0 lowest, 7 highest. |
|
VLAN reverse direction user priority: 255 passthrough, 0 lowest, 7 highest.. |
|
Set VLAN filters. |
|
Name of an existing VoIP profile. Source voip.profile.name. |
|
Policy-based IPsec VPN: name of the IPsec VPN Phase 1. Source vpn.ipsec.phase1.name vpn.ipsec.manualkey.name. |
|
Name of an existing Web application firewall profile. Source waf.profile.name. |
|
Enable/disable WAN optimization. Choices:
|
|
WAN optimization auto-detection mode. Choices:
|
|
WAN optimization passive mode options. This option decides what IP address will be used to connect server. Choices:
|
|
WAN optimization peer. Source wanopt.peer.peer-host-id. |
|
WAN optimization profile. Source wanopt.profile.name. |
|
Enable/disable forwarding traffic matching this policy to a configured WCCP server. Choices:
|
|
Enable/disable web cache. Choices:
|
|
Enable/disable web cache for HTTPS. Choices:
|
|
Name of an existing Web filter profile. Source webfilter.profile.name. |
|
Webproxy forward server name. Source web-proxy.forward-server.name web-proxy.forward-server-group.name. |
|
Webproxy profile name. Source web-proxy.profile.name. |
|
Enable/disable WiFi Single Sign On (WSSO). Choices:
|
|
Source ztna-ems-tag names. |
|
Address name. Source firewall.address.name firewall.addrgrp.name. |
|
Source ztna-geo-tag names. |
|
Address name. Source firewall.address.name firewall.addrgrp.name. |
|
Enable/disable zero trust access. Choices:
|
|
Member attribute path to operate on. Delimited by a slash character if there are more than one attribute. Parameter marked with member_path is legitimate for doing member operation. |
|
Add or delete a member under specified attribute path. When member_state is specified, the state option is ignored. Choices:
|
|
mkey of self identifier |
|
Indicates whether to create or remove the object. Choices:
|
|
Virtual domain, among those defined previously. A vdom is a virtual instance of the FortiGate that can be configured and used as a different unit. Default: “root” |
Notes
Note
Legacy fortiosapi has been deprecated, httpapi is the preferred way to run playbooks
Adjust object order by moving self after(before) another.
Only one of [after, before] must be specified when action is moving an object.
Examples
- collections:
- fortinet.fortios
connection: httpapi
hosts: fortigate01
vars:
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
vdom: root
tasks:
- name: fortios_firewall_policy
fortios_firewall_policy:
vdom: root
state: present
firewall_policy:
action: accept
anti_replay: enable
auth_path: disable
auto_asic_offload: enable
block_notification: disable
captive_portal_exempt: disable
delay_tcp_npu_session: disable
diffserv_forward: disable
diffserv_reverse: disable
diffservcode_forward: '000000'
diffservcode_rev: '000000'
disclaimer: disable
dsri: disable
dstaddr:
- all
dstaddr_negate: disable
dstintf:
- any
email_collect: disable
firewall_session_dirty: check-all
fixedport: disable
geoip_anycast: disable
geoip_match: physical-location
http_policy_redirect: disable
inbound: disable
inspection_mode: flow
internet_service: disable
internet_service_negate: disable
internet_service_src: disable
internet_service_src_negate: disable
ippool: disable
logtraffic: utm
logtraffic_start: disable
match_vip: disable
match_vip_only: disable
name: terr_policy
nat: enable
natinbound: disable
natip: 0.0.0.0 0.0.0.0
natoutbound: disable
ntlm: disable
ntlm_guest: disable
outbound: enable
permit_any_host: disable
permit_stun_host: disable
policyid: 1
profile_protocol_options: default
profile_type: single
radius_mac_auth_bypass: disable
reputation_direction: destination
reputation_minimum: 0
rtp_nat: disable
schedule: always
schedule_timeout: disable
send_deny_packet: disable
service:
- ALL
service_negate: disable
session_ttl: 0
srcaddr:
- all
srcaddr_negate: disable
srcintf:
- any
ssh_policy_redirect: disable
ssl_ssh_profile: no-inspection
status: enable
tcp_mss_receiver: 0
tcp_mss_sender: 0
tcp_session_without_syn: disable
timeout_send_rst: disable
tos: '0x00'
tos_mask: '0x00'
tos_negate: disable
utm_status: disable
vlan_cos_fwd: 2
vlan_cos_rev: 2
wccp: disable
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Build number of the fortigate image Returned: always Sample: “1547” |
|
Last method used to provision the content into FortiGate Returned: always Sample: “PUT” |
|
Last result given by FortiGate on last operation applied Returned: always Sample: “200” |
|
Master key (id) used in the last call to FortiGate Returned: success Sample: “id” |
|
Name of the table used to fulfill the request Returned: always Sample: “urlfilter” |
|
Path of the table used to fulfill the request Returned: always Sample: “webfilter” |
|
Internal revision number Returned: always Sample: “17.0.2.10658” |
|
Serial number of the unit Returned: always Sample: “FGVMEVYYQT3AB5352” |
|
Indication of the operation’s result Returned: always Sample: “success” |
|
Virtual domain used Returned: always Sample: “root” |
|
Version of the FortiGate Returned: always Sample: “v5.6.3” |
Authors
Link Zheng (@chillancezen)
Jie Xue (@JieX19)
Hongbin Lu (@fgtdev-hblu)
Frank Shen (@frankshen01)
Miguel Angel Munoz (@mamunozgonzalez)
Nicolas Thomas (@thomnico)