{"id":253433,"date":"2015-03-20T00:08:02","date_gmt":"2015-03-19T20:08:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=253433"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=253433","title":{"rendered":"SaltStack: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0438\u043b\u0438 \u0441\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432"},"content":{"rendered":"<br \/>\n<h4><b>\u041e \u0447\u0435\u043c \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f?<\/b><\/h4>\n<p>  \u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 SaltStack \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430; \u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u043b\u0438 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0438 \u0442. \u0434. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0449\u0435 \u2014 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043a\u0430\u0436\u0434\u0430\u044f \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u0441\u0438\u0441\u0442\u0435\u043c \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439. <br \/>  <a name=\"habracut\"><\/a><br \/>  \u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0435\u0440\u0438\u0438 \u043e SaltStack, \u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0438\u0442\u0430\u0439\u0442\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/218231\/\">\u0437\u0434\u0435\u0441\u044c<\/a>, \u0432\u0442\u043e\u0440\u0443\u044e \u2014 <a href=\"http:\/\/habrahabr.ru\/post\/218249\/\">\u0442\u0443\u0442<\/a>.<\/p>\n<h4><b>\u0417\u0430\u0434\u0430\u0447\u0430: \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0442\u0430\u043a \u0447\u0442\u043e-\u0431\u044b \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u0445 \u043d\u043e\u0434 \u0431\u044b\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u043e\u0434\u044b \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430<\/b><\/h4>\n<p>  \u0421\u0430\u043c\u043e\u0435 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0434 \u0441 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u0442. \u0412\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0433\u0430\u0439\u0434\u0430\u0445, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043f\u043e SaltStack, \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043d\u0438\u0445 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c. \u0412\u0441\u0435 \u044d\u0442\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u043e\u043a\u0430 \u044d\u0442\u0438 \u043d\u043e\u0434\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u043d\u0430\u0442\u044c \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u043e\u0434 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u2014 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b \/etc\/hosts \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0434\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0438 \u0438\u043c\u0435\u043d\u0430 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043d\u043e\u0434 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435. <\/p>\n<p>  \u041a\u0430\u043a \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e SaltStack? \u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u2014 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434 \u0432 pillar \u0444\u0430\u0439\u043b \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u043e \u0432\u0441\u0435\u043c \u0441\u0442\u0435\u0439\u0442\u0430\u043c \u0432\u0441\u0435\u0445 \u043d\u043e\u0434: <\/p>\n<p>  <b>pillar\/cluster-nodes.sls<\/b>  <\/p>\n<pre><code class=\"python\">cluster-nodes:   node1:      name: node1.domain.com     ip: 10.0.0.1   node2:      name: node2.domain.com     ip: 10.0.0.2   node3:      name: node3.domain.com     ip: 10.0.0.3    .......    nodeN:      name: nodeN.domain.com     ip: 10.0.0.N <\/code><\/pre>\n<p>  <b>pillar\/top.sls<\/b>  <\/p>\n<pre><code class=\"python\">base:   '*':     - cluster-nodes <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0435\u0439\u0442 \u0434\u043b\u044f \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \/etc\/hosts. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/docs.saltstack.com\/en\/latest\/ref\/states\/all\/salt.states.host.html\">salt.states.host<\/a>.<\/p>\n<p>  <b>states\/cluster-nodes.sls<\/b>  <\/p>\n<pre><code class=\"python\">{% for node in salt['pillar.get']('cluster-nodes', []) %} cluster-node-{{node['name']}}:   host.present:     - ip: {{node['ip']}}     - names:       - {{node['name']}}       - {{node['name'].split('.')[0]}} {% endfor %} <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u0439\u0442\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434\u0430\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 <b>\/etc\/hosts<\/b>:<\/p>\n<pre><code class=\"bash\">127.0.0.1     localhost  10.0.0.1      node1.domain.com   node1 10.0.0.2      node2.domain.com   node2 10.0.0.3      node3.domain.com   node3 ......... 10.0.0.N      nodeN.domain.com   nodeN <\/code><\/pre>\n<p>  \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u2014 \u0446\u0435\u043b\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u0430 \u2014 \u0441\u043e \u0432\u0441\u0435\u0445 \u0445\u043e\u0441\u0442\u043e\u0432 \u0432\u0438\u0434\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u0435. \u0422\u0430\u043a\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0445\u043e\u0442\u044c \u0438 \u043d\u0435 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e\u0435, \u0442.\u043a. \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u043a\u0438 \u0432 pillar \u0444\u0430\u0439\u043b \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u043d\u043e\u0434 \u043a \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443, \u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0442\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043a\u043e\u0433\u0434\u0430 \u0438\u043c\u0435\u043d\u0430 \u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u0441\u0435\u0445 \u043d\u043e\u0434 \u0437\u0430\u0432\u0435\u0434\u043e\u043c\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u044b. <\/p>\n<p>  \u0410 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043d\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u0430\u0434\u0440\u0435\u0441, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u043e DHCP? \u0418\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043d\u043e\u0434 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c IaaS \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0442\u0438\u043f\u0430 Amazon EC2, GoGrid \u0438\u043b\u0438 Google Grid? \u0422\u0430\u043c \u043d\u0438 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043d\u0438 \u0438\u043c\u0435\u043d \u043d\u043e\u0434 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043d\u0435\u0442 \u0438 \u0437\u0430 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u0438 \u0434\u043e\u043f\u043b\u0430\u0447\u0438\u0432\u0430\u0442\u044c.<\/p>\n<p>  <i>(\u041b\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u2014 \u0432 \u0441\u043a\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043d\u0430\u043f\u0438\u0448\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e SaltStack \u0441\u0432\u043e\u044e \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432 EC2)<\/i>.<\/p>\n<p>  \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u0438\u043d\u0438\u043e\u043d\u0430 \u043d\u0430 \u043d\u043e\u0434\u0443, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u0438 \u0430\u0434\u0440\u0435\u0441\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"http:\/\/docs.saltstack.com\/en\/latest\/topics\/targeting\/grains.html\">salt-grains<\/a>.<\/p>\n<p>  \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430 \u043c\u0438\u043d\u0438\u043e\u043d\u0435 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">#salt-call grains.item fqdn fqdn_ip4 local:     ----------     fqdn:         ip-10-6-0-150.ec2.internal     fqdn_ip4:         - 10.6.0.150 <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u0442\u0435\u0439\u0442\u0430:<\/p>\n<pre><code class=\"python\">{% set host_name = salt['grains.get']('fqdn') %} {% set host_ip = salt['grains.get']('fqdn_ip4') %} <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0431\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u2014 \u043d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 <b>\u043d\u043e<\/b>: \u044d\u0442\u043e \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u0438 \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0438\u043d\u0438\u043e\u043d\u0430\u0445. \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432 \u0432\u0438\u0434\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043c\u0438\u043d\u0438\u043e\u043d\u0430, \u043a\u043e\u0435-\u0447\u0442\u043e \u0438\u0437 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043e\u0431 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0438\u043d\u0438\u043e\u043d\u0430\u0445.<\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0443\u0442 \u0438 \u0432\u0441\u0442\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u043a\u0430\u043a \u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432 \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043c\u0438\u043d\u0438\u043e\u043d\u0430?<\/p>\n<p>  \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442: \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/docs.saltstack.com\/en\/latest\/topics\/mine\/\"><b>salt-mine<\/b><\/a>. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0435 \u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u041a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442? \u041c\u0430\u0441\u0442\u0435\u0440 \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u0442 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432 \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u0442\u0438\u043c \u0437\u0430\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0432\u0441\u0435\u043c \u043c\u0438\u043d\u0438\u043e\u043d\u0430\u043c.<\/p>\n<p>  \u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c?<br \/>  1. \u0417\u0430\u0434\u0430\u0435\u043c mine_functions \u2014 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432. \u041c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432 \/etc\/salt\/minion \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432, \u0438\u043b\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c pillar \u0444\u0430\u0439\u043b\u0430 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432.<br \/>  2. \u041b\u0438\u0431\u043e \u0436\u0434\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f (mine_interval \u0441\u0435\u043a. \u2014 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u0438\u043d\u0438\u043e\u043d\u0430) \u043b\u0438\u0431\u043e \u0444\u043e\u0440\u0441\u0438\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0443\u043a\u0430\u043c\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b>salt &#8216;*&#8217; mine.update<\/b> <br \/>  3. \u041f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444-\u0446\u0438\u044e mine.get \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u043f\u0440\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043c\u0438\u043d\u0438\u043e\u043d\u0430.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u0445\u043e\u0441\u0442\u0430\u043c\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432. \u0418\u0442\u0430\u043a:<\/p>\n<p>  1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 pillar \u0444\u0430\u0439\u043b \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u043a\u043e \u0432\u0441\u0435\u043c \u043c\u0438\u043d\u0438\u043e\u043d\u0430\u043c:<\/p>\n<p>  <b>pillar\/minefuncs.sls<\/b>  <\/p>\n<pre><code class=\"python\">mine_functions:   grains.item: [fqdn, fqdn_ip4] <\/code><\/pre>\n<p>  <b>pillar\/top.sls<\/b>  <\/p>\n<pre><code class=\"python\">base:   '*':     - minefuncs <\/code><\/pre>\n<p>  2. \u0424\u043e\u0440\u0441\u0438\u043c \u0441\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432.<\/p>\n<p>  3. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0442\u0435\u0439\u0442 \u0434\u043b\u044f <b>\/etc\/hosts<\/b>:<\/p>\n<pre><code class=\"python\">{% for node, fqdn_data in salt['mine.get']('*', 'grains.item', expr_form='glob').items() %} cluster-node-{{fqdn_data['fqdn']}}:   host.present:     - names:       - {{fqdn_data['fqdn'].split('.')[0]}}       - {{fqdn_data['fqdn']}}     - ip: {{fqdn_data['fqdn_ip4'][0]}} {% endfor %} <\/code><\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0441 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0438\u043c\u0435\u043d\u0430 \u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u0441\u0435\u0445 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u043b\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0441\u0442\u0435\u0439\u0442 (\u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0443 \u043e\u0434\u043d\u0438\u0445 \u043d\u043e\u0434 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u043e\u0434\u043d\u0430 \u0440\u043e\u043b\u044c, \u0443 \u0434\u0440\u0443\u0433\u0438\u0445 \u2014 \u0434\u0440\u0443\u0433\u0430\u044f \u0438 \u043d\u0430\u0434\u043e \u0432\u044b\u0447\u043b\u0435\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0434\u044b \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u043e\u043b\u044f\u043c\u0438) \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f\u043c\u0438:<\/p>\n<p>  1. \u0414\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c <b>custom grain<\/b> (\u044d\u0442\u043e \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438), \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443: grains:roles:name_node \u0438 grains:roles:data_node.<br \/>  2. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0432 <b>mine.get<\/b> \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0440\u043e\u043b\u044f\u043c. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">{% for node, fqdn_data in salt['mine.get']('roles:data_node', 'grains.item', expr_form='grain').items() %} cluster-node-{{fqdn_data['fqdn']}}:   host.present:     - names:       - {{fqdn_data['fqdn'].split('.')[0]}}       - {{fqdn_data['fqdn']}}     - ip: {{fqdn_data['fqdn_ip4'][0]}} {% endfor %}   {% for node, fqdn_data in salt['mine.get']('* and not G@roles:data_node', 'grains.item', expr_form='compound').items() %} cluster-node-{{fqdn_data['fqdn']}}:   host.present:     - names:       - {{fqdn_data['fqdn'].split('.')[0]}}       - {{fqdn_data['fqdn']}}     - ip: {{fqdn_data['fqdn_ip4'][0]}} {% endfor %} <\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <b>expr_form<\/b> \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438.<\/p>\n<p>  \u0412\u043e\u0442, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u2014 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043c\u0438\u043d\u0438\u043e\u043d\u043e\u0432. <\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u0438\u043a \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u043c\u0438\u043d\u0438\u043e\u043d\u0430\u043c\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0441\u0442\u0430\u0442\u0435\u0439\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 SaltStack \u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u0445.<\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0447\u0442\u0435\u043d\u0438\u0435.      \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/253443\/\"> http:\/\/habrahabr.ru\/post\/253443\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<br \/>\n<h4><b>\u041e \u0447\u0435\u043c \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f?<\/b><\/h4>\n<p>  \u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 SaltStack \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430; \u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u043b\u0438 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0438 \u0442. \u0434. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0449\u0435 \u2014 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043a\u0430\u0436\u0434\u0430\u044f \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u0441\u0438\u0441\u0442\u0435\u043c \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439.   <\/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-253433","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253433","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=253433"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253433\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=253433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=253433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=253433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}