Forum Discussion

Chase_Hoffman_2's avatar
Chase_Hoffman_2
Icon for Nimbostratus rankNimbostratus
Jul 19, 2012

How do I create Sequential or Linked iRules?

So I'm a bit of an F5 novice, so please forgive me if this question is stupid.

 

 

I have an iRule currently which is programmatically updated by a web app as web applications are deployed. It works great. Basically it redirects PRODSITE.COM/CLIENTSPECIFCURI to a PRODSERVERPOOL based on /CLIENTSPECIFICURI.

 

 

I'd like to create an iRule ahead of it such that anything arriving to TESTSITE.COM goes to TESTSERVERPOOL. Because of the programatically generated nature of the PRODSITE iRule, I'd like to avoid putting code into it if possible.

 

 

Can anyone shed some light on this for me?

 

  • Joe,

     

     

    Thanks for the help.

     

     

    Having read your tutorial, I think I may have phrased my question badly.

     

     

    What I was hoping to do was basically:

     

     

    If host == testsite, go to pool testsite

     

    If host != testsite, go to iRule prodsite

     

     

    Since that isn't possible, how do I do a rule where it checks if the host = testsite, and, if not, does nothing? Presumably then the next rule in the priority order would take effect (in this case the programatically generated iRule looking at URIs).

     

     

    Thank you so much for your help.
  • That get's a little more difficult as there isn't a direct way to call an iRule from another iRule. What you'll need to do is to create a session variable to handle state and you. Here's some pseudo code that may help

    priority 100

    when HTTP_REQUEST {

    set PROCESS_IRULE_PRODSITE 1;

    if { [HTTP::host] eq "testsite" } {

    Assign target pool (if this is the default pool, this can be omitted).

    pool testsite

    Do not process prodsite iRule

    set PROCESS_IRULE_PRODSITE 0;

    }

    }

    priority 200

    when HTTP_REQUEST {

    if { $PROCESS_IRULE_PRODSITE == 1 } {

    Do something

    }

    }

    I think that's what you are going after.

    -Joe

  • Are there only the 2 rules assigned to the VIPs doing Pool assignment?

    As if that's the case, couldn't you just use 'Event disable' in your test iRule if it's a test connection...

     

     
    when HTTP_REQUEST {
     if { [HTTP::host] eq "testsite" } {
         Assign target pool (if this is the default pool, this can be omitted).
        pool testsite
         Do not process prodsite iRule
        event disable
      }
    }
    

     

    Cheers

    Gav

  • Joe,

     

     

    Thanks, I'll give that a shot!

     

     

    Gavin,

     

     

    Yes, there are the only two iRules. I'll try that one as well.

     

     

    Thank you both so much for your help.