Forum Discussion

sundogbrew's avatar
sundogbrew
Icon for Altocumulus rankAltocumulus
Feb 01, 2013

Data groups in config

So I have been doing some research on this for a bit. Have read some good posts by Jason and some other stuff. I am a bit confused on a few things though. Can you call external classes in the config for anything?

 

Here is my situation. I have a list of applications that are migrating to a new application cluster which is frontended by the F5. The way it is setup all 25 nodes of the cluster go into the pool of each application. So each application I add ads something way north of 50 lines to the bigip.conf file (each app has a test version too.) So what I am wondering is can I go into the GUI and create a data group list call it cluster and add all 25 nodes and rather than have a new pool for each application. The application pool would include internal class cluster or whatever I called it and fix that problem. Or can I (even better) create a file with all the config info for one application (virtual host, monitors, pool...) name is something and call it as an external class in the config and then each app would be a file outside the bigip.conf file. If so does anyone do either of these and if so could you send me a little sample of how that code would look. Any other ideas on how to fix this problem would be greatly appreciated. Currently I am either putting it in with the GUI which adding 25 nodes with the GUI is painful. Or I am copying out a piece of config changing it and then pasting it back in. Neither of these is quick or easy for avioding mistakes.

 

Thanks a bunch in advance!

 

Joe

 

8 Replies

  • You cannot call external classes, or data groups in general, as object references in the config.

     

     

    Just curious, but are all of the nodes listening on the same port? If so why not create a single pool and apply to all of the virtual servers.

     

     

    You could potentially automate the creation of each individual pool given a list of nodes. This wouldn't solve the config file size issue, but it would make your life a lot easier. As for storing the entire application in a class for easy reproduction, that too could be automated via TMSH or an iApp.
  • Kevin,

     

    They all technically go to the same port (80) but each application has its own monitor which monitors the tomcat port and bases the nodes in it's application pool by that. So each pool has all 25 hosts in it but based on which host is running a certain tomcat determines which hosts are active in the pool. Each application has it's own virtual server, pool and monitor.

     

    So you say you can't call external classes but then you say you can use TMSH or IApp to create an entire application in a class. I don't understand?

     

    Thanks

     

    Joe

     

  • I should have asked what TMOS version you're running. Version 9.x comes with the BIGPIPE utility for creating objects on the command line. Version 10.x has BIGPIPE and TMSH, and version 11.x only has TMSH.

    Here's a few TMSH and iApp references to get you started:

    TMSH scripting:

    https://devcentral.f5.com/wiki/TMSH.HomePage.ashx

    http://support.f5.com/content/kb/en-us/products/big-ip_ltm/manuals/product/bigip-tmsh-11-3-0/_jcr_content/pdfAttach/download/file.res/bigip-tmsh-11-3-0.pdf

    iApp scripting:

    https://devcentral.f5.com/wiki/iApp.HomePage.ashx

    I won't go into the details of each, but TMSH is the scripting language used to create/modify BIG-IP objects. You can use TMSH directly in the shell or shell scripts (bash), or create TMSH scripts that can be used independently (see https://devcentral.f5.com/wiki/TMSH.PoolStatus.ashx as an example), or include in iApps. An iApp is a "user-customizable framework for deploying applications". Think of it like a GUI wizard for creating applications, that you get to customize.

    Here's a sample of creating an application from the command line using tmsh in a shell script:

    
     create the pool
    tmsh create ltm pool app-pool members replace-all-with { 1.1.1.1:80 1.1.1.2:80 1.1.1.3:80 } monitor http
     create the virtual server
    tmsh create ltm virtual app-vs destination 10.10.10.10:80 pool app-pool source-address-translation { type automap } profiles replace-all-with { http } persist replace-all-with { cookie }
    

    This will build a very simple virtual server and associated pool that you can use in a shell script. In your case most of the information would be "canned" and you'd just need to supply the virtual's destination IP, port, and the pool members.
  • OK, so I took Kevin's advice and created a script that creates a monitor, a pool and a virtual host. Wasn't too bad for a non-scripter like myself! There is a lot of info out there and lots of bits and pieces. Plus using the list command and looking at what you have on your machine now really helps. Now I am going to beat you up with the same question. Can I call a data group form my tmsh script? My create virtual statement is pretty UGLY with 25 nodes in it. Can I put them all in a file and call it somehow?

     

    Please say yes! If not then what the heck is it for?

     

     

    Thanks as always

     

    Joe
  • You certainly can:

    tmsh list ltm data-group

    But if you're creating a shell script, I think it'd be easier to create a text file and parse through this instead:

    
    while read p; do
      echo $p
    done < serverlist.txt
    

  • I know this is ugly but if I have this as part of a script that runs and collects values (app_name comes from an input question,) how would I list that in? Could I run the tmsh list ltm data-group and then somehow assign that to a variable or add that to the below line rather than all the members?

     

     

    tmsh::create ltm pool "PFA-$app_name'_pool'" {members add {172.20.36.161:80 172.20.36.162:80 172.20.36.163:80 172.20.36.164:80 172.20.36.165:80 172.20.36.166:80 172.20.36.167:80 172.20.36.168:80 172.20.36.169:80 172.20.36.170:80 172.20.36.171:80 172.20.36.172:80 172.20.36.173:80 172.20.36.174:80 172.20.36.175:80 172.20.36.176:80 172.20.36.177:80 172.20.36.178:80 172.20.36.179:80 172.20.36.180:80 172.20.36.181:80 172.20.36.182:80 172.20.36.183:80 172.20.36.184:80 172.20.36.185:80}} monitor "PFA-$app_name'-'$tomcat" service-down-action reselect

     

     

    Thanks

     

    Joe
  • Use the above bash script to read in the contents of a text file and format a local variable as "{ IP IP IP IP IP IP IP }". Then use that variable in your TMSH create command.
  • Kevin,

     

    Are you saying write a bash script that calls tmsh to create the pool or add bash to a tmsh script? Can you add this functionality to a tmsh script?

     

    Thanks

     

    Joe