{"id":6333,"date":"2020-07-11T13:54:26","date_gmt":"2020-07-11T19:54:26","guid":{"rendered":"http:\/\/gregsowell.com\/?p=6333"},"modified":"2020-07-11T13:57:37","modified_gmt":"2020-07-11T19:57:37","slug":"ansible-terminal-expansion-with-mikrotik","status":"publish","type":"post","link":"https:\/\/gregsowell.com\/?p=6333","title":{"rendered":"Ansible Terminal Expansion With Mikrotik"},"content":{"rendered":"<p>Mikrotik routers are, I&#8217;m finding, well suited to be used with Ansible as infrastructure as code.<\/p>\n<p>I was recently working on a project where I was pulling &#8220;\/ip firewall nat print without-paging terse&#8221;, but the returned output kept adding in \\n (carriage returns) on the 81st position&#8230;*sigh*.  <\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">&quot;stdout&quot;: [\r\n            &quot;0    comment=ReverseNAT chain=srcnat action=src-nat to-addresses=2.1.\\n25.64 src-address=1.1.1.1 \\n 1    comment=Mail_Reverse_NAT chain=srcnat action=src-nat to-addresses=1.1.1\\n25.64 src-address=1.1.2.25 \\n 2 X  comment=VPN_Traffic chain=srcnat action=masquerade src-address=1.1.9.0\/24 \\ndst-address=1.1.2.0\/24 \\n 3    comment=VPN_Traffic chain=srcnat action=masquerade src-address=10.1.9.0\/24 \\n\\n 4  <\/code><\/pre>\n<p>It turns out that when connected via ssh, Mikrotik assumes a smaller window size on the terminal.  The trick here is to edit the username used to connect with a special set of instructions:<\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">ansible_user=Tacos+cet512w<\/code><\/pre>\n<p>+cet512w tells ansible the default terminal width is equal to 512 cols and enables &#8220;dumb&#8221; terminal mode.  After this, all is right with the world \ud83d\ude42<\/p>\n<p>It took me about 2 hours to suss this out, then when I presented it to Jimmy he said &#8220;Oh yeah, that&#8217;s why I&#8217;ve got &#8220;+cet512w&#8221; in the user name, so really he gave me the fix.  Another lesson hard earned hehehe.<\/p>\n<p>If you are using ansible with Mikrotik and the routeros module is inserting carriage returns, give this a go.  Oh, it also helps to have an Ansible Ninja on your team when you need a little help \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mikrotik routers are, I&#8217;m finding, well suited to be used with Ansible as infrastructure as code. I was recently working on a project where\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49,6],"tags":[],"class_list":["post-6333","post","type-post","status-publish","format-standard","hentry","category-ansible","category-mikrotik"],"_links":{"self":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/6333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6333"}],"version-history":[{"count":2,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/6333\/revisions"}],"predecessor-version":[{"id":6335,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/6333\/revisions\/6335"}],"wp:attachment":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}