{"id":161,"date":"2026-08-16T09:43:13","date_gmt":"2026-08-16T07:43:13","guid":{"rendered":"https:\/\/pprzybyla.com\/blog\/?p=161"},"modified":"2026-08-16T09:43:14","modified_gmt":"2026-08-16T07:43:14","slug":"fortimanager-cli-vs-jinja-scripts","status":"publish","type":"post","link":"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/","title":{"rendered":"FortiManager CLI vs Jinja scripts"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">It is relatively easy to manage one device via its GUI or CLI. However, managing tens or even hundreds of devices is where efficiency comes into play or falters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">FortiManager offers two main ways of automation in terms of object configuration, interface management, and setting up devices in bulk: Native CLI Scripts and Jinja2 Templates. Although they perform pretty much the same tasks, they differ greatly in terms of their execution, flexibility, and application.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The following text will help you understand when it is better to apply one or another way of management.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Native CLI Scripts<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Native CLI scripts consist of a sequential list of commands using standard FortiOS commands. The execution is done sequentially on FortiManager, just like a network engineer would paste individual commands while working in an SSH session.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Execution Environment:<\/strong> It can execute against the Device Database (the policy package or device configuration that is stored on FortiManager before installation) or directly on the Remote FortiGate via CLI (which bypasses FortiManager&#8217;s policy DB synchronization and modifies the device itself).<\/li>\n\n\n\n<li><strong>Support for Logic:<\/strong> Static. Some limited dynamic support through metadata variables such as $(name) and $(ip).<\/li>\n\n\n\n<li><strong>Error Handling: <\/strong>Sequential. If an error occurs, the script can either abort or proceed based on its global settings, but with limited rollback abilities.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\"><code>config system dns\nset primary 1.1.1.1\nset secondary 8.8.8.8\nend\nconfig system global\nset hostname \"FG-$(name)\"\nend<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Jinja2 Templates<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Jinja2 is an advanced templating engine which is built-in to FortiManager. This engine enables the use of conditionals, loops, variables, and math operations in your definition.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Execution Context:<\/strong> Evaluated dynamically at deployment time with FortiManager metadata, device variables, and CLI template groups.<\/li>\n\n\n\n<li><strong>Logic:<\/strong> Complete programmatic logic (conditional statements such as if\/else statements, for loops, filters like default, ipaddr, etc.)<\/li>\n\n\n\n<li><strong>Error Handling:<\/strong> Evaluated before execution; syntax error in template is detected before execution of the commands on device.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">config system interface\n{% for intf in device_interfaces %}\n    edit \"{{ intf.name }}\"\n        set vdom \"root\"\n        set ip {{ intf.ip }} {{ intf.mask }}\n        {% if intf.allow_ping %}\n        set allowaccess ping\n        {% endif %}\n    next\n{% endfor %}\nend<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Direct Comparison<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><td><strong>Feature \/ Dimension<\/strong><\/td><td><strong>Native CLI Scripts<\/strong><\/td><td><strong>Jinja2 Templates<\/strong><\/td><\/tr><\/thead><tbody><tr><td><strong>Learning Curve<\/strong><\/td><td>Extremely Low (Standard FortiOS CLI)<\/td><td>Moderate (Requires basic programming logic)<\/td><\/tr><tr><td><strong>Logic &amp; Conditionals<\/strong><\/td><td>No (<code>if\/else<\/code> not supported)<\/td><td>Yes (Full <code>if\/elif\/else<\/code> and loop control)<\/td><\/tr><tr><td><strong>Variable Manipulation<\/strong><\/td><td>Basic FortiManager Meta-Variables<\/td><td>Advanced (Filters, string transformations, arithmetic)<\/td><\/tr><tr><td><strong>Code Reusability<\/strong><\/td><td>Low (Requires separate scripts per variant)<\/td><td>High (Single template handles varying site specs)<\/td><\/tr><tr><td><strong>Debugging Complexity<\/strong><\/td><td>Low (Direct CLI output)<\/td><td>Moderate (Need to inspect rendered CLI before deployment)<\/td><\/tr><tr><td><strong>Ideal Scope<\/strong><\/td><td>Quick fixes, one-off changes, simple baselines<\/td><td>Complex multi-site provisioning, SD-WAN, Hub-Spoke networks<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is relatively easy to manage one device via its GUI or CLI. However, managing tens or even hundreds of devices is where efficiency comes into play or falters. FortiManager offers two main ways of automation in terms of object configuration, interface management, and setting up devices in bulk: Native CLI Scripts and Jinja2 Templates.\u2026 <span class=\"read-more\"><a href=\"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-161","post","type-post","status-publish","format-standard","hentry","category-fortigate"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>FortiManager CLI vs Jinja scripts - Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FortiManager CLI vs Jinja scripts - Blog\" \/>\n<meta property=\"og:description\" content=\"It is relatively easy to manage one device via its GUI or CLI. However, managing tens or even hundreds of devices is where efficiency comes into play or falters. FortiManager offers two main ways of automation in terms of object configuration, interface management, and setting up devices in bulk: Native CLI Scripts and Jinja2 Templates.\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-16T07:43:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-08-16T07:43:14+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/fortimanager-cli-vs-jinja-scripts\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/fortimanager-cli-vs-jinja-scripts\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/#\\\/schema\\\/person\\\/78e3f329b514e87d4b8591f2e797b558\"},\"headline\":\"FortiManager CLI vs Jinja scripts\",\"datePublished\":\"2026-08-16T07:43:13+00:00\",\"dateModified\":\"2026-08-16T07:43:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/fortimanager-cli-vs-jinja-scripts\\\/\"},\"wordCount\":383,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/#\\\/schema\\\/person\\\/78e3f329b514e87d4b8591f2e797b558\"},\"articleSection\":[\"Fortigate\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/fortimanager-cli-vs-jinja-scripts\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/fortimanager-cli-vs-jinja-scripts\\\/\",\"url\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/fortimanager-cli-vs-jinja-scripts\\\/\",\"name\":\"FortiManager CLI vs Jinja scripts - Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/#website\"},\"datePublished\":\"2026-08-16T07:43:13+00:00\",\"dateModified\":\"2026-08-16T07:43:14+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/fortimanager-cli-vs-jinja-scripts\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/fortimanager-cli-vs-jinja-scripts\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/fortimanager-cli-vs-jinja-scripts\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FortiManager CLI vs Jinja scripts\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/\",\"name\":\"Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/#\\\/schema\\\/person\\\/78e3f329b514e87d4b8591f2e797b558\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/#\\\/schema\\\/person\\\/78e3f329b514e87d4b8591f2e797b558\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/pprzybyla.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/my-photo-url.jpg\",\"url\":\"http:\\\/\\\/pprzybyla.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/my-photo-url.jpg\",\"contentUrl\":\"http:\\\/\\\/pprzybyla.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/my-photo-url.jpg\",\"width\":800,\"height\":800,\"caption\":\"admin\"},\"logo\":{\"@id\":\"http:\\\/\\\/pprzybyla.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/my-photo-url.jpg\"},\"sameAs\":[\"http:\\\/\\\/pprzybyla.com\\\/blog\"],\"url\":\"https:\\\/\\\/pprzybyla.com\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"FortiManager CLI vs Jinja scripts - Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/","og_locale":"en_US","og_type":"article","og_title":"FortiManager CLI vs Jinja scripts - Blog","og_description":"It is relatively easy to manage one device via its GUI or CLI. However, managing tens or even hundreds of devices is where efficiency comes into play or falters. FortiManager offers two main ways of automation in terms of object configuration, interface management, and setting up devices in bulk: Native CLI Scripts and Jinja2 Templates.\u2026 Read More &raquo;","og_url":"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/","og_site_name":"Blog","article_published_time":"2026-08-16T07:43:13+00:00","article_modified_time":"2026-08-16T07:43:14+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/#article","isPartOf":{"@id":"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/"},"author":{"name":"admin","@id":"https:\/\/pprzybyla.com\/blog\/#\/schema\/person\/78e3f329b514e87d4b8591f2e797b558"},"headline":"FortiManager CLI vs Jinja scripts","datePublished":"2026-08-16T07:43:13+00:00","dateModified":"2026-08-16T07:43:14+00:00","mainEntityOfPage":{"@id":"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/"},"wordCount":383,"commentCount":0,"publisher":{"@id":"https:\/\/pprzybyla.com\/blog\/#\/schema\/person\/78e3f329b514e87d4b8591f2e797b558"},"articleSection":["Fortigate"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/","url":"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/","name":"FortiManager CLI vs Jinja scripts - Blog","isPartOf":{"@id":"https:\/\/pprzybyla.com\/blog\/#website"},"datePublished":"2026-08-16T07:43:13+00:00","dateModified":"2026-08-16T07:43:14+00:00","breadcrumb":{"@id":"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/pprzybyla.com\/blog\/fortimanager-cli-vs-jinja-scripts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pprzybyla.com\/blog\/"},{"@type":"ListItem","position":2,"name":"FortiManager CLI vs Jinja scripts"}]},{"@type":"WebSite","@id":"https:\/\/pprzybyla.com\/blog\/#website","url":"https:\/\/pprzybyla.com\/blog\/","name":"Blog","description":"","publisher":{"@id":"https:\/\/pprzybyla.com\/blog\/#\/schema\/person\/78e3f329b514e87d4b8591f2e797b558"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pprzybyla.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/pprzybyla.com\/blog\/#\/schema\/person\/78e3f329b514e87d4b8591f2e797b558","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/pprzybyla.com\/blog\/wp-content\/uploads\/2025\/02\/my-photo-url.jpg","url":"http:\/\/pprzybyla.com\/blog\/wp-content\/uploads\/2025\/02\/my-photo-url.jpg","contentUrl":"http:\/\/pprzybyla.com\/blog\/wp-content\/uploads\/2025\/02\/my-photo-url.jpg","width":800,"height":800,"caption":"admin"},"logo":{"@id":"http:\/\/pprzybyla.com\/blog\/wp-content\/uploads\/2025\/02\/my-photo-url.jpg"},"sameAs":["http:\/\/pprzybyla.com\/blog"],"url":"https:\/\/pprzybyla.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/pprzybyla.com\/blog\/wp-json\/wp\/v2\/posts\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pprzybyla.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pprzybyla.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pprzybyla.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pprzybyla.com\/blog\/wp-json\/wp\/v2\/comments?post=161"}],"version-history":[{"count":1,"href":"https:\/\/pprzybyla.com\/blog\/wp-json\/wp\/v2\/posts\/161\/revisions"}],"predecessor-version":[{"id":162,"href":"https:\/\/pprzybyla.com\/blog\/wp-json\/wp\/v2\/posts\/161\/revisions\/162"}],"wp:attachment":[{"href":"https:\/\/pprzybyla.com\/blog\/wp-json\/wp\/v2\/media?parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pprzybyla.com\/blog\/wp-json\/wp\/v2\/categories?post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pprzybyla.com\/blog\/wp-json\/wp\/v2\/tags?post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}