Forum Discussion

Parveez_70209's avatar
Parveez_70209
Icon for Nimbostratus rankNimbostratus
Feb 04, 2014

How to Apply Irule Through CLI: Idea is to Share the tmsh script to create a Batch script which Windows Team can work edit accordingly

Hi Team,

The below is the Irule which we apply for the maintenance page which we applied through GUI, Kindly assist in letting know how can we apply through CLI,. This we need to give it to Application Team who can make a batch file, which they wanted to edit as per the requirement.

================================

when HTTP_REQUEST { Check active members of pool, if 0 respond with Apology Page. if { [active_members total-poc.redprairielabs.net-Pool] == 0 } { HTTP::respond 200 content {

The App is undergoing site maintenance This APP is currently down as it undergoing site maintenance. It will be available soon! Please check back again shortly. We apologize for the inconvenience.

If you need to reach us, please call 1-469-357-6900 or email HostingSD@jda.com.

    }
}

}

==========================================

Thanks and Regards Parveez

13 Replies

  • This works from me from CLI (but not from tmos shell). If I issue command from within tmos, it opens an editor. However, entering from advanced shell, it works: tmsh create ltm rule RULE_NAME XXX; where, XXX is the iRule. Here is exact example that modifies a header: tmsh create ltm rule MYRULE when HTTP_REQUEST { HTTP::header replace "Host" "4.2.2.2" } Good luck!
  • I have tested in my lab and below is the set to give you a better understanding.

     

    I have 1 vs with name test.lab.com and i created 3 irule with names as below hsl-irule-test1, hsl-irule-test2, hsl-irule-test3,

     

    My below output will help in understanding: *root@(bigip)(cfg-sync Standalone)(Active)(/Common)(tmos) list ltm virtual test.lab.com

     

    ltm virtual test.lab.com { destination 10.128.10.100:http ip-protocol tcp mask 255.255.255.255 pool test_lab_pool profiles { HSL-profile { } http { } tcp { } } source 0.0.0.0/0 source-address-translation { type automap } vs-index 2 } root@(bigip)(cfg-sync Standalone)(Active)(/Common)(tmos) root@(bigip)(cfg-sync Standalone)(Active)(/Common)(tmos) run util bash [root@bigip:Active:Standalone] config tmsh mod ltm virtual test.lab.com rules {hsl-irule-test1} [root@bigip:Active:Standalone] config tmsh list ltm virtual test.lab.com ltm virtual test.lab.com { destination 10.128.10.100:http ip-protocol tcp mask 255.255.255.255 pool test_lab_pool profiles { HSL-profile { } http { } tcp { } } rules { hsl-irule-test1 } source 0.0.0.0/0 source-address-translation { type automap } vs-index 2 } [root@bigip:Active:Standalone] config [root@bigip:Active:Standalone] config tmsh mod ltm virtual test.lab.com rules {hsl-irule-test2} [root@bigip:Active:Standalone] config tmsh list ltm virtual test.lab.com ltm virtual test.lab.com { destination 10.128.10.100:http ip-protocol tcp mask 255.255.255.255 pool test_lab_pool profiles { HSL-profile { } http { } tcp { } } rules { hsl-irule-test2 } source 0.0.0.0/0 source-address-translation { type automap } vs-index 2 } [root@bigip:Active:Standalone] config [root@bigip:Active:Standalone] config tmsh mod ltm virtual test.lab.com rules {hsl-irule-test1 hsl-irule-test3} [root@bigip:Active:Standalone] config tmsh list ltm virtual test.lab.com ltm virtual test.lab.com { destination 10.128.10.100:http ip-protocol tcp mask 255.255.255.255 pool test_lab_pool profiles { HSL-profile { } http { } tcp { } } rules { hsl-irule-test1 hsl-irule-test3 } source 0.0.0.0/0 source-address-translation { type automap } vs-index 2 } [root@bigip:Active:Standalone] config