Forum Discussion
create IRule in tmsh
I am trying to create an IRule from the command line in tmsh and running into errors that I am not sure how to correct.
I know there are other tools out there such as IControl that can be used but at this time we are doing configurations from the tmsh shell and I will investigate the other options later.
Using LTM Version 11.2 and trying to create the IRule I do the following from the tmsh prompt:
create ltm rule /Common/my_rule_rule { when HTTP_REQUEST { if { [class match [HTTP::uri] contains this_uri] } { pool my_test_pool_1 } else { pool my_test_pool_2 }}}
I get the following error:
Syntax Error: Unexpected {
I have tried removing some of the { but still having an issue.
I noticed that if I typed create ltm rule /Common/my_rule_rule that it takes me into an editor mode to apparently apply the rule. Is there a way to create the rule without having to go into the editor mode?
- hooleylistCirrostratusHi Wally,
- naladar_65658AltostratusThis compiles for me just fine
- naladar_65658AltostratusHey Hoolio,
- hooleylistCirrostratusHey Naladar, the 'tmsh create ltm rule rule_name' option was added in 11.0. In 10.x you could do the same using 'tmsh edit ltm rule rule_name'.
- Wally_Steadman_NimbostratusHow I have resolved the issue is by using the “Load sys config from-terminal merge” command and pasting the config in and then committing with CTRL-D
- MVANimbostratus
Wally, this loads for me on 11.4.1 HF3
tmsh create ltm rule /Common/my_rule_rule when HTTP_REQUEST { if { [class match [HTTP::uri] contains this_uri] } { pool my_test_pool_1 } else { pool my_test_pool_2 }}
Removed the "{" between rule name and when statement and corresponding "}" at the end.
Couple other notes: - Double quotes require backslash delimiter, i.e., if { [HTTP::host] starts_with \"myhost\"} - Linefeeds require backslash delimiter, if using LF for clarity, i.e., tmsh create /ltm rule test_rule \ when HTTP_REQUEST {\ if { [HTTP::host] starts_with \"myhost\" } } else {\ discard\ }\ }
We use scripts for change control and create (most)everything at the console. Hope this helps.
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