{"id":302379,"date":"2020-04-23T15:01:01","date_gmt":"2020-04-23T15:01:01","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=302379"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=302379","title":{"rendered":"\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0434\u0435\u043f\u043b\u043e\u0439 vm ESXi \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Terraform"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/498716\/\">\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0418\u0432\u0430\u043d \u0438 \u044f <s>\u0430\u043b\u043a\u043e\u0433\u043e\u043b\u0438\u043a<\/s> \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 (OPS). <\/p>\n<p>  \u042f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b \u043d\u0430 ESXi \u0431\u0435\u0437 vCenter \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Terraform.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\/\u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u043a\u0438, \u0447\u0442\u043e \u0431\u044b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0412 \u0441\u0438\u043b\u0443 \u043b\u0435\u043d\u0438 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b \u043e\u0431 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041c\u043e\u0438 \u043f\u043e\u0438\u0441\u043a\u0438 \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043c\u0435\u043d\u044f \u043a \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0443 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 <a href=\"https:\/\/www.hashicorp.com\">hashicorp<\/a>, <a href=\"https:\/\/www.terraform.io\">terraform<\/a>.<\/p>\n<p>  \u0414\u0443\u043c\u0430\u044e \u043c\u043d\u043e\u0433\u0438\u0435 \u0437\u043d\u0430\u044e\u0442 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Terraform, \u0430 \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u044d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u044b\u043c \u043e\u0431\u043b\u0430\u043a\u043e\u043c, \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0438\u043b\u0438 \u0441\u043b\u0443\u0436\u0431\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e IasC (<i>\u0418\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043a\u0430\u043a \u043a\u043e\u0434<\/i>).<\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0440\u0435\u0434\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e ESXi. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0438 \u043d\u0430\u0434\u0451\u0436\u043d\u0430\u044f.<br \/>  \u041f\u0440\u0435\u0434\u0432\u0438\u0436\u0443 \u0432\u043e\u043f\u0440\u043e\u0441. <\/p>\n<blockquote><p>\u0417\u0430\u0447\u0435\u043c terraform \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c vCenter Server?<\/p><\/blockquote>\n<p>\u041c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u043e. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u044f, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0435\u043c\u043a\u0438\u0439 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u043c\u043e\u0451\u043c \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0438 \u0432-\u0442\u0440\u0435\u0442\u044c\u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0442\u044c \u0441\u043a\u0438\u043b\u043b\u044b.<\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 Intel NUC:<\/p>\n<pre><code class=\"php\">CPU: 2 CPUs x Intel(R) Core(TM) i3-4010U CPU @ 1.70GHz RAM: 8Gb HDD: 500Gb ESXi version: ESXi-6.5.0-4564106-standard (VMware, Inc.)<\/code><\/pre>\n<p>  \u0418 \u0442\u0430\u043a, \u043e\u0431\u043e \u0432\u0441\u0451\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443. <\/p>\n<p>  \u041f\u043e\u043a\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c esxi, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0442\u043a\u0440\u043e\u0435\u043c VNC \u043f\u043e\u0440\u0442 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u0430.<\/p>\n<p>  \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0444\u0430\u0439\u043b \u0437\u0430\u0449\u0438\u0449\u0451\u043d \u043e\u0442 \u0437\u0430\u043f\u0438\u0441\u0438. \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438:<\/p>\n<pre><code class=\"php\">chmod 644 \/etc\/vmware\/firewall\/service.xml chmod +t \/etc\/vmware\/firewall\/service.xml vi \/etc\/vmware\/firewall\/service.xml<\/code><\/pre>\n<p>  \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0431\u043b\u043e\u043a:<\/p>\n<pre><code class=\"xml\">&lt;service id=&quot;1000&quot;&gt;   &lt;id&gt;packer-vnc&lt;\/id&gt;   &lt;rule id=&quot;0000&quot;&gt;     &lt;direction&gt;inbound&lt;\/direction&gt;     &lt;protocol&gt;tcp&lt;\/protocol&gt;     &lt;porttype&gt;dst&lt;\/porttype&gt;     &lt;port&gt;       &lt;begin&gt;5900&lt;\/begin&gt;       &lt;end&gt;6000&lt;\/end&gt;     &lt;\/port&gt;   &lt;\/rule&gt;   &lt;enabled&gt;true&lt;\/enabled&gt;   &lt;required&gt;true&lt;\/required&gt; &lt;\/service&gt;<\/code><\/pre>\n<p>  \u0412\u044b\u0445\u043e\u0434\u0438\u043c, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c. \u041c\u0435\u043d\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441:<\/p>\n<pre><code class=\"php\">chmod 444 \/etc\/vmware\/firewall\/service.xml esxcli network firewall refresh<\/code><\/pre>\n<p>  \u0410\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0445\u043e\u0441\u0442\u0430. \u041f\u043e\u0441\u043b\u0435 \u0436\u0435, \u0434\u0430\u043d\u043d\u0443\u044e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c.<\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0431\u0443\u0434\u0443 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u043d\u0430 \u044d\u0442\u043e\u043c \u0436\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p>  \u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438:<\/p>\n<pre><code class=\"php\">OS: Centos 7 x86_64 minimal RAM: 1GB HDD: 20GB Selinux: disable firewalld: disable<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/www.packer.io\">packer<\/a>, \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 HashiCorp. <\/p>\n<p>  \u041d\u0443\u0436\u0435\u043d \u043e\u043d, \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u00ab\u0437\u043e\u043b\u043e\u0442\u043e\u0433\u043e\u00bb \u043e\u0431\u0440\u0430\u0437\u0430. \u041a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<pre><code class=\"php\">yum install unzip git -y curl -O https:\/\/releases.hashicorp.com\/packer\/1.5.5\/packer_1.5.5_linux_amd64.zip unzip packer_1.5.5_linux_amd64.zip -d \/usr\/bin && rm -rf packer_1.5.5_linux_amd64.zip packer version Packer v1.5.5<\/code><\/pre>\n<p>  \u041d\u0430 \u0448\u0430\u0433\u0435 <i>packer version<\/i> \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 RedHat-based \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u043a\u0435\u0442 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c.<\/p>\n<pre><code class=\"php\">which -a packer \/usr\/sbin\/packer<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0438\u043c\u043b\u0438\u043d\u043a, \u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0439 \u043f\u0443\u0442\u044c <i>\/usr\/bin\/packer.<\/i><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f ovftool <a href=\"https:\/\/www.vmware.com\/support\/developer\/ovf\/\">download link<\/a>. \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c, \u043a\u043b\u0430\u0434\u0451\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c:<\/p>\n<pre><code class=\"php\">chmod +x VMware-ovftool-4.4.0-15722219-lin.x86_64.bundle .\/VMware-ovftool-4.4.0-15722219-lin.x86_64.bundle Extracting VMware Installer...done. You must accept the VMware OVF Tool component for Linux End User License Agreement to continue.  Press Enter to proceed. VMWARE END USER LICENSE AGREEMENT Do you agree? [yes\/no]:yes The product is ready to be installed.  Press Enter to begin installation or Ctrl-C to cancel.  Installing VMware OVF Tool component for Linux 4.4.0     Configuring... [######################################################################] 100% Installation was successful.<\/code><\/pre>\n<p>  \u0414\u0432\u0438\u0436\u0435\u043c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>  \u041d\u0430 \u0433\u0438\u0442\u0435 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u0432\u0441\u0451 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435. <\/p>\n<pre><code class=\"php\">git clone https:\/\/github.com\/letnab\/create-and-deploy-esxi.git && cd create-and-deploy-esxi<\/code><\/pre>\n<p>  \u0412 \u043f\u0430\u043f\u043a\u0443 <i>iso<\/i> \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e centos 7.<\/p>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b <i>centos-7-base.json<\/i>:<\/p>\n<pre><code class=\"php\">variables: \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f iso_urls: \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 iso_checksum: \u0447\u0435\u043a\u0441\u0443\u043c\u043c\u0430 \u0432\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0443:<\/p>\n<pre><code class=\"php\">\/usr\/bin\/packer build centos-7-base.json<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u0435\u0440\u043d\u043e, \u0442\u043e \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u044f\u0446\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443 \u043c\u0435\u043d\u044f \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 7-8 \u043c\u0438\u043d\u0443\u0442.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 <i>output-packer-centos7-x86_64<\/i> \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f ova \u0444\u0430\u0439\u043b.<\/p>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c Terraform:<\/p>\n<pre><code class=\"php\">curl -O https:\/\/releases.hashicorp.com\/terraform\/0.12.24\/terraform_0.12.24_linux_amd64.zip unzip terraform_0.12.24_linux_amd64.zip -d \/usr\/bin\/ && rm -rf terraform_0.12.24_linux_amd64.zip terraform version Terraform v0.12.24<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0443 Terraform \u043d\u0435\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u043f\u043e\u0434 ESXi, \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c.<\/p>\n<p>  \u0421\u0442\u0430\u0432\u0438\u043c go:<\/p>\n<pre><code class=\"php\">cd \/tmp curl -O https:\/\/dl.google.com\/go\/go1.14.2.linux-amd64.tar.gz tar -C \/usr\/local -xzf go1.14.2.linux-amd64.tar.gz && rm -rf go1.14.2.linux-amd64.tar.gz export PATH=$PATH:\/usr\/local\/go\/bin go version go version go1.14.2 linux\/amd64<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440:<\/p>\n<pre><code class=\"php\">go get -u -v golang.org\/x\/crypto\/ssh go get -u -v github.com\/hashicorp\/terraform go get -u -v github.com\/josenk\/terraform-provider-esxi export GOPATH=&quot;$HOME\/go&quot; cd $GOPATH\/src\/github.com\/josenk\/terraform-provider-esxi CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-w -extldflags &quot;-static&quot;' -o terraform-provider-esxi_`cat version` cp terraform-provider-esxi_`cat version` \/usr\/bin<\/code><\/pre>\n<p>  \u041c\u044b \u043d\u0430 \u0444\u0438\u043d\u0438\u0448\u043d\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439. \u041f\u043e\u0435\u0445\u0430\u043b\u0438 \u0440\u0430\u0441\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443:<\/p>\n<pre><code class=\"php\">cd \/root\/create-and-deploy-esxi\/centos7<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b <i>variables.tf<\/i>. \u041d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 ESXi.<\/p>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 <i>network_config.cfg<\/i> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b. \u041c\u0435\u043d\u044f\u0435\u043c \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a:<\/p>\n<pre><code class=\"php\">sed -i -e '2d' -e '3i &quot;network&quot;: &quot;'$(gzip &lt; network_config.cfg| base64 | tr -d '\\n')'&quot;,' metadata.json<\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 <i>main.tf<\/i> \u043c\u0435\u043d\u044f\u0435\u043c \u043f\u0443\u0442\u044c \u043a ova \u0444\u0430\u0439\u043b\u0443 \u043d\u0430 \u0441\u0432\u043e\u0439, \u0435\u0441\u043b\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. <\/p>\n<p>  \u041c\u043e\u043c\u0435\u043d\u0442 \u0438\u0441\u0442\u0438\u043d\u044b.<\/p>\n<pre><code class=\"php\">terraform init Initializing the backend...  Initializing provider plugins...  The following providers do not have any version constraints in configuration, so the latest version was installed.  To prevent automatic upgrades to new major versions that may contain breaking changes, it is recommended to add version = &quot;...&quot; constraints to the corresponding provider blocks in configuration, with the constraint strings suggested below.  * provider.esxi: version = &quot;~&gt; 1.6&quot; * provider.template: version = &quot;~&gt; 2.1&quot;  Terraform has been successfully initialized!  You may now begin working with Terraform. Try running &quot;terraform plan&quot; to see any changes that are required for your infrastructure. All Terraform commands should now work.  If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"php\">terraform plan Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage.  data.template_file.Default: Refreshing state... data.template_file.network_config: Refreshing state...  ------------------------------------------------------------------------  An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols:   + create  Terraform will perform the following actions:    # esxi_guest.Default will be created   + resource &quot;esxi_guest&quot; &quot;Default&quot; {       + boot_disk_size         = (known after apply)       + disk_store             = &quot;datastore1&quot;       + guest_name             = &quot;centos7-test&quot;       + guest_shutdown_timeout = (known after apply)       + guest_startup_timeout  = (known after apply)       + guestinfo              = {           + &quot;metadata&quot;          = &quot;base64text&quot;           + &quot;metadata.encoding&quot; = &quot;gzip+base64&quot;           + &quot;userdata&quot;          = &quot;base64text&quot;           + &quot;userdata.encoding&quot; = &quot;gzip+base64&quot;         }       + guestos                = (known after apply)       + id                     = (known after apply)       + ip_address             = (known after apply)       + memsize                = &quot;1024&quot;       + notes                  = (known after apply)       + numvcpus               = (known after apply)       + ovf_properties_timer   = (known after apply)       + ovf_source             = &quot;\/root\/create-and-deploy-esxi\/output-packer-centos7-x86_64\/packer-centos7-x86_64.ova&quot;       + power                  = &quot;on&quot;       + resource_pool_name     = (known after apply)       + virthwver              = (known after apply)        + network_interfaces {           + mac_address     = (known after apply)           + nic_type        = (known after apply)           + virtual_network = &quot;VM Network&quot;         }     }  Plan: 1 to add, 0 to change, 0 to destroy.  ------------------------------------------------------------------------  Note: You didn't specify an &quot;-out&quot; parameter to save this plan, so Terraform can't guarantee that exactly these actions will be performed if &quot;terraform apply&quot; is subsequently run. <\/code><\/pre>\n<p>  \u0424\u0438\u043d\u0438\u0448:<\/p>\n<pre><code class=\"perl\">terraform apply<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432\u0435\u0440\u043d\u043e, \u0442\u043e \u0447\u0435\u0440\u0435\u0437 2-3 \u043c\u0438\u043d\u0443\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442\u0430 \u043d\u043e\u0432\u0430\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0448\u0438\u043d\u0430 \u0438\u0437 \u0440\u0430\u043d\u0435\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430. <\/p>\n<p>  \u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0435\u0439.<\/p>\n<p>  \u042f \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0430\u043c\u0438 \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u043c\u0438. <\/p>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<p>  P.S.: \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043a\u0440\u0438\u0442\u0438\u043a\u0435.<\/p><\/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=\"https:\/\/habr.com\/ru\/post\/498716\/\"> https:\/\/habr.com\/ru\/post\/498716\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/498716\/\">\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0418\u0432\u0430\u043d \u0438 \u044f <s>\u0430\u043b\u043a\u043e\u0433\u043e\u043b\u0438\u043a<\/s> \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 (OPS). <\/p>\n<p>  \u042f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b \u043d\u0430 ESXi \u0431\u0435\u0437 vCenter \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Terraform.  <\/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-302379","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/302379","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=302379"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/302379\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=302379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=302379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=302379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}