{"id":568,"date":"2020-05-06T19:20:13","date_gmt":"2020-05-06T12:20:13","guid":{"rendered":"http:\/\/geeksops.com\/?p=568"},"modified":"2020-11-05T06:44:13","modified_gmt":"2020-11-04T23:44:13","slug":"how-to-enable-change-configuration-notification-on-oxidized","status":"publish","type":"post","link":"https:\/\/rotreein.com\/?p=568","title":{"rendered":"How to enable Change Configuration Notification on Oxidized"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p><strong>Goal<\/strong> : We have diff config notification if there are config changes on network devices<\/p>\n\n\n\n<p>Requirements:<\/p>\n\n\n\n<ul><li>msmtp<\/li><li>msmtp-mta<\/li><li>ansi2html<\/li><li><a href=\"https:\/\/github.com\/ytti\/oxidized\/blob\/master\/extra\/oxidized-report-git-commits\">oxidized script<\/a><\/li><\/ul>\n\n\n\n<p>Package Installation<\/p>\n\n\n\n<p class=\"has-text-color has-background has-small-font-size has-very-light-gray-color has-very-dark-gray-background-color\">pip install ansi2html<\/p>\n\n\n\n<p class=\"has-text-color has-background has-small-font-size has-very-light-gray-color has-very-dark-gray-background-color\">apt-get install colordiff msmtp msmtp-mta -y<\/p>\n\n\n\n<p>Put the script below, it will automatically create <strong>oxidized-report-git-commits<\/strong> in folder \/opt\/oxidized<\/p>\n\n\n\n<pre data-mode=\"plain_text\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" class=\"wp-block-simple-code-block-ace\">cat &lt;&lt;'EOF' > \/opt\/oxidized\/oxidized-report-git-commits\n#!\/bin\/sh\n\necho \"Node name: ${OX_NODE_NAME}\"\necho \"Group name: ${OX_NODE_GROUP}\"\necho \"Job status: ${OX_JOB_STATUS}\"\necho \"Job time: ${OX_JOB_TIME}\"\n\nif [ \"${OX_EVENT}\" = \"node_fail\" ]; then\n    echo 'Job failed'\n    exit 64\nfi\n\nif [ -z \"${OX_REPO_COMMITREF}\" ]; then\n\techo '$OX_REPO_COMMITREF not set'\n\texit 64\nfi\n\nif [ -z \"${OX_REPO_NAME}\" ]; then\n\techo '$OX_REPO_NAME not set'\n\texit 64\nfi\n\t\necho \"Git repo: ${OX_REPO_NAME}\"\necho \"Git commit ID: ${OX_REPO_COMMITREF}\"\necho \"\"\n\ngit --bare --git-dir=\"${OX_REPO_NAME}\" show --pretty='' --no-color \"${OX_REPO_COMMITREF}\"\nEOF<\/pre>\n\n\n\n<p>chmod +x \/opt\/oxidized\/oxidized-report-git-commits<\/p>\n\n\n\n<pre data-mode=\"plain_text\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" class=\"wp-block-simple-code-block-ace\">cat &lt;&lt;EOF > \/etc\/msmtprc\n# Set default values for all following accounts.\ndefaults\nauth on\ntls on\ntls_trust_file \/etc\/ssl\/certs\/ca-certificates.crt\nlogfile ~\/.msmtp.log\n# Gmail\naccount gmail\nhost smtp.gmail.com\nport 587\nfrom geeksopslab@gmail.com\nuser geeksopslab@gmail.com\npassword HIDDENPASSWORD!!\n\n# Set a default account\naccount default : gmail\nEOF<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>The part of configuration which will send via email if there are change configuration on network devices. Edit file in<strong> \/opt\/oxidized\/.config\/oxidized\/config<\/strong> and put the configuration below<\/p>\n\n\n\n<pre data-mode=\"plain_text\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" class=\"wp-block-simple-code-block-ace\">hooks:\n email_output:\n   type: exec\n   events: [post_store]\n   cmd: 'echo \"From:Oxidized\\nTo:geeksopslab@gmail.com\\nSubject: Production Network - Config diff ${OX_NODE_NAME}\\nMIME-Version: 1.0\\nContent-Type: text\/html; charset=utf-8\\n\\n\" > \/tmp\/${OX_NODE_NAME}; bash \/opt\/oxidized\/oxidized-report-git-commits | tr -d \\\\r | colordiff | ansi2html >> \/tmp\/${OX_NODE_NAME}; msmtp rohmat.trie@gmail.com&lt; \/tmp\/${OX_NODE_NAME}; rm \/tmp\/${OX_NODE_NAME}'\n   async: true\n   timeout: 120<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Sample output<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"626\" height=\"589\" src=\"https:\/\/geeksops.com\/wp-content\/uploads\/2020\/10\/image-1.png\" alt=\"\" class=\"wp-image-597\" srcset=\"https:\/\/rotreein.com\/wp-content\/uploads\/2020\/10\/image-1.png 626w, https:\/\/rotreein.com\/wp-content\/uploads\/2020\/10\/image-1-300x282.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Goal : We have diff config notification if there are config changes on network devices Requirements: msmtp msmtp-mta ansi2html oxidized script Package Installation pip install ansi2html apt-get install colordiff msmtp msmtp-mta -y Put the script below, it will automatically create oxidized-report-git-commits in folder \/opt\/oxidized chmod +x \/opt\/oxidized\/oxidized-report-git-commits The part of configuration which will send via&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":[],"_links":{"self":[{"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/posts\/568"}],"collection":[{"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rotreein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=568"}],"version-history":[{"count":29,"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/posts\/568\/revisions"}],"predecessor-version":[{"id":610,"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/posts\/568\/revisions\/610"}],"wp:attachment":[{"href":"https:\/\/rotreein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rotreein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rotreein.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}