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.

Prerequisites

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

  1. Click the Workspace icon next to the F5 icon, and click Applications.

  2. Click iRules from the left menu.

  3. At the top of the screen, click Create.

  4. Type an Name for the iRule, and add an optional Description.

  5. 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.

    1. Begin typing the iRule function and select from the provided list.

    2. Press the SPACE bar to view a list of all valid events. You can type key words to filter the event list.

    3. Enter the conditions and commands. The editor will auto-populate commands according to iRule syntax.

  6. To copy the iRule click the copy button image to the top right of the editor.

  7. 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

Sample iRule creation

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 name

  • content: iRule schema in Tcl

  • description: 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

  1. Click the Workspace icon next to the F5 icon, and click Applications.

  2. Click iRules from the left menu.

  3. Click the iRule name. A panel for the iRules properties and content editor is displayed.

  4. 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.

  5. (Optional) Update the Name and add a Description.

  6. From the panel menu click iRule Editor.

    The editor contains the iRule script from the original iRule.

  7. 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 name

  • content - The iRule schema in Tcl

  • description - (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

  1. Click the Workspace icon next to the F5 icon, and click iRules.

  2. Click check box next to the iRule name.

  3. 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.

  1. Click the Workspace icon next to the F5 icon, and click Applications.

  2. Click iRules from the left menu.

  3. Click the iRule name.

    A panel for the iRules properties and content editor is displayed.

  4. Select the version to the right of the iRule name.

  5. Select the drop-down to the right of the iRule name and select Stage from this version.

    iRule version selection

  6. To add applications:

    1. Click Start Attaching.

    2. Click the check box next to each application you would like to attach.

    3. Click Attach.

  7. To edit applications (only for staged versions):

    1. Select iRule Editor from the panel menu

    2. Ensure the mode is set to Single Edit.

    3. Edit the iRules. For more information about iRule customization, see iRules Home.

  8. 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.

    1. Click Deploy Changes.

    2. Confirm the action. The deployment progress message shows the stage of iRule deployment to the attached applications.

  9. To save changes and create a new iRule version with your changes:

    Saving changes updates the iRule version.

    1. Click Commit Changes.

    2. To save the changes with the attached application list, click Yes, Save.

    3. To save and attach any application associated with the iRule, click More save options, select Save and attach all.., and click Yes, Save.

    4. To save changes without any applications attached to the new version, click More save options, select Save without…, and click Yes, Save.

  10. To discard the staged iRule and revert it back to the previous version:

    1. Click Revert.

    2. 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

  1. Click the Workspace icon next to the F5 icon, and click Applications.

  2. Click iRules from the left menu.

  3. Click the iRule name. A panel for the iRules properties and content editor is displayed.

  4. To verify which applications are attached to each iRule version:

    1. Click the drop-down list for the iRule version and select Show version history. See example of version selection:

      iRule version selection

    2. 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.

    1. Close the version history panel.

  5. Select the iRule version you would like to revert one or more applications to.

  6. From the Attached Applications area, click Start Attaching or + Add.

  7. Click the check box next to each application you would like to attach.

  8. Click Attach.

  9. Click Deploy Changes.

    Note: At least one application needs to be attached to the iRule to deploy changes.

  10. 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.

  1. Click the Workspace icon next to the F5 icon, and click Applications.

  2. Click iRules from the left menu.

  3. Click the iRule name. A panel for the iRules properties and content editor is displayed.

  4. 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.

  5. From the panel menu click iRule Editor.

  6. From Mode select Compare(Diff).

  7. 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.