We have load balancers in two geographically disperse datacenters that are also globally load balanced. It started becoming an inconvenience to add allowed IP addresses to our SMTP relay data group in both datacenters as we spun up additional printers at one of our many sites, so I created this script to use the REST API and update both load balancers with the same configuration simultaneous for this one group. This script is single purpose for me but I figure all anyone really needs to do is edit it for their own use and potentially save themselves some time. DataGroups don't allow a REST delete so I am basically recreating the JSON and overwriting the existing configuration.
How to use this snippet:
When you run it you will be presented with four options.
Add - This will add an individual IP address. It also makes a backup of the current DataGroup configuration in case something goes wrong.
Delete - This will delete an individual IP address. It also makes a backup of the current DataGroup configuration in case something goes wrong.
Backup - This will backup up the existing configuration on both load balancers. These get saved as ArchiveDG-Date and will not be removed unless done manually(I like being able to do a point in time.)
Restore - This will restore a backed up configuration.
After you select the option you wish to use you will be prompted for the credentials to your F5, the username and password has to be the same on both load balancers. I will most likely save an encrypted credential long term, but this works for my needs at the moment. The oldest backups will be cleared after 10 saves have been completed.