{"id":296471,"date":"2019-12-27T09:00:07","date_gmt":"2019-12-27T09:00:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296471"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296471","title":{"rendered":"\u0410\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438 \u0437\u0430\u043b\u0438\u0432\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Nornir"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/482194\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7z\/bp\/zt\/7zbpztvjkn5yfvxwcxudhj7hrja.png\"><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0425\u0430\u0431\u0440!<br \/>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0441\u043a\u043e\u0447\u0438\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044f <a href=\"http:\/\/https:\/\/habr.com\/en\/post\/480404\/\" rel=\"nofollow\">Mikrotik \u0438 Linux. \u0420\u0443\u0442\u0438\u043d\u0430 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f<\/a> \u0433\u0434\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0440\u0435\u0448\u0430\u043b\u0438 \u0438\u0441\u043a\u043e\u043f\u0430\u0435\u043c\u044b\u043c\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438. \u0418 \u0445\u043e\u0442\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0442\u0438\u043f\u043e\u0432\u0430\u044f, \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043f\u0440\u043e \u043d\u0435\u0435 \u043a\u0430\u043a \u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f. \u041e\u0441\u043c\u0435\u043b\u044e\u0441\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u043c\u0443 \u0418\u0422-\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u0441\u0432\u043e\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434. <\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u042d\u0442\u043e \u043d\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u0434\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0431\u044b\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u0435\u0449\u0435 \u043d\u0430 <em>ansible<\/em> \u0432\u0435\u0440\u0441\u0438\u0438 1.x.\u0445. \u0412\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0440\u0435\u0434\u043a\u043e \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0440\u0436\u0430\u0432\u0435\u043b. \u0412 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435, \u0447\u0442\u043e \u0441\u0430\u043c\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043a\u0430\u043a \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0435\u0440\u0441\u0438\u0438 <em>ansible<\/em>. \u0418 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0435\u0445\u0430\u0442\u044c, \u0442\u043e \u0446\u0435\u043f\u044c \u0441\u043f\u0430\u0434\u0435\u0442, \u0442\u043e \u043a\u043e\u043b\u0435\u0441\u043e \u043e\u0442\u0432\u0430\u043b\u0438\u0442\u0441\u044f. \u0412\u043f\u0440\u043e\u0447\u0435\u043c \u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c, \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432 \u2014 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0430\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0447\u0435\u043d\u044c \u0447\u0435\u0442\u043a\u043e, \u0431\u043b\u0430\u0433\u043e <em>jinja2<\/em> \u0434\u0432\u0438\u0436\u043e\u043a \u0434\u0430\u0432\u043d\u043e \u0443\u0441\u0442\u043e\u044f\u0432\u0448\u0438\u0439\u0441\u044f. \u0410 \u0432\u043e\u0442 \u0432\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2014 \u0440\u0430\u0441\u043a\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0435\u043f\u043e\u0434\u043d\u043e\u0441\u0438\u043b\u0430 \u0441\u044e\u0440\u043f\u0440\u0438\u0437\u044b. \u0410 \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0441\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433 \u043c\u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e \u043d\u0430 \u043f\u043e\u043b \u0441\u043e\u0442\u043d\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0442\u044b\u0441\u044f\u0447\u0430\u0445 \u043a\u0438\u043b\u043e\u043c\u0435\u0442\u0440\u043e\u0432, \u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0431\u044b\u043b\u043e \u0441\u043b\u0435\u0433\u043a\u0430 \u0441\u0441\u044b\u043a\u043e\u0442\u043d\u043e.<br \/>  \u0422\u0443\u0442 \u043d\u0430\u0434\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u044f \u043d\u0435\u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0441\u043a\u043e\u0440\u0435\u0439 \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0435 \u043c\u0435\u043d\u044f \u0441 <em>ansible<\/em>, \u0447\u0435\u043c \u0432 \u0435\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u0445. \u0418 \u0432\u043e\u0442 \u044d\u0442\u043e, \u043a\u0441\u0442\u0430\u0442\u0438, \u0432\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. <em>ansible<\/em> \u2014 \u044d\u0442\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f, \u0441\u0432\u043e\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u0439 \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c DSL (Domain Specific Language), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435. \u041d\u0443 \u0438 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u0447\u0442\u043e <em>ansible<\/em> \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u0440\u0438\u0447\u0435\u043c \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u043e\u0439 \u043e\u0433\u043b\u044f\u0434\u043a\u0438 \u043d\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c, \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u0431\u044b\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u0430. \u041d\u0430 \u044d\u0442\u043e \u0440\u0430\u0437 \u043d\u0430 <em>python<\/em>, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u043d\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c \u043d\u0430 <em>python<\/em> \u0438 \u0434\u043b\u044f <em>python<\/em> \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/nornir.readthedocs.io\/\" rel=\"nofollow\">Nornir<\/a><\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a \u2014 <em>Nornir<\/em> \u044d\u0442\u043e \u043c\u0438\u043a\u0440\u043e\u0444\u0440\u0435\u0439\u043c\u043e\u043a, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 <em>python<\/em> \u0438 \u0434\u043b\u044f <em>python<\/em> \u0438 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <em>ansible<\/em>, \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0437\u0434\u0435\u0441\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u0430\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442.\u0435. \u0438\u043d\u0432\u0435\u043d\u0442\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u043e\u0441\u0442\u043e\u0432 \u0438 \u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0430 \u0432\u043e\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u043d\u0435 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c DSL, \u0430 \u0432\u0441\u0435 \u043d\u0430 \u0442\u043e\u043c \u0436\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0430\u0440\u043e\u043c, \u043d\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0434\u043e\u0431\u0440\u043e\u043c \u043f[\u0438|\u0430\u0439]\u0442\u043e\u043d\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u043e\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0436\u0438\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<br \/>  \u0415\u0441\u0442\u044c \u0443 \u043c\u0435\u043d\u044f \u0444\u0438\u043b\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u0442\u044c \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0434\u0435\u0441\u044f\u0442\u043a\u0430\u043c\u0438 \u043e\u0444\u0438\u0441\u043e\u0432 \u043f\u043e \u0432\u0441\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0435. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0444\u0438\u0441\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 WAN-\u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0441\u0432\u044f\u0437\u0438 \u043e\u0442 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432. \u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 BGP. WAN-\u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u0431\u044b\u0432\u0430\u044e\u0442 \u0434\u0432\u0443\u0445 \u0442\u0438\u043f\u043e\u0432: Cisco ISG \u0438\u043b\u0438 Juniper SRX.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0434\u0430\u0447\u0430: \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0432\u0441\u0435\u0445 WAN-\u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440\u0430\u0445 \u0444\u0438\u043b\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0434\u0441\u0435\u0442\u044c \u0434\u043b\u044f \u0412\u0438\u0434\u0435\u043e\u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u0442\u0443 \u2014 \u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u043e\u0434\u0441\u0435\u0442\u044c \u0432 BGP \u2014 \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430.<\/p>\n<p>  <\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u043e Cisco \u0438 Juniper. \u0410 \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442.\u0435. \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u043e \u0441\u0430\u043c\u043e\u0435 inventory<\/p>\n<p>  <\/p>\n<p>\u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f Cisco:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ cat templates\/ios\/base.j2  class-map match-all VIDEO_SURV  match access-group 111  policy-map VIDEO_SURV  class VIDEO_SURV     police 1500000 conform-action transmit  exceed-action drop  interface {{ host.task_data.ifname }}   description VIDEOSURV   ip address 10.10.{{ host.task_data.ipsuffix }}.254 255.255.255.0   service-policy input VIDEO_SURV  router bgp {{ host.task_data.asn }}   network 10.40.{{ host.task_data.ipsuffix }}.0 mask 255.255.255.0  access-list 11 permit 10.10.{{ host.task_data.ipsuffix }}.0 0.0.0.255 access-list 111 permit ip 10.10.{{ host.task_data.ipsuffix }}.0 0.0.0.255 any<\/code><\/pre>\n<p>  <\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f Juniper:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ cat templates\/junos\/base.j2  set interfaces {{ host.task_data.ifname }} unit 0 description \"Video surveillance\" set interfaces {{ host.task_data.ifname }} unit 0 family inet filter input limit-in set interfaces {{ host.task_data.ifname }} unit 0 family inet address 10.10.{{ host.task_data.ipsuffix }}.254\/24 set policy-options policy-statement export2bgp term 1 from route-filter 10.10.{{ host.task_data.ipsuffix }}.0\/24 exact set security zones security-zone WAN interfaces {{ host.task_data.ifname }} set firewall policer policer-1m if-exceeding bandwidth-limit 1m set firewall policer policer-1m if-exceeding burst-size-limit 187k set firewall policer policer-1m then discard set firewall policer policer-1.5m if-exceeding bandwidth-limit 1500000 set firewall policer policer-1.5m if-exceeding burst-size-limit 280k set firewall policer policer-1.5m then discard set firewall filter limit-in term 1 then policer policer-1.5m set firewall filter limit-in term 1 then count limiter<\/code><\/pre>\n<p>  <\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d\u044b, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u043d\u0435 \u0441 \u043f\u043e\u0442\u043e\u043b\u043a\u0430. \u042d\u0442\u043e \u043f\u043e \u0441\u0443\u0442\u0438 diff-\u044b \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0431\u043e\u0447\u0438\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0431\u044b\u043b\u043e-\u0441\u0442\u0430\u043b\u043e \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u0434\u0432\u0443\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440\u0430\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u0418\u0437 \u043d\u0430\u0448\u0438\u0445 \u0448\u0430\u0431\u043e\u043d\u043e\u0432 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u0432\u0443\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043b\u044f Juniper \u0438 3 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0434\u043b\u044f Cisco. \u0432\u043e\u0442 \u043e\u043d\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>ifname<\/li>\n<li>ipsuffix<\/li>\n<li>asn<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0442.\u0435. \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e \u0441\u0430\u043c\u043e\u0435 <em>inventory<\/em>.<br \/>  \u0414\u043b\u044f <em>inventory<\/em> \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0442\u043a\u043e \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/nornir.readthedocs.io\/en\/latest\/tutorials\/intro\/initializing_nornir.html\" rel=\"nofollow\">Initializing Nornir<\/a> <\/p>\n<p>  <\/p>\n<p>\u0442.\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0441\u043a\u0435\u043b\u0435\u0442: <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">. \u251c\u2500\u2500 config.yaml \u251c\u2500\u2500 inventory \u2502   \u251c\u2500\u2500 defaults.yaml \u2502   \u251c\u2500\u2500 groups.yaml \u2502   \u2514\u2500\u2500 hosts.yaml<\/code><\/pre>\n<p>  <\/p>\n<p>\u0424\u0430\u0439\u043b config.yaml \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 nornir<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$ cat config.yaml  --- core:     num_workers: 10  inventory:     plugin: nornir.plugins.inventory.simple.SimpleInventory     options:         host_file: \"inventory\/hosts.yaml\"         group_file: \"inventory\/groups.yaml\"         defaults_file: \"inventory\/defaults.yaml\"<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0431\u0443\u0434\u0435\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 <em>hosts.yaml<\/em>, \u0433\u0440\u0443\u043f\u043f\u043e\u0432\u044b\u0435 (\u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043b\u043e\u0433\u0438\u043d\u044b\/\u043f\u0430\u0440\u043e\u043b\u0438) \u0432 <em>groups.yaml<\/em>, \u0430 \u0432 <em>defaults.yaml<\/em> \u043d\u0438\u0447\u0435\u0433\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u043d\u043e \u0442\u0443\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0440\u0438 \u043c\u0438\u043d\u0443\u0441\u0430 \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435, \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u044d\u0442\u043e <em>yaml<\/em> \u0444\u0430\u0439\u043b \u0445\u043e\u0442\u044c \u0438 \u043f\u0443\u0441\u0442\u043e\u0439. <\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 hosts.yaml:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">--- srx-test:     hostname: srx-test     groups:          - juniper     data:         task_data:             ifname: fe-0\/0\/2             ipsuffix: 111  cisco-test:     hostname: cisco-test     groups:          - cisco     data:         task_data:             ifname: GigabitEthernet0\/1\/1             ipsuffix: 222             asn: 65111<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u0432\u043e\u0442 \u0442\u0430\u043a groups.yaml:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">--- cisco:     platform: ios     username: admin1     password: cisco1  juniper:     platform: junos     username: admin2     password: juniper2<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u043b\u0443\u0438\u043b\u043e\u0441\u044c <em>inventory<\/em> \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0437 inventory-\u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u0430\u043f\u044f\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c <strong>InventoryElement<\/strong>. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c \u0441\u0445\u0435\u043c\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 InventoryElement<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"json\">print(json.dumps(InventoryElement.schema(), indent=4)) {     \"title\": \"InventoryElement\",     \"type\": \"object\",     \"properties\": {         \"hostname\": {             \"title\": \"Hostname\",             \"type\": \"string\"         },         \"port\": {             \"title\": \"Port\",             \"type\": \"integer\"         },         \"username\": {             \"title\": \"Username\",             \"type\": \"string\"         },         \"password\": {             \"title\": \"Password\",             \"type\": \"string\"         },         \"platform\": {             \"title\": \"Platform\",             \"type\": \"string\"         },         \"groups\": {             \"title\": \"Groups\",             \"default\": [],             \"type\": \"array\",             \"items\": {                 \"type\": \"string\"             }         },         \"data\": {             \"title\": \"Data\",             \"default\": {},             \"type\": \"object\"         },         \"connection_options\": {             \"title\": \"Connection_Options\",             \"default\": {},             \"type\": \"object\",             \"additionalProperties\": {                 \"$ref\": \"#\/definitions\/ConnectionOptions\"             }         }     },     \"definitions\": {         \"ConnectionOptions\": {             \"title\": \"ConnectionOptions\",             \"type\": \"object\",             \"properties\": {                 \"hostname\": {                     \"title\": \"Hostname\",                     \"type\": \"string\"                 },                 \"port\": {                     \"title\": \"Port\",                     \"type\": \"integer\"                 },                 \"username\": {                     \"title\": \"Username\",                     \"type\": \"string\"                 },                 \"password\": {                     \"title\": \"Password\",                     \"type\": \"string\"                 },                 \"platform\": {                     \"title\": \"Platform\",                     \"type\": \"string\"                 },                 \"extras\": {                     \"title\": \"Extras\",                     \"type\": \"object\"                 }             }         }     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0439, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043d\u0430\u0447\u0430\u043b\u0443. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u0432 <strong>ipython<\/strong>. <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"> $ ipython3 Python 3.6.9 (default, Nov  7 2019, 10:44:02)  Type 'copyright', 'credits' or 'license' for more information IPython 7.1.1 -- An enhanced Interactive Python. Type '?' for help.  In [1]: from nornir import InitNornir                                                                             In [2]: nr = InitNornir(config_file=\"config.yaml\", dry_run=True)                                                  In [3]: nr.inventory.hosts                                                                                       Out[3]:  {'srx-test': Host: srx-test, 'cisco-test': Host: cisco-test}  In [4]: nr.inventory.hosts['srx-test'].data                                                                                     Out[4]: {'task_data': {'ifname': 'fe-0\/0\/2', 'ipsuffix': 111}}  In [5]: nr.inventory.hosts['srx-test']['task_data']                                                      Out[5]: {'ifname': 'fe-0\/0\/2', 'ipsuffix': 111}  In [6]: nr.inventory.hosts['srx-test'].platform                                                                                 Out[6]: 'junos' <\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0443 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0443. \u0422\u0443\u0442 \u043c\u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0433\u043e\u0440\u0434\u0438\u0442\u044c\u0441\u044f \u043d\u0435\u0447\u0435\u043c. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u043b \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 <a href=\"https:\/\/nornir.readthedocs.io\/en\/latest\/tutorials\/intro\/grouping_tasks.html\" rel=\"nofollow\">\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430<\/a> \u0438 \u043f\u043e\u0447\u0442\u0438 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b. \u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from nornir import InitNornir from nornir.plugins.tasks import networking, text from nornir.plugins.functions.text import print_title, print_result  def config_and_deploy(task):     # Transform inventory data to configuration via a template file     r = task.run(task=text.template_file,                  name=\"Base Configuration\",                  template=\"base.j2\",                  path=f\"templates\/{task.host.platform}\")      # Save the compiled configuration into a host variable     task.host[\"config\"] = r.result      # Save the compiled configuration into a file     with open(f\"configs\/{task.host.hostname}\", \"w\") as f:         f.write(r.result)      # Deploy that configuration to the device using NAPALM     task.run(task=networking.napalm_configure,              name=\"Loading Configuration on the device\",              replace=False,              configuration=task.host[\"config\"])  nr = InitNornir(config_file=\"config.yaml\", dry_run=True) # set dry_run=False, cross your fingers and run again  # run tasks result = nr.run(task=config_and_deploy) print_result(result)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>dry_run=True<\/em> \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <strong>nr<\/strong>.<br \/>  \u0422\u0443\u0442 \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 <em>ansible<\/em> \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043e\u043d \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c, \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0442\u0435\u043c \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c (\u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u0447\u043d\u043e; \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0432 NAPALM), \u043d\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u0414\u043b\u044f \u0431\u043e\u0435\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>dry_run<\/em> \u043b\u0438\u0431\u043e \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 <em>False<\/em>. <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f Nornir \u0432\u044b\u0434\u0430\u0435\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u043b\u043e\u0433\u0438. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c \u0432\u044b\u0432\u043e\u0434 \u0431\u043e\u0435\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u043d\u0430 \u0434\u0432\u0443\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043c\u0430\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440\u0430\u0445:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">config_and_deploy*************************************************************** * cisco-test ** changed : True ******************************************* vvvv config_and_deploy ** changed : True vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- Base Configuration ** changed : True ------------------------------------- INFO class-map match-all VIDEO_SURV  match access-group 111  policy-map VIDEO_SURV  class VIDEO_SURV     police 1500000 conform-action transmit  exceed-action drop  interface GigabitEthernet0\/1\/1   description VIDEOSURV   ip address 10.10.222.254 255.255.255.0   service-policy input VIDEO_SURV  router bgp 65001   network 10.10.222.0 mask 255.255.255.0  access-list 11 permit 10.10.222.0 0.0.0.255 access-list 111 permit ip 10.10.222.0 0.0.0.255 any ---- Loading Configuration on the device ** changed : True --------------------- INFO +class-map match-all VIDEO_SURV + match access-group 111 +policy-map VIDEO_SURV + class VIDEO_SURV +interface GigabitEthernet0\/1\/1 +  description VIDEOSURV +  ip address 10.10.222.254 255.255.255.0 +  service-policy input VIDEO_SURV +router bgp 65001 +  network 10.10.222.0 mask 255.255.255.0 +access-list 11 permit 10.10.222.0 0.0.0.255 +access-list 111 permit ip 10.10.222.0 0.0.0.255 any ^^^^ END config_and_deploy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * srx-test ** changed : True ******************************************* vvvv config_and_deploy ** changed : True vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- Base Configuration ** changed : True ------------------------------------- INFO set interfaces fe-0\/0\/2 unit 0 description \"Video surveillance\" set interfaces fe-0\/0\/2 unit 0 family inet filter input limit-in set interfaces fe-0\/0\/2 unit 0 family inet address 10.10.111.254\/24 set policy-options policy-statement export2bgp term 1 from route-filter 10.10.111.0\/24 exact set security zones security-zone WAN interfaces fe-0\/0\/2 set firewall policer policer-1m if-exceeding bandwidth-limit 1m set firewall policer policer-1m if-exceeding burst-size-limit 187k set firewall policer policer-1m then discard set firewall policer policer-1.5m if-exceeding bandwidth-limit 1500000 set firewall policer policer-1.5m if-exceeding burst-size-limit 280k set firewall policer policer-1.5m then discard set firewall filter limit-in term 1 then policer policer-1.5m set firewall filter limit-in term 1 then count limiter ---- Loading Configuration on the device ** changed : True --------------------- INFO [edit interfaces] +   fe-0\/0\/2 { +       unit 0 { +           description \"Video surveillance\"; +           family inet { +               filter { +                   input limit-in; +               } +               address 10.10.111.254\/24; +           } +       } +   } [edit] +  policy-options { +      policy-statement export2bgp { +          term 1 { +              from { +                  route-filter 10.10.111.0\/24 exact; +              } +          } +      } +  } [edit security zones]      security-zone test-vpn { ... } +    security-zone WAN { +        interfaces { +            fe-0\/0\/2.0; +        } +    } [edit] +  firewall { +      policer policer-1m { +          if-exceeding { +              bandwidth-limit 1m; +              burst-size-limit 187k; +          } +          then discard; +      } +      policer policer-1.5m { +          if-exceeding { +              bandwidth-limit 1500000; +              burst-size-limit 280k; +          } +          then discard; +      } +      filter limit-in { +          term 1 { +              then { +                  policer policer-1.5m; +                  count limiter; +              } +          } +      } +  } ^^^^ END config_and_deploy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3 id=\"pryachem-paroli-v-ansible_vault\">\u041f\u0440\u044f\u0447\u0435\u043c \u043f\u0430\u0440\u043e\u043b\u0438 \u0432 ansible_vault<\/h3>\n<p>  <\/p>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0435\u0445\u0430\u043b \u043d\u0430 <em>ansible<\/em>, \u043d\u043e \u0442\u0430\u043c \u043d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u043f\u043b\u043e\u0445\u043e. \u041e\u0447\u0435\u043d\u044c \u043c\u043d\u0435 \u0443 \u043d\u0438\u0445 <strong>vault<\/strong> \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0447\u0443\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441 \u0433\u043b\u0430\u0437 \u0434\u043e\u043b\u043e\u0439. \u0418 \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043c\u043d\u043e\u0433\u0438\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435 \u043b\u043e\u0433\u0438\u043d\u044b\/\u043f\u0430\u0440\u043e\u043b\u0438 \u043a\u043e \u0432\u0441\u0435\u043c \u0431\u043e\u0435\u0432\u044b\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440\u0430\u043c \u0441\u0432\u0435\u0440\u043a\u0430\u044e\u0442 \u0432 \u043e\u0442\u0440\u044b\u0442\u043e\u043c \u0432\u0438\u0434\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435 <em>gorups.yaml<\/em>. \u041d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e \u044d\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0449\u0438\u0442\u0438\u043c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>vault<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0437 groups.yaml \u0432 creds.yaml, \u0438 \u0437\u0430\u0448\u0438\u0444\u0440\u0443\u0435\u043c \u0435\u0433\u043e AES256 c 20-\u0437\u043d\u0430\u0447\u043d\u044b\u043c \u043f\u0430\u0440\u043e\u043b\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ cd inventory $ cat creds.yaml --- cisco:     username: admin1     password: cisco1  juniper:     username: admin2     password: juniper2  $ pwgen 20 -N 1 &gt; vault.passwd ansible-vault encrypt creds.yaml --vault-password-file vault.passwd   Encryption successful $ cat creds.yaml  $ANSIBLE_VAULT;1.1;AES256 39656463353437333337356361633737383464383231366233386636333965306662323534626131 3964396534396333363939373539393662623164373539620a346565373439646436356438653965 39643266333639356564663961303535353364383163633232366138643132313530346661316533 6236306435613132610a656163653065633866626639613537326233653765353661613337393839 62376662303061353963383330323164633162386336643832376263343634356230613562643533 30363436343465306638653932366166306562393061323636636163373164613630643965636361 34343936323066393763323633336366366566393236613737326530346234393735306261363239 35663430623934323632616161636330353134393435396632663530373932383532316161353963 31393434653165613432326636616636383665316465623036376631313162646435<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0448 <em>Nornir<\/em>-\u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <em>nr = InitNornir(config_file=&#8230;<\/em> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">... nr = InitNornir(config_file=\"config.yaml\", dry_run=True) # set dry_run=False, cross your fingers and run again  # enrich Inventory with the encrypted vault data from ansible_vault import Vault vault_password_file=\"inventory\/vault.passwd\" vault_file=\"inventory\/creds.yaml\" with open(vault_password_file, \"r\") as fp:     password = fp.readline().strip()        vault = Vault(password)     vaultdata = vault.load(open(vault_file).read())  for a in nr.inventory.hosts.keys():     item = nr.inventory.hosts[a]     item.username = vaultdata[item.groups[0]]['username']     item.password = vaultdata[item.groups[0]]['password']     #print(\"hostname={}, username={}, password={}\\n\".format(item.hostname, item.username, item.password))  # run tasks ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f vault.passwd \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043b\u0435\u0436\u0430\u0442\u044c \u0440\u044f\u0434\u043e\u043c \u0441 creds.yaml \u043a\u0430\u043a \u0432 \u043c\u043e\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u041d\u043e \u0434\u043b\u044f \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0439\u0434\u0435\u0442.<br \/>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0430 \u0432\u0441\u0435. \u041d\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0435\u0449\u0435 \u043f\u0430\u0440\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e Cisco + Zabbix, \u043d\u043e \u044d\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044e. \u0410 \u0432 \u043d\u0435\u0434\u0430\u043b\u0435\u043a\u043e\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e RESTCONF \u0432 Cisco.  <\/p>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/482194\/\"> https:\/\/habr.com\/ru\/post\/482194\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/482194\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7z\/bp\/zt\/7zbpztvjkn5yfvxwcxudhj7hrja.png\"><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0425\u0430\u0431\u0440!<br \/>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0441\u043a\u043e\u0447\u0438\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044f <a href=\"http:\/\/https:\/\/habr.com\/en\/post\/480404\/\" rel=\"nofollow\">Mikrotik \u0438 Linux. \u0420\u0443\u0442\u0438\u043d\u0430 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f<\/a> \u0433\u0434\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0440\u0435\u0448\u0430\u043b\u0438 \u0438\u0441\u043a\u043e\u043f\u0430\u0435\u043c\u044b\u043c\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438. \u0418 \u0445\u043e\u0442\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0442\u0438\u043f\u043e\u0432\u0430\u044f, \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043f\u0440\u043e \u043d\u0435\u0435 \u043a\u0430\u043a \u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f. \u041e\u0441\u043c\u0435\u043b\u044e\u0441\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u043c\u0443 \u0418\u0422-\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u0441\u0432\u043e\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-296471","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=296471"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296471\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}