{"id":16,"date":"2021-08-20T23:00:18","date_gmt":"2021-08-20T23:00:18","guid":{"rendered":"http:\/\/vn.aalmekbel.com:8080\/?p=16"},"modified":"2023-08-06T13:15:01","modified_gmt":"2023-08-06T10:15:01","slug":"automating-your-datacenter-network-nxos-with-ansible","status":"publish","type":"post","link":"https:\/\/aalmekbel.com\/index.php\/2021\/08\/20\/automating-your-datacenter-network-nxos-with-ansible\/","title":{"rendered":"Automating your Datacenter Network (NXOS) with Ansible"},"content":{"rendered":"\n<p>As a Datacenter Networking Expert, I felt that I need to always  perform a network health check every morning as I take my morning coffee to ensure that my infrastructure is working properly.<\/p>\n\n\n\n<p>I was doing my datacenter network health check manually, then I tried to employee my ansible skills to automate my network health check.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Here are the requirements:<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Linux OS  preferer Centos ( it can be VM or bare-metal or PC ).<\/li>\n\n\n\n<li>That is it !<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step-1: Install Ansible (Linux Centos 7)<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum update<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install ansible<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step-2: Setup your inventory (Switches)<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>nano \/etc\/ansible\/hosts<\/code><\/pre>\n\n\n\n<p>in bellow example my host group &#8220;DC-SW&#8221; and &#8220;dc-sw1\/2&#8221; are my switches hostname.<\/p>\n\n\n\n<p>Note: to exit nano editor and save press ctlr + &#8216;x&#8217; then &#8216;y&#8217;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"561\" height=\"338\" src=\"http:\/\/vn.aalmekbel.com:8080\/wp-content\/uploads\/2021\/08\/Capture.jpg\" alt=\"\" class=\"wp-image-21\" srcset=\"https:\/\/aalmekbel.com\/wp-content\/uploads\/2021\/08\/Capture.jpg 561w, https:\/\/aalmekbel.com\/wp-content\/uploads\/2021\/08\/Capture-300x181.jpg 300w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step-3: Create your playbook<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>nano playbook.yml<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>---\n\n- name: CORE SWITCHES\n  hosts: DC-SW\n  gather_facts: false\n  connection: network_cli\n\n  tasks:\n    - name: health check\n      ios_command: \n        commands: \n          - show  int stat down\n          - show int des | include \"Interface description\"\n          - show cdp nei\n          - show lldp nei\n          - show ver | i system\n          - show ver | i kick\n      register: results\n    \n    - name: print results\n      debug:\n        var: down.stdout_lines\n\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step-4: Run your Playbook<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>ansible-playbook -i inventory playbook.yml &lt;-(your playbook name.yml) --ask-pass --user (your user)<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a Datacenter Networking Expert, I felt that I need to always perform a network health check every morning as I take my morning coffee to ensure that my infrastructure is working properly. I was doing my datacenter network health check manually, then I tried to employee my ansible skills to automate my network health [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-16","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/aalmekbel.com\/index.php\/wp-json\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aalmekbel.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aalmekbel.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aalmekbel.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aalmekbel.com\/index.php\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":13,"href":"https:\/\/aalmekbel.com\/index.php\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"predecessor-version":[{"id":299,"href":"https:\/\/aalmekbel.com\/index.php\/wp-json\/wp\/v2\/posts\/16\/revisions\/299"}],"wp:attachment":[{"href":"https:\/\/aalmekbel.com\/index.php\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aalmekbel.com\/index.php\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aalmekbel.com\/index.php\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}