firewall_rule - Create, modify or delete a firewall rule¶
New in version 2.5.
Synopsis¶
- Firewall rules can be added or removed from either a top level policy or a sub-policy. Source, destination and service elements can be used and referenced by their type and name (they must be pre-created). Many other rule settings are possible, including logging, inspection and connection tracking settings.
Options¶
| parameter | required | default | choices | comments | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| inspection_policy |
no |
Read only view of the inspection policy for this policy |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| policy |
yes |
The policy which to operate on. Any rule modifications are done in the context of this policy |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rules |
no |
Source elements to add to the rule. Elements need to specify the type of element to add. If source is not provided, the rule source cell will be set to none and the rule will effectively be disabled.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| state |
no | present |
|
Create or delete a firewall cluster |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sub_policy |
no |
The sub policy which to operate on. This is mutually exclusive with the policy parameter. You can operate on rules within a firewall policy or firewall sub policy. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| template |
no |
Read only view of the policy or sub policies template. This is returned by the facts module when retrieving rules |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Examples¶
- name: Example log all rule for top of rule set
firewall_rule:
policy: TestPolicy
rules:
- action: continue
comment: logging rule
log_options:
log_accounting_info_mode: true
log_closing_mode: true
log_level: stored
is_disabled: false
name: Log all continue rule
- name: Create a rule with specific sources and services
firewall_rule:
smc_logging:
level: 10
path: ansible-smc.log
policy: TestPolicy
rules:
- action: allow
comment: my comment
connection_tracking:
mss_enforced: true
mss_enforced_max: 1555
mss_enforced_min: 0
timeout: 11
destinations:
group:
- foogroup
host:
- host-1.1.1.1
ip_list:
- Amazon S3
network:
- foonet
inspection_options:
decrypting: null
deep_inspection: null
file_filtering: null
is_disabled: false
log_options:
application_logging: enforced
eia_executable_logging: 'off'
log_accounting_info_mode: false
log_closing_mode: true
log_compression: 'off'
log_level: none
log_payload_additionnal: true
log_payload_excerpt: false
log_payload_record: false
log_severity: -1
user_logging: enforced
name: ruletest2
services:
ip_service:
- CHAOS
tcp_service:
- AOL
udp_service:
- Biff
sources:
country:
- China
interface_nic_x_ip_alias:
- $$ Interface ID 0.ip
single_fw:
- myfw
- name: Create a rule to use VPN, requires a vpn_policy or mobile_vpn set
firewall_rule:
smc_logging:
level: 10
path: ansible-smc.log
inspection_policy: High-Security Inspection Template
policy: TestPolicy
rules:
- action: enforce_vpn
comment: my comment
connection_tracking:
mss_enforced: false
mss_enforced_max: -1
mss_enforced_min: -1
timeout: -1
destinations:
any: true
inspection_options:
decrypting: null
deep_inspection: null
file_filtering: null
is_disabled: false
authentication_options:
method:
- LDAP Authentication
require_auth: true
users:
- dc=lepages,dc=local,domain=myldapdomain
log_options:
application_logging: default
eia_executable_logging: default
log_accounting_info_mode: true
log_closing_mode: false
log_compression: 'off'
log_level: stored
log_payload_additionnal: false
log_payload_excerpt: false
log_payload_record: false
log_severity: -1
name: ruletest2
services:
any: true
sources:
any: true
vpn_policy: MOBILE CLIENT VPN
template: Firewall Inspection Template
- name: Add a deny rule after specified rule using add_after syntax
firewall_rule:
smc_logging:
level: 10
path: ansible-smc.log
policy: TestPolicy
rules:
- action: discard
comment: deny rule
is_disabled: false
name: my deny
add_after: '2097193.0'
- name: Delete a rule
firewall_rule:
policy: TestPolicy
rules:
- tag: '2097203.0'
state: absent