f5networks.f5_modules.bigip_policy_rule module – Manage LTM policy rules on a BIG-IP
Note
This module is part of the f5networks.f5_modules collection (version 1.17.0).
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 f5networks.f5_modules
.
To use it in a playbook, specify: f5networks.f5_modules.bigip_policy_rule
.
New in version 1.0.0: of f5networks.f5_modules
Requirements
The below requirements are needed on the host that executes this module.
BIG-IP >= v12.1.0
Parameters
Parameter |
Comments |
---|---|
The actions you want the policy rule to perform. The available attributes vary by the action, however, each action requires you specify a These conditions can be specified in any order. Despite the fact they are in a list, the order in the list does not matter to the BIG-IP. |
|
ASM policy to enable. This parameter is only valid with the |
|
Optional argument, specifying the time for which the session is persisted. This parameter is only valid with the |
|
Cookie name on which you want to persist. This parameter is only valid with the |
|
Target you want to disable. This parameter is only valid with the Choices:
|
|
Events on which actions, such as reset and forward, can be triggered. With the Valid event choices for Valid event choices for Valid event choices for |
|
A Tcl expression used with the |
|
HTTP Connect header you want to replace. This parameter is only valid with the |
|
Type of event when the Choices:
|
|
The port number. If a port number is not provided, the value is set to 0 by default. Be explicit when defining rules, so the system does not override port values. |
|
The value of |
|
HTTP Cookie header you want to remove or insert. This parameter is only valid with the |
|
Type of event when the Choices:
|
|
The name of |
|
The value of This is a mandatory parameter when configured with |
|
HTTP Header that you want to remove or insert. This parameter is only valid with the |
|
Type of event when the The All of events are valid with Choices:
|
|
The name of |
|
The value of Mandatory parameter when configured with |
|
HTTP Host header you want to replace. This parameter is only valid with the |
|
Type of event when the Choices:
|
|
The value of |
|
HTTP Referer header you want to remove, replace, or insert. This parameter is only valid with the |
|
Type of event when the c(http_referer) is removed, replaced, or inserted. Choices:
|
|
The value of This is a mandatory parameter when configured with This parameter is ignored for the This parameter is optional for the |
|
HTTP Set-Cookie header you want to remove or insert. This parameter is only valid with the |
|
The name of |
|
The value of This is a mandatory parameter when configured with |
|
Replaces HTTP URI, path, or string. This parameter is only valid with the |
|
Type of event when the Choices:
|
|
Specifies the part of the Choices:
|
|
The value of |
|
The new URL for which a redirect response is sent. A Tcl command substitution can be used for this field. |
|
Node to which you want to forward traffic. This parameter is only valid with the |
|
Pool to which you want to forward traffic. This parameter is only valid with the |
|
The action type. This value controls which of the following options are required. When When When When When When When When When When When Choices:
|
|
Variable name used with the |
|
Virtual server to which you want to forward traffic. This parameter is only valid with the |
|
A list of attributes that describe the condition. See suboptions for details on how to construct each list entry. The ordering of this list is important, the module ensures the order is kept when modifying the task. The suboption options below are not required for all condition types, read the description for more details. These conditions can be specified in any order. Despite the fact they are in a list, the order in the list does not matter to the BIG-IP. |
|
A list of IP Subnet address strings the IP address should match. This parameter is only valid with the |
|
A list of internal datagroup strings the IP address should match. This parameter is only valid with the |
|
A list of external datagroup strings the IP address should match. This parameter is only valid with the |
|
Events on which conditions type match rules can be triggered. Supported only for Valid choices for Valid choices for Valid choices for Valid choices for |
|
A list of strings of characters the HTTP Header value should match. This parameter is only valid with the |
|
A name of This parameter is only valid with the |
|
A list of strings of characters the HTTP Host should start with. This parameter is only valid with the |
|
A list of strings of characters the HTTP Host should end with. This parameter is only valid with the |
|
A list of strings of characters the HTTP Host should match. This parameter is only valid with the |
|
A list of strings of characters the HTTP Host should not match. This parameter is only valid with the |
|
A list of strings of characters the HTTP Method value should match. This parameter is only valid with the |
|
A list of strings of characters the HTTP URI should start with. This parameter is only valid with the |
|
A list of strings of characters the HTTP URI should contain. This parameter is only valid with the |
|
A list of strings of characters the HTTP URI should match. This parameter is only valid with the |
|
A list of strings of characters the SSL Extension should match. This parameter is only valid with the |
|
The condition type. This value controls which of the following options are required. When When When When When Choices:
|
|
Description of the policy rule. |
|
The name of the rule. |
|
Device partition to manage resources on. Default: “Common” |
|
The name of the policy you want to associate this rule with. |
|
A dict object containing connection details. |
|
Configures the auth provider for to obtain authentication tokens from the remote device. This option is really used when working with BIG-IQ devices. |
|
If You may omit this option by setting the environment variable Previously used variable Choices:
|
|
The password for the user account used to connect to the BIG-IP. You may omit this option by setting the environment variable |
|
The BIG-IP host. You may omit this option by setting the environment variable |
|
The BIG-IP server port. You may omit this option by setting the environment variable Default: 443 |
|
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. |
|
Configures the transport connection to use when connecting to the remote device. Choices:
|
|
The username to connect to the BIG-IP with. This user must have administrative privileges on the device. You may omit this option by setting the environment variable |
|
If You may omit this option by setting the environment variable Choices:
|
|
Specifies if the The option is useful when a subset of Using this option is not idempotent. Choices:
|
|
Specifies a number that indicates the order of this rule relative to other rules in the policy. When not set, the device sets the parameter to 0. If there are rules with the same rule order number, the device uses rule names to determine how the rules are ordered. The lower the number, the lower the rule is in the general order, with the lowest number Valid range of values is between |
|
When Choices:
|
Notes
Note
For more information on using Ansible to manage F5 Networks devices see https://www.ansible.com/integrations/networks/f5.
Requires BIG-IP software version >= 12.
The F5 modules only manipulate the running configuration of the F5 product. To ensure that BIG-IP specific configuration persists to disk, be sure to include at least one task that uses the f5networks.f5_modules.bigip_config module to save the running configuration. Refer to the module’s documentation for the correct usage of the module to save your running configuration.
Examples
- name: Create policies
bigip_policy:
name: Policy-Foo
state: present
provider:
server: lb.mydomain.com
user: admin
password: secret
delegate_to: localhost
- name: Add a rule to the new policy
bigip_policy_rule:
policy: Policy-Foo
name: rule3
conditions:
- type: http_uri
path_begins_with_any:
- /ABC
actions:
- type: forward
pool: pool-svrs
provider:
server: lb.mydomain.com
user: admin
password: secret
delegate_to: localhost
- name: Add multiple rules to the new policy
bigip_policy_rule:
policy: Policy-Foo
name: "{{ item.name }}"
conditions: "{{ item.conditions }}"
actions: "{{ item.actions }}"
provider:
server: lb.mydomain.com
user: admin
password: secret
delegate_to: localhost
loop:
- name: rule1
actions:
- type: forward
pool: pool-svrs
conditions:
- type: http_uri
path_begins_with_any:
- /euro
- name: rule2
actions:
- type: forward
pool: pool-svrs
conditions:
- type: http_uri
path_begins_with_any:
- /HomePage/
- name: rule3
actions:
- type: set_variable
variable_name: user-agent
expression: tcl:[HTTP::header User-Agent]
event: request
conditions:
- type: http_uri
path_begins_with_any:
- /HomePage/
- name: Remove all rules and conditions from the rule
bigip_policy_rule:
policy: Policy-Foo
name: rule1
conditions:
- type: all_traffic
actions:
- type: ignore
provider:
server: lb.mydomain.com
user: admin
password: secret
delegate_to: localhost
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The new list of actions applied to the rule. Returned: changed Sample: “hash/dictionary of values” |
|
Pool for forwarding to. Returned: changed Sample: “foo-pool” |
|
The action type. Returned: changed Sample: “forward” |
|
The new list of conditions applied to the rule. Returned: changed Sample: “hash/dictionary of values” |
|
List of strings the URI begins with. Returned: changed Sample: [“foo”, “bar”] |
|
The condition type. Returned: changed Sample: “http_uri” |
|
The new description of the rule. Returned: changed Sample: “My rule” |
|
Specifies a number that indicates the order of this rule relative to other rules in the policy. Returned: changed Sample: 10 |
Authors
Tim Rupp (@caphrim007)
Wojciech Wypior (@wojtek0806)