cancel
Showing results for 
Search instead for 
Did you mean: 

TMSH CLI to modify objects with keyword variables in them

PeterKrike
Nimbostratus
Nimbostratus

I am curious if there was a way to modify VIPs w/o specifically defining them within the command .. for example :

 

modify ltm virtual Test-Donkey-HTTPS profiles delete { tcp-600 } profiles add { tcp }

modify ltm virtual Prod-Donkey-HTTPS profiles delete { tcp-600 } profiles add { tcp }

modify ltm virtual Stage-Donkey-HTTPS profiles delete { tcp-600 } profiles add { tcp }

 

So above, I would like to replace all "Donkey" VIPs in one shot to adjust their profiles.

 

Thank you!

1 REPLY 1

Hi @Peter Krike​ 

 

The modify command does not accept the wildcard method. The list command does,

tmsh list ltm virtual *-Donkey-HTTPS profiles

But you can still do it this way,

tmsh modify ltm virtual Test-Donkey-HTTPS Prod-Donkey-HTTPS Stage-Donkey-HTTPS profiles delete { tcp-600 } profiles add { tcp }

If the list is huge and you want to do with wildcard, you can do it by passing 1 commands output to another,

 

1st command: You list all virtuals using wildcard and xargs so you have each virtual space separated.

tmsh list ltm virtual *Donkey-HTTPS one-line | awk '{print $3}' | xargs

The output would be,

 

Test-Donkey-HTTPS Prod-Donkey-HTTPS Stage-Donkey-HTTPS

 

Then you use your modify command on this, so the final command would be,

tmsh modify ltm virtual `tmsh list ltm virtual *Donkey-HTTPS one-line | awk '{print $3}' | xargs` profiles delete { tcp-600 } profiles add { tcp }

Note: Be mindful on how you form your regex, do list the virtuals first and then run the modify command while using wildcard.

 

Hope this helps.