How to: Create and manage iRules on BIG-IP Next Central Manager¶
The following describes how to create a new, edit, or delete iRules using BIG-IP Next Central Manager.
iRules are created using the programming language Tcl. To create or modify an iRule you need to have familiarity with Tcl and iRule commands.
For information about attaching iRules to an application service, see Use the BIG-IP Next Central Manager UI to deploy a new application.
For more information about iRule structure, uses, and traffic management customizations see F5 iRule documentation iRules Home.
General iRule creation and management¶
Managing iRule versions¶
When you edit an existing iRule, a new version of that iRule is saved to BIG-IP Next Central Manager. You can use iRule versioning to test changes to an iRule and see if they meet the requirements of an application. If the changes do not meet the requirements, you can revert to an earlier version of the iRule.
<! To revert an application to a different version of the same iRule, you can select an earlier version of that iRule to deploy with the application. > For more information about deploying iRules with an application, see How to: Deploy iRules to a FAST application on BIG-IP Next Central Manager.
Edit an iRule - Stage an iRule versions to edit the iRule and commit changes to create a new version.
Deploy applications with a specific iRule version - Change the iRule version used with an application.
Compare iRule versions - Compare versions of the same iRule (in read-only) to one-another.
Prerequisites¶
(Recommended) To deploy iRules to an application service, you need to create an application service with iRules.
Ensure application services with iRules have the correct iRules attached. See How to: Manage applications using BIG-IP Next Central Manager and FAST templates
Create an iRule¶
Create an iRule using the UI or API. Once you create an iRule, you can add it to one of your applications, or create a new application using a iRule application template.
See Example iRules provided in BIG-IP Next Central Manager. These are commonly applied iRules that you can use as examples copy or clone.
Create an iRule-UI¶
Click the Workspace icon next to the F5 icon, and click Applications.
Click iRules from the left menu.
At the top of the screen, click Create.
Type an Name for the iRule, and add an optional Description.
Click on line 1 of the editor in the panel to start creating the iRule. The following is an example procedure for a simple iRule:
Note: The UI includes inline syntax validation. The editor provides a list of allowed Tcl/iRule syntax as you add to the schema. With any list-selected input, you can hover over the schema element to view details and use case examples for that selection. See a sample iRule procedure in the GIF below.
To copy the iRule click the copy button
to the top right of the editor.
Click Save.
The new iRule is added to the iRules list. To deploy iRules to a secure FAST application, see How to: Deploy iRules to an application on BIG-IP Next Central Manager.
Sample iRule in editor¶
Create an iRule-API¶
Use the following procedure to create a new iRule.
Send a POST request using the iRule OpenAPI.
POST https://{{bigip_next_cm_mgmt_ip}}/api/v1/spaces/default/irules
The body of the POST must include:
name
: iRule namecontent
: iRule schema in Tcldescription
: Optional - Additional information about the iRule.
Clone an iRule¶
Clone an iRule to work with an existing iRules contents, without creating a new iRule from scratch using the BIG-IP Next Central Manager UI.
See Create a new iRule - API to create an iRule using the API.
Clone an iRule - UI¶
Click the Workspace icon next to the F5 icon, and click Applications.
Click iRules from the left menu.
Click the iRule name. A panel for the iRules properties and content editor is displayed.
To the top right of the panel, click Clone.
The Clone iRule panel opens. Name is automatically populated with original iRule’s name and the prefix
clone
.(Optional) Update the Name and add a Description.
From the panel menu click iRule Editor.
The editor contains the iRule script from the original iRule.
When you have completed changes to the iRule, click Save.
The cloned iRule is added to the iRules list. To deploy iRules to a secure FAST application, see How to: Deploy iRules to an application on BIG-IP Next Central Manager.
Clone an iRule–API¶
Use the following procedure to create a new iRule.
Send a POST request using the iRule OpenAPI.
POST https://{{bigip_next_cm_mgmt_ip}}/api/v1/spaces/default/irules
The body of the POST must include:
name
- iRule namecontent
- The iRule schema in Tcldescription
- (optional)Additional information about the iRule.
Delete an iRule¶
You can remove an iRule. Ensure that you have removed the iRule from any attached applications. You can only delete one iRule at a time.
Delete an iRule–UI¶
Click the Workspace icon next to the F5 icon, and click iRules.
Click check box next to the iRule name.
Click Delete.
The iRule is deleted from the iRules list.
Delete an iRule–API¶
Use the following procedure to delete an iRule.
You will need the name (nameOrID
) of the iRule. Use the following GET request to see a full list of iRules on BIG-IP
Next Central Manager and their details:
GET https://{{bigip_next_cm_mgmt_ip}}/api/v1/spaces/default/irules
Send a DELETE request with changes to the iRule content
using the iRule OpenAPI.
DELETE https://{{bigip_next_cm_mgmt_ip}}/api/v1/spaces/default/irules/{nameOrID}
Edit an iRule¶
You can edit a staged version of an iRule BIG-IP Next Central Manager. Use the following procedures to make changes. Changes to an iRule automatically create a new iRule version.
Edit an iRule-UI¶
Staging an iRule version allows you to edit and create a new version of that iRule.
Once you complete staging and deploy an application, a new version is created, while the staged application remains.
Note: Each user login can create only 1 staged version per iRule. If multiple users can log in to your BIG-IP Next Central Manager environment, you may see more that one staged version. You can only edit staged iRules with your login version.
Click the Workspace icon next to the F5 icon, and click Applications.
Click iRules from the left menu.
Click the iRule name.
A panel for the iRules properties and content editor is displayed.
Select the version to the right of the iRule name.
Select the drop-down to the right of the iRule name and select Stage from this version.
To add applications:
Click Start Attaching.
Click the check box next to each application you would like to attach.
Click Attach.
To edit applications (only for staged versions):
Select iRule Editor from the panel menu
Ensure the mode is set to Single Edit.
Edit the iRules. For more information about iRule customization, see iRules Home.
To deploy the staged version without creating a new iRules version:
Note: At least one application needs to be attached to the iRule to deploy changes.
Click Deploy Changes.
Confirm the action. The deployment progress message shows the stage of iRule deployment to the attached applications.
To save changes and create a new iRule version with your changes:
Saving changes updates the iRule version.
Click Commit Changes.
To save the changes with the attached application list, click Yes, Save.
To save and attach any application associated with the iRule, click More save options, select Save and attach all.., and click Yes, Save.
To save changes without any applications attached to the new version, click More save options, select Save without…, and click Yes, Save.
To discard the staged iRule and revert it back to the previous version:
Click Revert.
Confirm the action.
The iRule version is updated with the latest changes and a new version is created to reflect the latest changes (if the staged version was not reverted). To attach an application to an older version, see Deploy applications with a specific iRule version.
Edit an iRule-API¶
Use the following procedure to edit an existing iRule.
You will need the name (nameOrID
) of the iRule. Use the following GET request to see a full list of iRules on BIG-IP
Next Central Manager and their details:
GET https://{{bigip_next_cm_mgmt_ip}}/api/v1/spaces/default/irules
Send a PUT request with changes to the iRule content
using the iRule OpenAPI.
PUT https://{{bigip_next_cm_mgmt_ip}}/api/v1/spaces/default/irules/{nameOrID}
Example request body for editing an iRule Needs sample
Deploy applications with a specific iRule version¶
You can revert attached applications to an iRule to an earlier version of that iRule. Ensure that you have created applications for the iRule. See How to: Deploy iRules to a FAST application on BIG-IP Next Central Manager
Click the Workspace icon next to the F5 icon, and click Applications.
Click iRules from the left menu.
Click the iRule name. A panel for the iRules properties and content editor is displayed.
To verify which applications are attached to each iRule version:
Click the drop-down list for the iRule version and select Show version history. See example of version selection:
From the version history panel you can view the number of applications for each version. You can also expand a version
to view which applications are attached.
Close the version history panel.
Select the iRule version you would like to revert one or more applications to.
From the Attached Applications area, click Start Attaching or + Add.
Click the check box next to each application you would like to attach.
Click Attach.
Click Deploy Changes.
Note: At least one application needs to be attached to the iRule to deploy changes.
Confirm the action. The deployment progress message shows the stage of iRule deployment to the attached applications.
The applications are now deployed to the select iRule version. The Attached applications list will display which iRule version was previously used.
Compare iRule versions¶
You can compare a staged iRule to another iRule, or a different iRule. View differences and decide whether to edit or attach/detach applications.
Click the Workspace icon next to the F5 icon, and click Applications.
Click iRules from the left menu.
Click the iRule name. A panel for the iRules properties and content editor is displayed.
Select the version to the right of the iRule name (recommended to select the staged iRule version).
Note: You can click Show Version History to view a full version list. Then select 2 versions and click Compare. This option limits is a view-only editor.
From the panel menu click iRule Editor.
From Mode select Compare(Diff).
From Compare to iRule select an iRule, and select a Version.
Note: If you do not select the most recent version a banner will appear on the panel. From the banner you can select the latest version, or the staged version, if available.
The editor highlights differences between the two selected iRules. To edit the iRule change the mode back to Single Editor and ensure you are on the latest version or the staged version.