Forum Discussion

Andy_Herrman_22's avatar
Andy_Herrman_22
Icon for Nimbostratus rankNimbostratus
May 25, 2010

Load iRule from external file using bigpipe

The iRules that I use are stored in .tcl files in source control. I'm trying to write a simple perl script that can be used by our deployment team to do the next deploy and I'm wondering if there's a way I could construct a `bigpipe` command to load the iRule from the file. I'm not seeing anything in `b rule help` to suggest it can load from an external file. I'm using BIG-IP Version 9.3.0 178.5
  • I don't believe there is a way to "read in" an external file using bigpipe. Are you just trying to keep them abstracted from the F5 CLI and GUI? If so, you could always just give them the iRule Editor.

     

     

    If you want something more elegant, iControl/PERL could be used to script up a rule creation:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iControl/LocalLB__Rule.html

     

     

    Cheers,

     

    Keith
  • I'm trying to make the deploy as brain-dead as possible. My preference is they scp the files to the bigip, run the script, and they're done.

     

     

    Pulling in iControl feels like overkill for this. My script is just generating bigpipe commands to do the actual deploy (some of the stuff I'm using can be found here: http://github.com/aherrman/f5)

     

     

    I think I found a way to do it, just haven't had a chance to test it yet. If what I found works I'll post it.
  • The iControl interface for iRules is very simple and I'm sure I've got a few samples of loading/saving iRules. I'll check when I get back into the office. The nice thing about the perl interface is that all the required libraries are already on the LTM. I'll post if I find something (or when I write one for you).

     

     

    -Joe

     

  • iControl felt a bit like overkill to me. Also, I don't actually *know* perl, and generally just use it to automate the creation of shell commands. I'm very used to the bigpipe command, so it felt natural to just write a script to automatically generate the bigpipe commands I was already used to using.

     

     

    I was also worried that using iControl would require some extra configuration to get running (like authentication stuff, though I could be wrong), and we've had problems in the past with the people doing the deploys not always configuring things properly. That's why I want to have it just be a 2-step process. Upload files to the F5, then run the script.
  • I just uploaded an iControl script that illustrates almost all of the methods in the LocalLB Rule interface. I tested it an it runs find directly on my BIG-IP so you can just save it there an use it. The usage is as follows:

    Usage: LocalLBRule.pl host uid pwd [options]
      [options]
       list             - List all iRules
       backup dirname   - Backup all iRules to specified local directory
       load filename    - Load single iRule from specified filename (iRule name from filename)
       get iRulename    - Display specified iRule
       delete iRulename - Delete specified iRule
       stats iRulename  - Get Statistics for specified iRule

    Here's the link to the CodeShare entry:

    http://devcentral.f5.com/wiki/default.aspx/iControl/PerlLocalLbRule.html

    If you use the "load filename" option it will take the filename (removing the beginning path and removing ".tcl" from the end) and attempt to either create a new iRule (if one doesn't exist with that name) or modify an existing one that's found.

    Hope this helps...

    -Joe

  • Oh, one more thing. If you are running this from the LTM, you can point the script at localhost and it will not require credentials to login for the iControl calls. So you can pass anything to the username/password fields and the script will still work.

     

     

    -Joe

     

  • FYI...Once you get to version 10.1 or greater, you can use tmsh scripting to pull iRules from external files.