Automating iRules creation process

November 29, 2016 marlonfrank No comments exist

if you are like me that likes to script and automate some of your configuration steps here is the summary on how to do so under version 12. Initially F5 used to have a b command available for the iRules creation which was never replaced with a TMOS equivalent.
This is the old creation method using b commands
b shell write partition Common
b rule fn89dev_rootlogin_ssl ‘{
when HTTP_REQUEST {
if {[HTTP::uri] == “” || [HTTP::uri] == “/”} {
HTTP::redirect “https://[HTTP::host]/fn89dev/signon.html”
}
else {
HTTP::header insert WL-Proxy-Client-IP [getfield [IP::client_addr] “%” 1]
}
}
}’

This is the new creation method using Unix shell scripts

echo writing irule to /var/tmp/irule.$$
cat << EOF > /var/tmp/irule.$$
ltm rule /BoQ/fn89dev_rootlogin_ssl {
when HTTP_REQUEST {
if {[HTTP::uri] == “” || [HTTP::uri] == “/”} {
HTTP::redirect “https://[HTTP::host]/fn89dev/signon.html”
}
else {
HTTP::header insert WL-Proxy-Client-IP [getfield [IP::client_addr] “%” 1]
}
}
}
EOF
echo merge irule in /var/tmp/irule.$$ to config
tmsh load sys config file /var/tmp/irule.$$ merge
echo deleting temp file /var/tmp/irule.$$
rm -f /var/tmp/irule.$$
echo done

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.