Forum Discussion
can an irule call another irule
Hello, I have a setup where I'm required to maintain two almost identical irules for two separate VSs. I'm trying to find a way to write a simple wrapper irule that would add few conditions and exec the main irule if the conditions are true. Is it possible? Thanks in advance.
Alex
- John_Alam_45640Historic F5 Account
Can you write the iRule so as it is general enough to be used for both virtuals?
If not, try using procs. See this link:
Getting Started with iRules Procedures
There is an example about calling code that is outside the current iRule.
- alyubarov_3971NimbostratusThanks, John. This sounds like procs could help, but is it available in v10.x? Sorry, I should have been more specific in my question - we are at 10.2.4? Switch to 11 probably won't happen until the next year with the h/w upgrade.
- nitassEmployee
is it available in v10.x?
no, it is introduced in 11.4.0.
Getting Started with iRules Procedures by Jason Rahm
- Kevin_StewartEmployee
If I may add, procs would definitely be the way to go here. I might have also said that a sideband call might work, but that too requires v11. There still may be a way though, depending on how the main rule interacts with the VIPs, and at what (if any) event level it needs to fire. So lets say for example you have a main rule that gets triggered at HTTP_REQUEST, and your two almost identical iRules, which probably also trigger code at HTTP_REQUEST. You could add the main rule to each VIP and use a few conditions inside that iRule to determine when and what to run. For example:
VIP iRule:
when HTTP_REQUEST { ...doing something important here }
Main iRule:
when HTTP_REQUEST priority 501 { switch [virtual] { "app1-vs" { do something for app1 } "app2-vs" { do something for app2 } } }
In this way, you have a single main iRule that 1) gets triggered after your VIP-specific iRule, and 2) evaluates code based on the caller VIP.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com