Forum Discussion
Add an iRule to multiple virtual servers
I am looking for a script to add/apply an irule to a list of virtual servers, or virtual servers that contain "www" in the name.
Thanks.
19 Replies
- Kevin_Stewart
Employee
Try this Bash script:
!/bin/bash for virtual in `tmsh list /ltm virtual one-line |awk -F" " '{ print $3 }' |grep www`; do tmsh modify /ltm virtual $virtual rules { test-rule } doneIf you do:
grep ^wwwThat'll grab virtual servers that start with www, and if you leave the grep off completely it'll give you all of the virtual servers.
- willsweeper_131
Nimbostratus
Thanks Kevin for the quick response. below is the script that I ran,
!/bin/bashfor virtual in
; do tmsh modify /ltm virtual $virtual rules { Server_Response_Header_Remove } donetmsh list /ltm virtual one-line |awk -F" " '{ print $3 }' |grep VIP_zzzBut the rule didn't apply.
then I check the virtual server, the irule "Server_Response_Header_Remove" was not applied.
I then ran the first half of the command to list all the virtual servers, but it only came back with "requested", see below output.[admin@nyadltm01:Active] ~ tmsh list /ltm virtual one-line |awk -F" " '{ print $3 }'
requestedif I just run "tmsh list /ltm virtual", it came back with all the virutal servers on the ltm, the ltm is running v10.3 please let me know if anything else I can try, thanks. Will
- willsweeper_131
Nimbostratus
sorry for the bad format
- Kevin_Stewart
Employee
I wouldn't have imagined the output was different, but I don't have a v10 in front of me. Can you run the following and post a sample output:
tmsh list /ltm virtual one-line - willsweeper_131
Nimbostratus
[will.dou@nyadltm01:Active] ~ tmsh list /ltm virtual one-line
01020036:3: The requested virtual server (one-line) was not found.
- Kevin_Stewart
Employee
Try this:
tmsh list /ltm virtual |grep "ltm virtual" |awk -F" " '{ print $3 }' - willsweeper_131
Nimbostratus
ran it, but got nothing in return
[will.dou@nyadltm01:Active] ~ tmsh list /ltm virtual |grep "ltm virtual" |awk -F" " '{ print $3 }'
- willsweeper_131
Nimbostratus
have to close the window to come out of the session.
- Kevin_Stewart
Employee
Okay, clearly not having a v10 system in front of me is slowing me down. Can you post a sample from the following command:
tmsh list /ltm virtual - willsweeper_131
Nimbostratus
- willsweeper_131
Nimbostratus
I couldn't get the format right, so I uploaded the image of 1 of the 1700 virtual servers.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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