{"id":266738,"date":"2015-10-25T23:28:02","date_gmt":"2015-10-25T20:28:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=266738"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=266738","title":{"rendered":"SparkleFormation \u2014 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 CloudFormation \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0441 \u0440\u0430\u0434\u0443\u0433\u0430\u043c\u0438 \u0438 \u0435\u0434\u0438\u043d\u043e\u0440\u043e\u0433\u0430\u043c\u0438"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ec3\/493\/0ef\/ec34930efa22db34a6eb58c365eb43cf.png\" alt=\"SparkleFormation\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 AWS (Amazon Web Services), \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0437\u043d\u0430\u0435\u0442\u0435 \u043f\u0440\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e JSON \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432. \u0412 AWS \u044d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/aws.amazon.com\/cloudformation\/\">CloudFormation<\/a>. \u041f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043b\u044e\u0431\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432 AWS (\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b, \u0441\u043b\u043e\u0438 opsworks, ELB, security groups \u0438 \u0442.\u0434.). \u041d\u0430\u0431\u043e\u0440 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0435\u043a\u043e\u043c. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 CloudFormation \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0430\u043c\u0430 \u043b\u0438\u0431\u043e \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0432 \u0441\u0442\u0435\u043a\u0435, \u0435\u0441\u043b\u0438 \u0438\u0445 \u0435\u0449\u0451 \u043d\u0435\u0442, \u043b\u0438\u0431\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0434\u043e \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<p>  \u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043d\u043e \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:  <\/p>\n<ul>\n<li>\u0412 JSON \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0438\u043a\u043b\u044b \u0438 \u0434\u043b\u044f \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u043e\u0436\u0435 (\u043d\u0435 DRY)<\/li>\n<li>\u0414\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f <a href=\"https:\/\/cloudinit.readthedocs.org\/en\/latest\/\">cloud-init<\/a> \u043d\u0443\u0436\u0435\u043d \u0434\u0432\u043e\u0439\u043d\u043e\u0439 escaping<\/li>\n<li>\u0412 JSON \u043d\u0435\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0438 \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u043f\u043b\u043e\u0445\u0443\u044e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u0447\u0438\u0442\u0430\u0435\u043c\u043c\u043e\u0441\u0442\u044c<\/li>\n<\/ul>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u044b \u0438\u0437 <a href=\"http:\/\/www.heavywater.io\/\">Heavy Water<\/a> \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430 ruby DSL \u0438 CLI \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u0442\u0438\u043c\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"http:\/\/www.sparkleformation.io\/\">SparkleFormation<\/a> (<a href=\"https:\/\/github.com\/sparkleformation\/sparkle_formation\">github<\/a>).<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h1>DRY<\/h1>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u044f \u043f\u0440\u0438\u0448\u0451\u043b \u043d\u0430 \u0441\u0432\u043e\u0439 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b CloudFormation \u0448\u0430\u0431\u043b\u043e\u043d, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043e\u043a\u043e\u043b\u043e 1500 \u0441\u0442\u0440\u043e\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0438 \u043e\u043a\u043e\u043b\u043e 0 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432. \u041f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f SparkleFormation \u0448\u0430\u0431\u043b\u043e\u043d \u0441\u0442\u0430\u043b \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c 300 \u0441\u0442\u0440\u043e\u043a, \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438. \u041a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0434\u043e\u0431\u0438\u043b\u0438\u0441\u044c? \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 CloudFormation, \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 ELB<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>    &quot;AppsElb&quot;: {       &quot;Type&quot;: &quot;AWS::ElasticLoadBalancing::LoadBalancer&quot;,       &quot;Properties&quot;: {         &quot;Scheme&quot;: &quot;internal&quot;,         &quot;Subnets&quot;: [           {&quot;Ref&quot;: &quot;Subnet1&quot;},           {&quot;Ref&quot;: &quot;Subnet2&quot;}         ],         &quot;SecurityGroups&quot;: [           {&quot;Ref&quot;: &quot;SG&quot;}         ],         &quot;HealthCheck&quot;: {           &quot;HealthyThreshold&quot;: &quot;2&quot;,           &quot;Interval&quot;: &quot;5&quot;,           &quot;Target&quot;: &quot;TCP:80&quot;,           &quot;Timeout&quot;: &quot;2&quot;,           &quot;UnhealthyThreshold&quot;: &quot;2&quot;         },         &quot;Listeners&quot;: [           {             &quot;InstancePort&quot;: &quot;80&quot;,             &quot;LoadBalancerPort&quot;: &quot;80&quot;,             &quot;Protocol&quot;: &quot;TCP&quot;,             &quot;InstanceProtocol&quot;: &quot;TCP&quot;           },           {             &quot;InstancePort&quot;: &quot;22&quot;,             &quot;LoadBalancerPort&quot;: &quot;2222&quot;,             &quot;Protocol&quot;: &quot;TCP&quot;,             &quot;InstanceProtocol&quot;: &quot;TCP&quot;           },           {             &quot;InstancePort&quot;: &quot;8500&quot;,             &quot;LoadBalancerPort&quot;: &quot;8500&quot;,             &quot;Protocol&quot;: &quot;TCP&quot;,             &quot;InstanceProtocol&quot;: &quot;TCP&quot;           }         ]       }     } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 SparkleFormation \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 ruby \u043a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438 DSL, \u0442\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 ELB \u0432 SparkleFormation<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"ruby\">  resources(:AppsElb) do     type 'AWS::ElasticLoadBalancing::LoadBalancer'     properties do       scheme 'internal'       subnets [PARAMS[:Subnet1], PARAMS[:Subnet2]]       security_groups [ref!(:SG)]       # port mapping 80-&gt;80, 22 -&gt; 2222, etc.       listeners = { :'80' =&gt; 80, :'2222' =&gt; 22, :'8500' =&gt; 8500 }.map do |k, v|         { 'LoadBalancerPort' =&gt; k.to_s,           'InstancePort' =&gt; v,           'Protocol' =&gt; 'TCP',           'InstanceProtocol' =&gt; 'TCP' }       end       listeners listeners       health_check do         target 'TCP:80'         healthy_threshold '2'         unhealthy_threshold '2'         interval '5'         timeout '2'       end     end   end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c\u0441\u044f \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0437\u0430\u0439\u043c\u0451\u0442 \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0447\u0442\u0438 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043f\u043e 1-2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c, SparkleFormation \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0430\u043a\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u043a dynamics, \u0433\u0434\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"ruby\"># dynamics\/node.rb SparkleFormation.dynamic(:node) do |_name, _config={}|   unless(_config[:ssh_key])     parameters.set!(&quot;#{_name}_ssh_key&quot;.to_sym) do       type 'String'     end   end   dynamic!(:ec2_instance, _name).properties do     key_name _config[:ssh_key] ? _config[:ssh_key] : ref!(&quot;#{_name}_ssh_key&quot;.to_sym)   end end <\/code><\/pre>\n<p>  \u0410 \u043f\u043e\u0442\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435:  <\/p>\n<pre><code class=\"ruby\">SparkleFormation.new(:node_stack) do   dynamic!(:node, :fubar)   dynamic!(:node, :foobar, :ssh_key =&gt; 'default') end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u0432 1 \u043c\u0435\u0441\u0442\u0435.<\/p>\n<h1>Cloud-init<\/h1>\n<p>  \u041c\u044b \u0447\u0430\u0441\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 cloud-init \u043a\u043e\u043d\u0444\u0438\u0433 \u0432 \u0432\u0438\u0434\u0435 yaml-\u0444\u0430\u0439\u043b\u0430 \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e CoreOS, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e yaml \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443 \u0432 user-data \u0432 CloudFormation \u0448\u0430\u0431\u043b\u043e\u043d\u0435 \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0411\u0435\u0437\u0443\u043c\u043d\u044b\u0439 escaping<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>        &quot;UserData&quot;: {           &quot;Fn::Base64&quot;: {             &quot;Fn::Join&quot;: [               &quot;&quot;,               [                 &quot;#cloud-config\\n&quot;,                 &quot;\\n&quot;,                 &quot;coreos:\\n&quot;,                 &quot;  etcd:\\n&quot;,                 &quot;    discovery: &quot;, {&quot;Ref&quot;: &quot;AppDiscoveryURL&quot;}, &quot;\\n&quot;,                 &quot;    addr: $private_ipv4:4001\\n&quot;,                 &quot;    peer-addr: $private_ipv4:7001\\n&quot;,                 &quot;  etcd2:\\n&quot;,  ... <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u043e, \u0443\u0440\u043e\u0434\u043b\u0438\u0432\u043e \u0438 \u043f\u043b\u043e\u0445\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e, \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u0443\u0436\u0435 \u043e \u0442\u043e\u043c \u0447\u0442\u043e \u043e \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u044b\u0442\u044c. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 DSL \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ruby \u043a\u043e\u0434, \u0442\u043e \u0432\u0435\u0441\u044c yaml \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c:  <\/p>\n<pre><code class=\"ruby\">user_data Base64.encode64(IO.read('files\/cloud-init.yml')) <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u044d\u0442\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435 \u0447\u0435\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0438 JSON. \u0412\u043c\u0435\u0441\u0442\u043e IO.read \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 HTTP \u0432\u044b\u0437\u043e\u0432 \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e. <\/p>\n<h1>CLI<\/h1>\n<p>  \u0423 \u0441\u0435\u0431\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043e\u0431\u0451\u0440\u0442\u043a\u0443 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438, \u043d\u043e \u044d\u0442\u0430 \u0436\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 CLI (Command Line Interface) \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 <a href=\"https:\/\/github.com\/sparkleformation\/sfn\">sfn<\/a>. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c, \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c CloudFormation \u0441\u0442\u0435\u043a\u0438, \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 sfn create, sfn destroy \u0438 sfn update. \u0422\u0430\u043c \u0442\u0430\u043a \u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 knife.<\/p>\n<p>  \u0412 \u0446\u0435\u043b\u043e\u043c \u043f\u043e\u0441\u043b\u0435 4 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f SparkleFormation \u044f \u0438\u043c \u0434\u043e\u0432\u043e\u043b\u0435\u043d \u0438 \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0432\u0435\u0440\u043d\u0443\u0441\u044c \u043d\u0430 plain JSON \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0412 \u043f\u043b\u0430\u043d\u0430\u0445 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c workflow, \u0432\u043a\u043b\u044e\u0447\u0430\u044f sfn, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 Heavy Water.               <\/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\/269501\/\"> http:\/\/habrahabr.ru\/post\/269501\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ec3\/493\/0ef\/ec34930efa22db34a6eb58c365eb43cf.png\" alt=\"SparkleFormation\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 AWS (Amazon Web Services), \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0437\u043d\u0430\u0435\u0442\u0435 \u043f\u0440\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e JSON \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432. \u0412 AWS \u044d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/aws.amazon.com\/cloudformation\/\">CloudFormation<\/a>. \u041f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043b\u044e\u0431\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432 AWS (\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b, \u0441\u043b\u043e\u0438 opsworks, ELB, security groups \u0438 \u0442.\u0434.). \u041d\u0430\u0431\u043e\u0440 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0435\u043a\u043e\u043c. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 CloudFormation \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0430\u043c\u0430 \u043b\u0438\u0431\u043e \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0432 \u0441\u0442\u0435\u043a\u0435, \u0435\u0441\u043b\u0438 \u0438\u0445 \u0435\u0449\u0451 \u043d\u0435\u0442, \u043b\u0438\u0431\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0434\u043e \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<p>  \u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043d\u043e \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:  <\/p>\n<ul>\n<li>\u0412 JSON \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0438\u043a\u043b\u044b \u0438 \u0434\u043b\u044f \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u043e\u0436\u0435 (\u043d\u0435 DRY)<\/li>\n<li>\u0414\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f <a href=\"https:\/\/cloudinit.readthedocs.org\/en\/latest\/\">cloud-init<\/a> \u043d\u0443\u0436\u0435\u043d \u0434\u0432\u043e\u0439\u043d\u043e\u0439 escaping<\/li>\n<li>\u0412 JSON \u043d\u0435\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0438 \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u043f\u043b\u043e\u0445\u0443\u044e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u0447\u0438\u0442\u0430\u0435\u043c\u043c\u043e\u0441\u0442\u044c<\/li>\n<\/ul>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u044b \u0438\u0437 <a href=\"http:\/\/www.heavywater.io\/\">Heavy Water<\/a> \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430 ruby DSL \u0438 CLI \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u0442\u0438\u043c\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"http:\/\/www.sparkleformation.io\/\">SparkleFormation<\/a> (<a href=\"https:\/\/github.com\/sparkleformation\/sparkle_formation\">github<\/a>).  <\/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-266738","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266738","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=266738"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266738\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}