{"id":344133,"date":"2023-01-18T15:02:12","date_gmt":"2023-01-18T15:02:12","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=344133"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=344133","title":{"rendered":"<span>\u041b\u0443\u0447\u0448\u0438\u0435 \u0434\u0440\u0443\u0437\u044c\u044f: Terraform, Ansible \u0438 Jenkins<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Jenkins CI\/CD Pipeline \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b AWS \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Terraform \u0438 Ansible. \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c Terraform \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043f\u043e \u043c\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u0438 \u0448\u0430\u0433\u0438 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438. \u041a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 \u043a\u043e\u0434 Terraform, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u0440\u0435\u0434\u0443 AWS \u0441 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u043f\u043e\u0434\u0441\u0435\u0442\u044f\u043c\u0438 \u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430\u043c\u0438 EC2 \u0441 Ansible Playbook. \u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u0434 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 GitHub, GitHub Webhook \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 Jenkins CI\/CD Pipeline, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0443\u0434\u0430 \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u0434 \u2014 \u0432 \u0432\u0435\u0442\u043a\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/50b\/f49\/949\/50bf4994977528bccf87c2568ada9918.jpg\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/50b\/f49\/949\/50bf4994977528bccf87c2568ada9918.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0412\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f<\/h3>\n<ul>\n<li>\n<p>\u0430\u043a\u043a\u0430\u0443\u043d\u0442 <a href=\"https:\/\/github.com\/\"><u>GitHub<\/u><\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.aws.amazon.com\/cli\/latest\/userguide\/install-cliv2.html\"><u>AWS CLI<\/u><\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/learn.hashicorp.com\/tutorials\/terraform\/install-cli\"><u>Terraform<\/u><\/a>;<\/p>\n<\/li>\n<li>\n<p>\u0430\u043a\u043a\u0430\u0443\u043d\u0442 <a href=\"https:\/\/aws.amazon.com\/premiumsupport\/knowledge-center\/create-and-activate-aws-account\/\"><u>AWS<\/u><\/a>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c AWS \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>AWS Cloud9 (\u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e IDE, \u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0448\u0430\u0433\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f);<\/p>\n<\/li>\n<li>\n<p>\u0430\u043a\u043a\u0430\u0443\u043d\u0442 <a href=\"https:\/\/app.terraform.io\/signup\/account?utm_source=cloud_landing&amp;utm_content=offers_tfc\"><u>Terraform Cloud<\/u><\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Getting-Started-Installing-Git\"><u>Git<\/u><\/a>.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0441\u0440\u0435\u0434\u0443<\/h3>\n<h4>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u0440\u0435\u0434\u0443 Amazon Cloud9.\u00a0<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043a\u0440\u043e\u043c\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u00abPlatform section\u00bb. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 Ubuntu Server 18.04 LTS.<\/p>\n<h4>\u041d\u0430\u0437\u043d\u0430\u0447\u044c\u0442\u0435 Elastic IP address\u00a0<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u043d\u0441\u0442\u0430\u043d\u0441 Cloud9 \u043d\u0435 \u043c\u0435\u043d\u044f\u043b \u0441\u0432\u043e\u0439 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 IP-\u0430\u0434\u0440\u0435\u0441 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438 \u0441\u043d\u043e\u0432\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u0437\u043d\u0430\u0447\u044c\u0442\u0435 \u0435\u043c\u0443 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 IP-\u0430\u0434\u0440\u0435\u0441. \u041f\u043e\u0437\u0436\u0435 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 IP-\u0430\u0434\u0440\u0435\u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 Terraform \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.\u00a0<\/p>\n<p>1. \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 AWS \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a EC2.<\/p>\n<p>2. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00abElastic IPs\u00bb \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u00abNetwork &amp; Security\u00bb.\u00a0<\/p>\n<p>3. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00abAllocate Elastic IP address\u00bb.<\/p>\n<p>4. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00abAllocate\u00bb.\u00a0<\/p>\n<p>5. \u0412 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u043c\u0441\u044f \u0441\u043f\u0438\u0441\u043a\u0435 \u00abAction\u00bb \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00abAssociate Elastic IP Address\u00bb:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/084\/ca6\/490\/084ca649082b0c78b5cca7b5cb5f6ce1.png\" width=\"574\" height=\"374\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/084\/ca6\/490\/084ca649082b0c78b5cca7b5cb5f6ce1.png\"\/><figcaption><\/figcaption><\/figure>\n<p>6. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00abCloud9 instance\u00bb > \u00abPrivate IP address\u00bb > \u00abCloud9 private IP address\u00bb. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00abAssociate\u00bb (\u0441\u0432\u044f\u0437\u0430\u0442\u044c).\u00a0<\/p>\n<h4>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 Cloud9<\/h4>\n<p>1. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432 Cloud9 \u0444\u0430\u0439\u043b \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <a href=\"http:\/\/resize.sh\">resize.sh<\/a>.<\/p>\n<p>2. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/morethancertified\/mtc-terraform\/blob\/main\/extras\/resize.sh\"><u>\u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/u><\/a> \u0432 \u0444\u0430\u0439\u043b <a href=\"http:\/\/resize.sh\">resize.sh<\/a>.<\/p>\n<p>3. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>chmod +x resize.sh<\/code><\/p>\n<p>4. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>.\/resize.sh<\/code><\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 SSH-\u043a\u043b\u044e\u0447<\/h4>\n<p>1. \u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>ssh-keygen -t rsa<\/code><\/p>\n<p>2. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0444\u0430\u0439\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d \u043a\u043b\u044e\u0447: <code>\/home\/ubuntu\/.ssh\/[\u0438\u043c\u044f \u043a\u043b\u044e\u0447\u0430]<\/code><\/p>\n<p>3. \u0411\u0435\u0437 passphrase.<\/p>\n<p>4. \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u043a\u043b\u044e\u0447 \u0441\u043e\u0437\u0434\u0430\u043d, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>ls ~\/.ssh<\/code><\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 jq<\/h4>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>sudo apt install jq<\/code><\/p>\n<h4>Fork Repo<\/h4>\n<p><a href=\"https:\/\/github.com\/troy-ingram\/terraform-ansible-jenkins.git\"><u>\u0417\u0434\u0435\u0441\u044c<\/u><\/a> \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u0434, \u0435\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0441\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0433\u043e.\u00a0\u00a0<\/p>\n<h3>Terraform Cloud<\/h3>\n<p><a href=\"https:\/\/cloud.hashicorp.com\/products\/terraform\"><u>Terraform Cloud<\/u><\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c Terraform State (\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 Terraform) \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e, \u0430 \u043d\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e. \u042d\u0442\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<p><em>\u041f\u0440\u0438\u043c., \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430: \u0442\u0430\u043a\u0436\u0435 Terraform State \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 s3 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u2014 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d-\u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/em><\/p>\n<p>1. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u043e\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e.<\/p>\n<p>2. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <strong>CLI-driven workflow<\/strong>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2f5\/36c\/e79\/2f536ce798db9c900faa9bc4186d4213.png\" width=\"702\" height=\"562\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2f5\/36c\/e79\/2f536ce798db9c900faa9bc4186d4213.png\"\/><figcaption><\/figcaption><\/figure>\n<p>3. \u0414\u0430\u0439\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0443, \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00abCreate workspace\u00bb.<\/p>\n<p>4. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b <a href=\"http:\/\/backends.tf\"><strong>backends.tf<\/strong><\/a>, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0431\u044d\u043a\u0435\u043d\u0434\u0430.<\/p>\n<p>5. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0440\u0435\u0436\u0438\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u00abExecution Mode\u00bb), \u043d\u0430\u0436\u0430\u0432 \u00abRemote\u00bb \u0438 \u0432\u044b\u0431\u0440\u0430\u0432 \u00ab<strong>Local<\/strong>\u00bb:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/792\/102\/4fa\/7921024fa25874d8d5ad73624c7a8856.png\" width=\"936\" height=\"84\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/792\/102\/4fa\/7921024fa25874d8d5ad73624c7a8856.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 Terraform Cloud Token<\/h3>\n<p>1. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00ab<strong>User settings<\/strong>\u00bb, \u0430 \u0437\u0430\u0442\u0435\u043c \u00ab<strong>Tokens<\/strong>\u00bb.<\/p>\n<p>2. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Create an API token<\/strong>\u00bb.<\/p>\n<p>3. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0435\u0433\u043e \u0432 \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.\u00a0<\/p>\n<p>4. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0443 Cloud9 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>terraform login<\/code>.<\/p>\n<p>5. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u00ab<em>Yes<\/em>\u00bb, \u0437\u0430\u0442\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0442\u043e\u043a\u0435\u043d Terraform Cloud.<\/p>\n<p>6. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>terraform init<\/code><\/p>\n<p>\u042d\u0442\u043e \u0441\u0432\u044f\u0436\u0435\u0442 \u043a\u043e\u0434 Terraform \u0441 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e Terraform Cloud, \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f Terraform Cloud. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u044d\u0442\u043e \u0434\u0430\u0441\u0442 Jenkins \u0434\u043e\u0441\u0442\u0443\u043f \u043a Terraform Cloud \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<h3>Terraform<\/h3>\n<p>\u042d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a HashiCorp (HCL). HCL Terraform \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0432\u044b\u0443\u0447\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u044f\u0437\u044b\u043a \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0438 \u044f\u0437\u044b\u043a \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445. HCL \u2014 \u044d\u0442\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u0433\u0434\u0435 \u0432\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b.\u00a0<\/p>\n<h4>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.tf<\/h4>\n<p>1. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>access_ip<\/strong> \u043d\u0430 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 IP-\u0430\u0434\u0440\u0435\u0441 CIDR.<\/p>\n<p>2. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>cloud9_ip<\/strong> \u043d\u0430 IP-\u0430\u0434\u0440\u0435\u0441 Cloud9 CIDR.<\/p>\n<h4>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0444\u0430\u0439\u043b\u044b tfvars<\/h4>\n<p>1. \u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>key_name<\/strong> \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 <strong>main.tfvars<\/strong> \u0438 <strong>dev.tfvars<\/strong>, \u0443\u043a\u0430\u0437\u0430\u0432 \u0438\u043c\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/p>\n<p>2. \u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>public_key_path<\/strong> \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 <strong>main.tfvars<\/strong> \u0438 <strong>dev.tfvars<\/strong>, \u0443\u043a\u0430\u0437\u0430\u0432 \u0438\u043c\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/p>\n<h3>Terraform Code<\/h3>\n<p>\u041a\u043e\u0434 Terraform \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 <a href=\"https:\/\/github.com\/troy-ingram\/terraform-ansible-jenkins\"><u>\u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/u><\/a>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0451 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<h4>Data Source\u00a0<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <a href=\"https:\/\/www.terraform.io\/language\/data-sources\"><strong><u>Data Source<\/u><\/strong><\/a> \u0434\u043b\u044f AWS Availability Zones, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0435 AZs, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0432 Region, \u0433\u0434\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <a href=\"https:\/\/www.terraform.io\/language\/values\/locals\"><strong><u>Local Value<\/u><\/strong><\/a> \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438\u043c\u0451\u043d \u0434\u043b\u044f AZs, \u0430 \u0437\u0430\u0442\u0435\u043c \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<strong> <\/strong><a href=\"https:\/\/www.terraform.io\/language\/functions\/length\"><strong><u>Length<\/u><\/strong><\/a> \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0447\u0438\u0441\u043b\u0430 AZs.\u00a0 \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 <strong>cidr_block<\/strong> \u0438 <strong>availability_zones<\/strong>, \u0430 \u043d\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430.\u00a0<\/p>\n<pre><code>locals {   azs = data.aws_availability_zones.available.names }  data \"aws_availability_zones\" \"available\" {}  resource \"aws_subnet\" \"public_subnet\" {   count                   = length(local.azs)   vpc_id                  = aws_vpc.vpc.id   cidr_block              = var.public_cidr[count.index]   map_public_ip_on_launch = true   availability_zone       = local.azs[count.index]     tags = {     Name = \"docker-public\"   } } view raw<\/code><\/pre>\n<p>Data Source \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 AWS AMI IDs \u0432 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c Region. \u042d\u0442\u043e \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0436\u0451\u0441\u0442\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f AMI ID \u0438\u043b\u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 AMIs \u0438 Regions. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a <strong>ami<\/strong> \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 Ubuntu AMI.<\/p>\n<pre><code>data \"aws_ami\" \"ubuntu\" {   most_recent = true    owners = [\"099720109477\"]    filter {     name   = \"name\"     values = [\"ubuntu\/images\/hvm-ssd\/ubuntu-focal-20.04-amd64-server-*\"]   } }  resource \"aws_instance\" \"web\" {   count                  = var.instance_count   ami                    = data.aws_ami.ubuntu.id   instance_type          = \"t2.micro\"   vpc_security_group_ids = [aws_security_group.sg.id]   subnet_id              = aws_subnet.public_subnet[count.index].id   key_name               = aws_key_pair.docker_auth.id    tags = {     Name = \"docker-instance\"   }<\/code><\/pre>\n<h3>Ansible<\/h3>\n<p>\u0422\u043e, \u0447\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible Playbook. \u0412 Ansible Playbooks \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f YAML, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043b\u0435\u0433\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e\u043c \u044f\u0437\u044b\u043a\u043e\u0432. \u0421 Ansible \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c \u0438\u043d\u0432\u0435\u043d\u0442\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u043e\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c. \u042d\u0442\u0438 \u0445\u043e\u0441\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0438\u043b\u0438 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438.\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/d7b\/08b\/dc3\/d7b08bdc303ed4ce9ab32f79043a66ce.jpg\" width=\"780\" height=\"100\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d7b\/08b\/dc3\/d7b08bdc303ed4ce9ab32f79043a66ce.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p><a href=\"https:\/\/slurm.club\/3GQCPCC\"><u>\u00abAnsible: Infrastructure as Code\u00bb<\/u><\/a><\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 Ansible<\/h4>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0435 Cloud9, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Ansible:<\/p>\n<pre><code>sudo apt update &amp;&amp; sudo apt install software-properties-common &amp;&amp; sudo add-apt-repository --yes --update ppa:ansible\/ansible &amp;&amp; sudo apt install ansible<\/code><\/pre>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 Ansible Hosts<\/h4>\n<p>1. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <strong>sudo vim \/etc\/ansible\/hosts<\/strong><\/p>\n<p>2. \u0412\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code>[hosts] localhost [hosts:vars] ansible_connection=local ansible_python_interpreter=\/usr\/bin\/python3<\/code><\/pre>\n<p>3. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0439\u0434\u0438\u0442\u0435.\u00a0<\/p>\n<h4>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a \u043a\u043b\u044e\u0447\u0430 ECDSA, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <strong>ansible.cfg<\/strong>.<\/p>\n<p>1. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>sudo vim \/etc\/ansible\/ansible.cfg<\/code><\/p>\n<p>2. \u0423\u0434\u0430\u043b\u0438\u0442\u0435 <em>\u00ab#\u00bb<\/em> \u0434\u043b\u044f <strong>host_key_checking = False<\/strong><\/p>\n<p>3. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0439\u0434\u0438\u0442\u0435.\u00a0<\/p>\n<h4>Ansible Playbook: docker.yml<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Docker \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <strong>docker.yml<\/strong> Ansible Playbook. Playbook \u0440\u0430\u0437\u0431\u0438\u0442 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <strong>ansible.builtin.apt <\/strong>\u0438\u043b\u0438 <strong>apt<\/strong>. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0445\u043e\u0441\u0442 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <strong>main<\/strong>, \u0430 \u043d\u0435 \u043d\u0430 <strong>local<\/strong>.<\/p>\n<pre><code>--- - name: Install Docker   hosts: main   become: yes      tasks:     - name: Update apt cache       apt: update_cache=yes cache_valid_time=3600      - name: Upgrade all apt packages       apt: upgrade=dist      - name: Install dependencies       apt:         name: \"{{ packages }}\"         state: present         update_cache: yes       vars:         packages:         - apt-transport-https         - ca-certificates         - curl         - software-properties-common         - gnupg-agent            - name: Add an apt signing key for Docker       apt_key:         url: https:\/\/download.docker.com\/linux\/ubuntu\/gpg         state: present      - name: Add apt repository for stable version       apt_repository:         repo: deb [arch=amd64] https:\/\/download.docker.com\/linux\/ubuntu focal stable         state: present      - name: Install Docker       apt:         name: \"{{ packages }}\"         state: present         update_cache: yes       vars:         packages:         - docker-ce         - docker-ce-cli          - containerd.io<\/code><\/pre>\n<h3>Jenkins\u00a0<\/h3>\n<p>Jenkins Pipeline \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u044b \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 Jenkins \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 Jenkinsfile. Jenkinsfile \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u0438\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u044b\u043c. \u041e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0448\u0430\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d.<\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 Ansible \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Jenkins<\/h4>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Jenkins \u043d\u0430 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 Cloud9, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 Ansible.<\/p>\n<p>1. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>ansible-playbook playbooks\/jenkins.yml<\/code><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f25\/975\/c5a\/f25975c5ac73ca7a40e54f805467deb0.png\" width=\"936\" height=\"382\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f25\/975\/c5a\/f25975c5ac73ca7a40e54f805467deb0.png\"\/><figcaption><\/figcaption><\/figure>\n<h4>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u043e\u0440\u0442 8080<\/h4>\n<p>1. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a Cloud9 Security Group \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 AWS.<\/p>\n<p>2. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u043e\u0440\u0442 <strong>8080<\/strong> \u043d\u0430 <strong>0.0.0.0\/0<\/strong>. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 Jenkins, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u043c\u0441\u044f \u043f\u043e\u0437\u0436\u0435 \u0441 GitHub Webhook.\u00a0<\/p>\n<p>3. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 P-\u0430\u0434\u0440\u0435\u0441\u0443 Cloud9 (Cloud9 Public IP). 8080 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/492\/cf7\/632\/492cf76322f36bce934e1d40cbd08d32.png\" width=\"936\" height=\"506\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/492\/cf7\/632\/492cf76322f36bce934e1d40cbd08d32.png\"\/><figcaption><\/figcaption><\/figure>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 Jenkins<\/h4>\n<p>1. \u0421\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>sudo cat \/var\/lib\/jenkins\/secrets\/initialAdminPassword<\/code>.<\/p>\n<p>2. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043f\u043e\u043b\u0435 \u00abUnlock Jenkins\u00bb \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Continue<\/strong>\u00bb.<\/p>\n<p>3. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Install suggested plugin<\/strong>s\u00bb (\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u044b).<\/p>\n<p>4. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a Jenkins.<\/p>\n<p>5. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Manage Jenkins<\/strong>\u00bb > \u00ab<strong>Manage Plugins<\/strong>\u00bb.<\/p>\n<p>6. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00ab<strong>Available<\/strong>\u00bb.<\/p>\n<p>7. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u00ab<strong>Ansible<\/strong>\u00bb \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<p>8. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Manage Plugins<\/strong>\u00bb > \u00ab<strong>Available<\/strong>\u00bb > \u00ab<strong>Pipeline: AWS Steps<\/strong>\u00bb \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<h3>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 Jenkins<\/h3>\n<h4>GitHub App<\/h4>\n<p>1. \u0412 GitHub \u0449\u0451\u043b\u043a\u043d\u0438\u0442\u0435 \u043d\u0430 \u0437\u043d\u0430\u0447\u043e\u043a \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00ab<strong>Settings<\/strong>\u00bb.<\/p>\n<p>2. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Developer settings<\/strong>\u00bb \u0432\u043d\u0438\u0437\u0443 \u043b\u0435\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438.<\/p>\n<p>3. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>GitHub Apps<\/strong>\u00bb, \u0430 \u0437\u0430\u0442\u0435\u043c \u2014 \u00ab<strong>New GitHub App<\/strong>\u00bb.<\/p>\n<p>4. \u0421\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u00ab<strong>Creating a GitHub App<\/strong>\u00bb \u0432 <a href=\"https:\/\/github.com\/jenkinsci\/github-branch-source-plugin\/blob\/master\/docs\/github-app.adoc\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 GitHub<\/u><\/a>.<\/p>\n<p>5. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e <strong>\u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0435\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 Cloud9 (\u044d\u0442\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0432\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043d\u0435 \u0437\u0430\u043a\u043e\u043c\u043c\u0438\u0442\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u043f\u043e\u0437\u0436\u0435).<\/p>\n<p>6. \u041d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435:<\/p>\n<pre><code>openssl pkcs8 -topk8 -inform PEM -outform PEM -in [key-in-your-downloads-folder-name].pem -out converted-github-app.pem -nocrypt<\/code><\/pre>\n<p>7. \u042d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0444\u0430\u0439\u043b \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <strong>convert-github-app.pem<\/strong>, \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0439 \u0441 Jenkins.<\/p>\n<p>8. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a Jenkins \u2014 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Manage Jenkins<\/strong>\u00bb> \u00ab<strong>Manage Credentials<\/strong>\u00bb.<\/p>\n<p>9. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Jenkins<\/strong>\u00bb:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4cd\/203\/753\/4cd20375302816bc9fc3472f0bd16704.png\" width=\"702\" height=\"472\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4cd\/203\/753\/4cd20375302816bc9fc3472f0bd16704.png\"\/><figcaption><\/figcaption><\/figure>\n<p>10. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Global credentials<\/strong>\u00bb (\u0431\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439).<\/p>\n<p>11. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Add Credentials<\/strong>\u00bb:<\/p>\n<ul>\n<li>\n<p><strong>Kind<\/strong> = \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f GitHub;<\/p>\n<\/li>\n<li>\n<p><strong>ID<\/strong> = [\u0438\u043c\u044f];<\/p>\n<\/li>\n<li>\n<p><strong>Description<\/strong> = \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f GitHub<\/p>\n<\/li>\n<li>\n<p><strong>App ID<\/strong> (\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f) = \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 GitHub: Settings > Developer settings > GitHub Apps > [\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f];\u00a0<\/p>\n<\/li>\n<li>\n<p><strong>Key<\/strong> = \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u043d\u0435\u0435 \u043a\u043b\u044e\u0447\u0430 \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab\u041e\u041a\u00bb.<\/p>\n<\/li>\n<\/ul>\n<p>12. \u0412\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u043a \u0441\u0432\u043e\u0435\u043c\u0443 <strong>GitHub App<\/strong> \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c95\/896\/bc7\/c95896bc72af57a1abfa076da9b6b9d6.png\" width=\"936\" height=\"354\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c95\/896\/bc7\/c95896bc72af57a1abfa076da9b6b9d6.png\"\/><figcaption><\/figcaption><\/figure>\n<p>13. \u0412\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u0432 Jenkins \u0438 \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043d\u0430 \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f GitHub. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Update<\/strong>\u00bb (\u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c), \u0430 \u0437\u0430\u0442\u0435\u043c \u00ab<strong>Test Connection<\/strong>\u00bb (\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435), \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<h4>\u0423\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 Terraform Cloud\u00a0<\/h4>\n<p>1. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 Terraform Cloud, \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>cat \/home\/ubuntu\/.terraform.d\/credentials.tfrc.json<\/code><\/p>\n<p>2. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b, \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435.<\/p>\n<p>3. \u0412\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u043a Jenkins \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u044b\u0435 \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p><strong>Kind<\/strong> = Secret file;<\/p>\n<\/li>\n<li>\n<p><strong>File<\/strong> = \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438;<\/p>\n<\/li>\n<li>\n<p><strong>ID<\/strong> = tf-creds<\/p>\n<\/li>\n<li>\n<p><strong>Description<\/strong> = \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 Terraform Cloud.<\/p>\n<\/li>\n<\/ul>\n<h4>SSH Key<\/h4>\n<p>1. \u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>cat \/home\/ubuntu\/.ssh\/[key name]<\/code><\/p>\n<p>2. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>3. \u0412\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u043a Jenkins \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u044b\u0435 \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p><strong>Kind<\/strong> = SSH Username with private key (\u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f SSH \u0441 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c);<\/p>\n<\/li>\n<li>\n<p><strong>ID<\/strong> = ec2-ssh-key;<\/p>\n<\/li>\n<li>\n<p><strong>Description<\/strong> = ssh key for ec2 instances;<\/p>\n<\/li>\n<li>\n<p><strong>Username<\/strong> = ubuntu;<\/p>\n<\/li>\n<li>\n<p><strong>Private Key<\/strong> = \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00abEnter directly\u00bb, \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>4. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00abOK\u00bb.<\/p>\n<h4>GitHub Webhook<\/h4>\n<p>1. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044e GitHub \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Settings<\/strong>\u00bb:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ee6\/5e3\/03e\/ee65e303e0ce9f5f0ea0d9bb80b808ef.png\" width=\"936\" height=\"106\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ee6\/5e3\/03e\/ee65e303e0ce9f5f0ea0d9bb80b808ef.png\"\/><figcaption><\/figcaption><\/figure>\n<p>2. \u041a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u00ab<strong>Webhooks<\/strong>\u00bb;<\/p>\n<p>3. \u041a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u00ab<strong>Add webhook<\/strong>\u00bb:<\/p>\n<p>\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/88f\/47d\/b18\/88f47db18866e16ab67bd7c1f81bfd50.png\" width=\"936\" height=\"284\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/88f\/47d\/b18\/88f47db18866e16ab67bd7c1f81bfd50.png\"\/><figcaption><\/figcaption><\/figure>\n<p>4. <strong>Payload URL<\/strong> = [jenkins url]\/github-webhook\/<\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \/ \u0432 \u043a\u043e\u043d\u0446\u0435.<\/em><\/p>\n<p>5. <strong>\u0422\u0438\u043f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430<\/strong> = application\/json.<\/p>\n<p>6. <strong>Which events would you like to trigger this webhook<\/strong> (\u043a\u0430\u043a\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u0432\u0435\u0431-\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430)? = push-\u0441\u043e\u0431\u044b\u0442\u0438\u0435.<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 Jenkins \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d<\/h4>\n<p>1. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a \u043f\u0430\u043d\u0435\u043b\u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 (Jenkins Dashboard) \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>New Item<\/strong>\u00bb.<\/p>\n<p>2. \u041d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00ab<strong>Multi-Branch Pipeline<\/strong>\u00bb. \u0417\u0430\u0442\u0435\u043c \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>OK<\/strong>\u00bb:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2fa\/fa6\/359\/2fafa6359f02f696891a2ecf6d22cd1c.png\" width=\"936\" height=\"486\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2fa\/fa6\/359\/2fafa6359f02f696891a2ecf6d22cd1c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>3. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d:<\/p>\n<ul>\n<li>\n<p><strong>Display Name<\/strong> = [\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430];<\/p>\n<\/li>\n<li>\n<p><strong>Branches Sources<\/strong> (\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0432\u0435\u0442\u043e\u043a) = GitHub;<\/p>\n<\/li>\n<li>\n<p><strong>GitHub Credentials<\/strong> = \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f GitHub;\u00a0<\/p>\n<\/li>\n<li>\n<p><strong>Repository HTTPS URL<\/strong> = [\u0438\u043c\u044f \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f].git<\/p>\n<\/li>\n<\/ul>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u044b \u043f\u043e\u043f\u0430\u0434\u0451\u0442\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u2014 Scan Repository Log. \u041e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435 SUCCESS \u0432 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0443.<\/em><\/p>\n<h4>Jenkinsfile<\/h4>\n<p>Jenkins \u043d\u0443\u0436\u0435\u043d <a href=\"https:\/\/www.jenkins.io\/doc\/book\/pipeline\/jenkinsfile\/\"><u>Jenkinsfile<\/u><\/a> \u0432 \u043a\u043e\u0440\u043d\u0435 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f Jenkins Pipeline. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d Jenkinsfile, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435:<\/p>\n<pre><code>pipeline {   agent any   environment {     TF_IN_AUTOMATION = 'true'     TF_CLI_CONFIG_FILE = credentials('tf-creds')     AWS_SHARED_CREDENTIALS_FILE='\/home\/ubuntu\/.aws\/credentials'   }   stages {     stage('Init') {       steps {         sh 'ls'         sh 'cat $BRANCH_NAME.tfvars'         sh 'terraform init -no-color'       }     }     stage('Plan') {       steps {         sh 'terraform plan -no-color -var-file=\"$BRANCH_NAME.tfvars\"'       }     }     stage('Validate Apply') {       when {         beforeInput true         branch \"dev\"       }       input {         message \"Do you want to apply this plan?\"         ok \"Apply plan\"       }     steps {         echo 'Apply Accepted'       }     }     stage('Apply') {       steps {         sh 'terraform apply -auto-approve -no-color -var-file=\"$BRANCH_NAME.tfvars\"'       }     }     stage('Inventory') {       steps {         sh '''printf \\\\           \"\\\\n$(terraform output -json instance_ips | jq -r \\'.[]\\')\" \\\\           >> aws_hosts'''       }     }     stage('EC2 Wait') {       steps {         sh '''aws ec2 wait instance-status-ok \\\\           --instance-ids $(terraform output -json instance_ids | jq -r \\'.[]\\') \\\\           --region us-east-1'''       }     }     stage('Validate Ansible') {       when {         beforeInput true         branch \"dev\"       }       input {         message \"Do you want to run Ansible?\"         ok \"Run Ansible\"       }       steps {         echo 'Ansible Approved'           }         }     stage('Ansible') {       steps {         ansiblePlaybook(credentialsId: 'ec2-ssh-key', inventory: 'aws_hosts', playbook: 'playbooks\/docker.yml')       }     }     stage('Validate Destroy') {       input {         message \"Do you want to destroy?\"         ok \"Destroy\"         }       steps {         echo 'Destroy Approved'       }     }     stage('Destroy') {       steps {         sh 'terraform destroy -auto-approve -no-color -var-file=\"$BRANCH_NAME.tfvars\"'       }     }   }   post {     success {       echo 'Success!'     }     failure {       sh 'terraform destroy -auto-approve -no-color -var-file=\"$BRANCH_NAME.tfvars\"'     }     aborted {       sh 'terraform destroy -auto-approve -no-color -var-file=\"$BRANCH_NAME.tfvars\"'     }   } } view raw<\/code><\/pre>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u043e \u0432\u0441\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u044d\u0442\u0438\u043c \u0444\u0430\u0439\u043b\u043e\u043c, \u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h4>Environment $BRANCH_NAME variable<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u0432\u0435\u0442\u043a\u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 Jenkinsfile. \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0438 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0432\u0435\u0442\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043b\u0430 GitHub Webhook. \u041d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u043e \u0444\u0430\u0439\u043b <strong>main.tfvars<\/strong>, \u043b\u0438\u0431\u043e \u0444\u0430\u0439\u043b <strong>dev.tfvars<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0448\u0435\u0442 \u043d\u0430\u0448 \u0444\u0430\u0439\u043b <a href=\"http:\/\/variable.tf\">variable.tf<\/a> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/45c\/a47\/566\/45ca475660eac1a935d795e56336c492.png\" width=\"936\" height=\"470\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/45c\/a47\/566\/45ca475660eac1a935d795e56336c492.png\"\/><figcaption><\/figcaption><\/figure>\n<h4>Conditional &amp; Input<\/h4>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 <strong>when<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c <strong>input<\/strong>, \u0435\u0441\u043b\u0438 \u0432\u0435\u0442\u0432\u044c \u0440\u0430\u0432\u043d\u0430 <strong>dev<\/strong>. \u0415\u0441\u043b\u0438 \u0432\u0435\u0442\u0432\u044c \u043d\u0435 \u0440\u0430\u0432\u043d\u0430 <strong>dev<\/strong>, \u0442\u043e input \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p><strong>Input<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0430 \u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430 <strong>Apply<\/strong> (\u043e\u0434\u043e\u0431\u0440\u0438\u0442\u044c) \u043f\u043b\u0430\u043d \u0438\u043b\u0438 <strong>Abort<\/strong> (\u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c).\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fb8\/2ac\/95b\/fb82ac95be8ef58cc47306af77b7357c.png\" width=\"654\" height=\"378\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fb8\/2ac\/95b\/fb82ac95be8ef58cc47306af77b7357c.png\"\/><figcaption><\/figcaption><\/figure>\n<h4>EC2 Wait<\/h4>\n<p>\u041d\u0430 \u044d\u0442\u0430\u043f\u0430\u0445 <strong>Inventory<\/strong> \u0438 <strong>EC2 Wait<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 Terraform \u0438 jq \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f <strong>instance ids<\/strong> \u0438 <strong>instance ips<\/strong>. \u042d\u0442\u0430\u043f <strong>Inventory<\/strong> \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 <strong>instance ips<\/strong>, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043a\u043e\u0434\u0430 Terraform, \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u0445 \u0432 \u0444\u0430\u0439\u043b <strong>aws_hosts<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Ansible.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4ab\/9a5\/8cc\/4ab9a58cc07762ad5591f2c7782b483c.png\" width=\"936\" height=\"402\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4ab\/9a5\/8cc\/4ab9a58cc07762ad5591f2c7782b483c.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435<\/h3>\n<h4>\u0412\u0435\u0442\u043a\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/h4>\n<p>1. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 <strong>\u0432\u0435\u0442\u043a\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/strong>, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>git checkout -b dev<\/code><\/p>\n<p>2. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>git add.<\/code><\/p>\n<p>3. \u0417\u0430\u043a\u043e\u043c\u043c\u0438\u0442\u044c\u0442\u0435 \u0444\u0430\u0439\u043b\u044b, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>git commit -m \"initial commit\"<\/code><\/p>\n<p>4. \u041e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 \u0441\u0432\u043e\u0439 \u043a\u043e\u0434 \u0432 <strong>\u0432\u0435\u0442\u043a\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/strong> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>git push -u origin dev<\/code> \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u0432 GitHub.<\/p>\n<p>5. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a \u043f\u0430\u043d\u0435\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 Jenkins.<\/p>\n<p>6. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u00ab<strong>Build Executor Status<\/strong>\u00bb, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c \u0432 \u043b\u0435\u0432\u043e\u043c \u043d\u0438\u0436\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/184\/50b\/6fa\/18450b6faf68dd0b9c6a6d7aeb60e2dd.png\" width=\"484\" height=\"222\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/184\/50b\/6fa\/18450b6faf68dd0b9c6a6d7aeb60e2dd.png\"\/><figcaption><\/figcaption><\/figure>\n<p>7. \u041d\u0430\u0432\u0435\u0434\u0438\u0442\u0435 \u043a\u0443\u0440\u0441\u043e\u0440 \u043c\u044b\u0448\u0438 \u043d\u0430 \u00ab<strong>Validate Apply step<\/strong>\u00bb, \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Apply plan<\/strong>\u00bb:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0a2\/6e2\/199\/0a26e2199ebe98fe1297f2473122b539.png\" width=\"936\" height=\"342\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0a2\/6e2\/199\/0a26e2199ebe98fe1297f2473122b539.png\"\/><figcaption><\/figcaption><\/figure>\n<p>8. \u041f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442 \u043a\u043e\u0434 Terraform, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u044d\u0442\u0430\u043f \u0438\u043d\u0432\u0435\u043d\u0442\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0434\u043e\u0436\u0434\u0435\u0442\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 EC2, \u0447\u0442\u043e\u0431\u044b Ansible \u043d\u0435 \u0432\u044b\u0434\u0430\u043b \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443.<\/p>\n<p>9. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u0448\u0430\u0433\u0430 \u00ab<strong>Validate Ansible<\/strong>\u00bb, \u0435\u0449\u0451 \u0440\u0430\u0437 \u043d\u0430\u0432\u0435\u0434\u0438\u0442\u0435 \u043a\u0443\u0440\u0441\u043e\u0440 \u043c\u044b\u0448\u0438 \u043d\u0430 \u0448\u0430\u0433 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00ab<strong>Run Ansible<\/strong>\u00bb.<\/p>\n<p>10. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0449\u0435\u043b\u043a\u043d\u0438\u0442\u0435 \u0437\u0435\u043b\u0435\u043d\u0443\u044e \u0433\u0430\u043b\u043e\u0447\u043a\u0443 \u0440\u044f\u0434\u043e\u043c \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u0441\u0431\u043e\u0440\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u0447\u0442\u043e Ansible \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0432\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0432\u0432\u0435\u0440\u0445 \u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<p>11. \u041f\u043e\u043a\u0430 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043d\u0430 \u0448\u0430\u0433\u0435 \u00abValidate Destroy\u00bb, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0441, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e Docker \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u041f\u0440\u043e\u0441\u043a\u0440\u043e\u043b\u044c\u0442\u0435 \u0432\u0432\u0435\u0440\u0445, \u043d\u0430\u0439\u0434\u0438\u0442\u0435 <strong>instance_ips<\/strong> \u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 IP-\u0430\u0434\u0440\u0435\u0441 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430.<\/p>\n<p>12. \u0412\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u043a \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0443 Cloud9 \u0438 \u0432\u043e\u0439\u0434\u0438\u0442\u0435 \u0432 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u043f\u043e SSH, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0432\u043e\u0439 SSH-\u043a\u043b\u044e\u0447. <code>ssh -i \/home\/ubuntu\/.ssh\/[\u0438\u043c\u044f \u043a\u043b\u044e\u0447\u0430] ubuntu@[IP-\u0430\u0434\u0440\u0435\u0441 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430]<\/code><\/p>\n<p>13. \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>docker \u2013version<\/code><\/p>\n<p>14. \u0412\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u043a \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0443 Jenkins \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00ab<strong>Destroy<\/strong>\u00bb.<\/p>\n<h4>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0432\u0435\u0442\u043a\u0430<\/h4>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0435\u0442\u043a\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438, \u043a\u043e\u0436 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0432\u0435\u0442\u043a\u0443.<\/p>\n<p>1. \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u0441\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0432\u0435\u0442\u043a\u0443 (<strong>main branch<\/strong>), \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>git checkout main<\/code><\/p>\n<p>2. \u0421\u043c\u0435\u0440\u0436\u0438\u0442\u0435 \u0432\u0435\u0442\u043a\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 (<strong>dev branch<\/strong>), \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>git merge dev<\/code><\/p>\n<p>3. \u041e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 \u043a\u043e\u0434 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u0443\u044e, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>git push -u origin main<\/code> \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u043d\u0430 GitHub.<\/p>\n<p>4. \u0412\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u043a Jenkins \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e \u0432\u0435\u0442\u043a\u0443 \u0434\u043b\u044f <strong>main<\/strong>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/034\/656\/4d0\/0346564d0b42c4e1b76a635f95103fc7.png\" width=\"936\" height=\"252\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/034\/656\/4d0\/0346564d0b42c4e1b76a635f95103fc7.png\"\/><figcaption><\/figcaption><\/figure>\n<p>5. \u041a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043d\u0430 \u00ab<strong>main<\/strong>\u00bb, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u043e\u0434 \u0443\u0436\u0435 \u0431\u044b\u043b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, Jenkinsfile \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u044d\u0442\u0430\u043f\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u041f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0439\u0442\u0438 \u0432\u0435\u0441\u044c \u043f\u0443\u0442\u044c \u0434\u043e \u044d\u0442\u0430\u043f\u0430 <strong>Validate Destroy<\/strong>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9d4\/91e\/4f9\/9d491e4f952f4b75ae1f54527eb32f47.png\" width=\"936\" height=\"286\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9d4\/91e\/4f9\/9d491e4f952f4b75ae1f54527eb32f47.png\"\/><figcaption><\/figcaption><\/figure>\n<p>6. \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e Docker \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0439\u0442\u0435\u0441\u044c \u043a \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0443, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u00ab<strong>Destroy<\/strong>\u00bb.<\/p>\n<h4>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a \u0444\u0430\u0439\u043b\u0430\u043c dev.tfvars \u0438 main.tfvars, \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 \u043d\u0430 \u0434\u0432\u0430 \u0438\u043b\u0438 \u0442\u0440\u0438. \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432.<\/p>\n<h3>\u0422\u0440\u0430\u0431\u043b\u0448\u0443\u0442\u0438\u043d\u0433<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043e\u0442\u043a\u043b\u043e\u043d\u0438\u0442\u0435\u0441\u044c \u043e\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u0448\u0430\u0433\u043e\u0432, \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c IDE \u043f\u043e\u0432\u0435\u0440\u0445 Cloud9 \u0438\u043b\u0438 \u0432\u043e\u0437\u044c\u043c\u0451\u0442\u0435 Amazon Linux \u0432\u043c\u0435\u0441\u0442\u043e Ubuntu. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u044b \u0441\u0442\u0440\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c, \u043d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0441\u0432\u043e\u0438\u043c \u0448\u0430\u0433\u0430\u043c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0432\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043b\u043e\u0433\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/1c4\/a34\/093\/1c4a34093c0d3f0efdb9b356e7cb6b38.jpg\" width=\"780\" height=\"100\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1c4\/a34\/093\/1c4a34093c0d3f0efdb9b356e7cb6b38.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p><a href=\"https:\/\/slurm.club\/3Wofa2a\"><u>\u00abDevOps\u00a0Tools\u00a0\u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432\u00bb<\/u><\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><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\/company\/southbridge\/blog\/711398\/\"> https:\/\/habr.com\/ru\/company\/southbridge\/blog\/711398\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Jenkins CI\/CD Pipeline \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b AWS \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Terraform \u0438 Ansible. \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c Terraform \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043f\u043e \u043c\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u0438 \u0448\u0430\u0433\u0438 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438. \u041a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 \u043a\u043e\u0434 Terraform, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u0440\u0435\u0434\u0443 AWS \u0441 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u043f\u043e\u0434\u0441\u0435\u0442\u044f\u043c\u0438 \u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430\u043c\u0438 EC2 \u0441 Ansible Playbook. \u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u0434 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 GitHub, GitHub Webhook \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 Jenkins CI\/CD Pipeline, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0443\u0434\u0430 \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u0434 \u2014 \u0432 \u0432\u0435\u0442\u043a\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0412\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f<\/h3>\n<ul>\n<li>\n<p>\u0430\u043a\u043a\u0430\u0443\u043d\u0442 <a href=\"https:\/\/github.com\/\"><u>GitHub<\/u><\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.aws.amazon.com\/cli\/latest\/userguide\/install-cliv2.html\"><u>AWS CLI<\/u><\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/learn.hashicorp.com\/tutorials\/terraform\/install-cli\"><u>Terraform<\/u><\/a>;<\/p>\n<\/li>\n<li>\n<p>\u0430\u043a\u043a\u0430\u0443\u043d\u0442 <a href=\"https:\/\/aws.amazon.com\/premiumsupport\/knowledge-center\/create-and-activate-aws-account\/\"><u>AWS<\/u><\/a>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c AWS \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>AWS Cloud9 (\u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e IDE, \u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0448\u0430\u0433\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f);<\/p>\n<\/li>\n<li>\n<p>\u0430\u043a\u043a\u0430\u0443\u043d\u0442 <a href=\"https:\/\/app.terraform.io\/signup\/account?utm_source=cloud_landing&amp;utm_content=offers_tfc\"><u>Terraform Cloud<\/u><\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Getting-Started-Installing-Git\"><u>Git<\/u><\/a>.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0441\u0440\u0435\u0434\u0443<\/h3>\n<h4>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u0440\u0435\u0434\u0443 Amazon Cloud9.\u00a0<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043a\u0440\u043e\u043c\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u00abPlatform section\u00bb. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 Ubuntu Server 18.04 LTS.<\/p>\n<h4>\u041d\u0430\u0437\u043d\u0430\u0447\u044c\u0442\u0435 Elastic IP address\u00a0<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u043d\u0441\u0442\u0430\u043d\u0441 Cloud9 \u043d\u0435 \u043c\u0435\u043d\u044f\u043b \u0441\u0432\u043e\u0439 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 IP-\u0430\u0434\u0440\u0435\u0441 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438 \u0441\u043d\u043e\u0432\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u0437\u043d\u0430\u0447\u044c\u0442\u0435 \u0435\u043c\u0443 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 IP-\u0430\u0434\u0440\u0435\u0441. \u041f\u043e\u0437\u0436\u0435 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 IP-\u0430\u0434\u0440\u0435\u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 Terraform \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.\u00a0<\/p>\n<p>1. \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 AWS \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a EC2.<\/p>\n<p>2. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00abElastic IPs\u00bb \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u00abNetwork &amp; Security\u00bb.\u00a0<\/p>\n<p>3. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00abAllocate Elastic IP address\u00bb.<\/p>\n<p>4. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00abAllocate\u00bb.\u00a0<\/p>\n<p>5. \u0412 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u043c\u0441\u044f \u0441\u043f\u0438\u0441\u043a\u0435 \u00abAction\u00bb \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00abAssociate Elastic IP Address\u00bb:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>6. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00abCloud9 instance\u00bb > \u00abPrivate IP address\u00bb > \u00abCloud9 private IP address\u00bb. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00abAssociate\u00bb (\u0441\u0432\u044f\u0437\u0430\u0442\u044c).\u00a0<\/p>\n<h4>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 Cloud9<\/h4>\n<p>1. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432 Cloud9 \u0444\u0430\u0439\u043b \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <a href=\"http:\/\/resize.sh\">resize.sh<\/a>.<\/p>\n<p>2. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/morethancertified\/mtc-terraform\/blob\/main\/extras\/resize.sh\"><u>\u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/u><\/a> \u0432 \u0444\u0430\u0439\u043b <a href=\"http:\/\/resize.sh\">resize.sh<\/a>.<\/p>\n<p>3. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>chmod +x resize.sh<\/code><\/p>\n<p>4. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>.\/resize.sh<\/code><\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 SSH-\u043a\u043b\u044e\u0447<\/h4>\n<p>1. \u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>ssh-keygen -t rsa<\/code><\/p>\n<p>2. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0444\u0430\u0439\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d \u043a\u043b\u044e\u0447: <code>\/home\/ubuntu\/.ssh\/[\u0438\u043c\u044f \u043a\u043b\u044e\u0447\u0430]<\/code><\/p>\n<p>3. \u0411\u0435\u0437 passphrase.<\/p>\n<p>4. \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u043a\u043b\u044e\u0447 \u0441\u043e\u0437\u0434\u0430\u043d, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>ls ~\/.ssh<\/code><\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 jq<\/h4>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>sudo apt install jq<\/code><\/p>\n<h4>Fork Repo<\/h4>\n<p><a href=\"https:\/\/github.com\/troy-ingram\/terraform-ansible-jenkins.git\"><u>\u0417\u0434\u0435\u0441\u044c<\/u><\/a> \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u0434, \u0435\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0441\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0433\u043e.\u00a0\u00a0<\/p>\n<h3>Terraform Cloud<\/h3>\n<p><a href=\"https:\/\/cloud.hashicorp.com\/products\/terraform\"><u>Terraform Cloud<\/u><\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c Terraform State (\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 Terraform) \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e, \u0430 \u043d\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e. \u042d\u0442\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<p><em>\u041f\u0440\u0438\u043c., \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430: \u0442\u0430\u043a\u0436\u0435 Terraform State \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 s3 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u2014 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d-\u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/em><\/p>\n<p>1. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u043e\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e.<\/p>\n<p>2. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <strong>CLI-driven workflow<\/strong>:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>3. \u0414\u0430\u0439\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0443, \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00abCreate workspace\u00bb.<\/p>\n<p>4. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b <a href=\"http:\/\/backends.tf\"><strong>backends.tf<\/strong><\/a>, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0431\u044d\u043a\u0435\u043d\u0434\u0430.<\/p>\n<p>5. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0440\u0435\u0436\u0438\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u00abExecution Mode\u00bb), \u043d\u0430\u0436\u0430\u0432 \u00abRemote\u00bb \u0438 \u0432\u044b\u0431\u0440\u0430\u0432 \u00ab<strong>Local<\/strong>\u00bb:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 Terraform Cloud Token<\/h3>\n<p>1. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00ab<strong>User settings<\/strong>\u00bb, \u0430 \u0437\u0430\u0442\u0435\u043c \u00ab<strong>Tokens<\/strong>\u00bb.<\/p>\n<p>2. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Create an API token<\/strong>\u00bb.<\/p>\n<p>3. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0435\u0433\u043e \u0432 \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.\u00a0<\/p>\n<p>4. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0443 Cloud9 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>terraform login<\/code>.<\/p>\n<p>5. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u00ab<em>Yes<\/em>\u00bb, \u0437\u0430\u0442\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0442\u043e\u043a\u0435\u043d Terraform Cloud.<\/p>\n<p>6. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>terraform init<\/code><\/p>\n<p>\u042d\u0442\u043e \u0441\u0432\u044f\u0436\u0435\u0442 \u043a\u043e\u0434 Terraform \u0441 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e Terraform Cloud, \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f Terraform Cloud. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u044d\u0442\u043e \u0434\u0430\u0441\u0442 Jenkins \u0434\u043e\u0441\u0442\u0443\u043f \u043a Terraform Cloud \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<h3>Terraform<\/h3>\n<p>\u042d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a HashiCorp (HCL). HCL Terraform \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0432\u044b\u0443\u0447\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u044f\u0437\u044b\u043a \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0438 \u044f\u0437\u044b\u043a \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445. HCL \u2014 \u044d\u0442\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u0433\u0434\u0435 \u0432\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b.\u00a0<\/p>\n<h4>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.tf<\/h4>\n<p>1. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>access_ip<\/strong> \u043d\u0430 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 IP-\u0430\u0434\u0440\u0435\u0441 CIDR.<\/p>\n<p>2. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>cloud9_ip<\/strong> \u043d\u0430 IP-\u0430\u0434\u0440\u0435\u0441 Cloud9 CIDR.<\/p>\n<h4>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0444\u0430\u0439\u043b\u044b tfvars<\/h4>\n<p>1. \u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>key_name<\/strong> \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 <strong>main.tfvars<\/strong> \u0438 <strong>dev.tfvars<\/strong>, \u0443\u043a\u0430\u0437\u0430\u0432 \u0438\u043c\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/p>\n<p>2. \u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>public_key_path<\/strong> \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 <strong>main.tfvars<\/strong> \u0438 <strong>dev.tfvars<\/strong>, \u0443\u043a\u0430\u0437\u0430\u0432 \u0438\u043c\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/p>\n<h3>Terraform Code<\/h3>\n<p>\u041a\u043e\u0434 Terraform \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 <a href=\"https:\/\/github.com\/troy-ingram\/terraform-ansible-jenkins\"><u>\u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/u><\/a>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0451 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<h4>Data Source\u00a0<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <a href=\"https:\/\/www.terraform.io\/language\/data-sources\"><strong><u>Data Source<\/u><\/strong><\/a> \u0434\u043b\u044f AWS Availability Zones, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0435 AZs, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0432 Region, \u0433\u0434\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <a href=\"https:\/\/www.terraform.io\/language\/values\/locals\"><strong><u>Local Value<\/u><\/strong><\/a> \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438\u043c\u0451\u043d \u0434\u043b\u044f AZs, \u0430 \u0437\u0430\u0442\u0435\u043c \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<strong> <\/strong><a href=\"https:\/\/www.terraform.io\/language\/functions\/length\"><strong><u>Length<\/u><\/strong><\/a> \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0447\u0438\u0441\u043b\u0430 AZs.\u00a0 \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 <strong>cidr_block<\/strong> \u0438 <strong>availability_zones<\/strong>, \u0430 \u043d\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430.\u00a0<\/p>\n<pre><code>locals {   azs = data.aws_availability_zones.available.names }  data \"aws_availability_zones\" \"available\" {}  resource \"aws_subnet\" \"public_subnet\" {   count                   = length(local.azs)   vpc_id                  = aws_vpc.vpc.id   cidr_block              = var.public_cidr[count.index]   map_public_ip_on_launch = true   availability_zone       = local.azs[count.index]     tags = {     Name = \"docker-public\"   } } view raw<\/code><\/pre>\n<p>Data Source \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 AWS AMI IDs \u0432 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c Region. \u042d\u0442\u043e \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0436\u0451\u0441\u0442\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f AMI ID \u0438\u043b\u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 AMIs \u0438 Regions. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a <strong>ami<\/strong> \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 Ubuntu AMI.<\/p>\n<pre><code>data \"aws_ami\" \"ubuntu\" {   most_recent = true    owners = [\"099720109477\"]    filter {     name   = \"name\"     values = [\"ubuntu\/images\/hvm-ssd\/ubuntu-focal-20.04-amd64-server-*\"]   } }  resource \"aws_instance\" \"web\" {   count                  = var.instance_count   ami                    = data.aws_ami.ubuntu.id   instance_type          = \"t2.micro\"   vpc_security_group_ids = [aws_security_group.sg.id]   subnet_id              = aws_subnet.public_subnet[count.index].id   key_name               = aws_key_pair.docker_auth.id    tags = {     Name = \"docker-instance\"   }<\/code><\/pre>\n<h3>Ansible<\/h3>\n<p>\u0422\u043e, \u0447\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible Playbook. \u0412 Ansible Playbooks \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f YAML, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043b\u0435\u0433\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e\u043c \u044f\u0437\u044b\u043a\u043e\u0432. \u0421 Ansible \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c \u0438\u043d\u0432\u0435\u043d\u0442\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u043e\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c. \u042d\u0442\u0438 \u0445\u043e\u0441\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0438\u043b\u0438 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438.\u00a0<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><a href=\"https:\/\/slurm.club\/3GQCPCC\"><u>\u00abAnsible: Infrastructure as Code\u00bb<\/u><\/a><\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 Ansible<\/h4>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0435 Cloud9, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Ansible:<\/p>\n<pre><code>sudo apt update &amp;&amp; sudo apt install software-properties-common &amp;&amp; sudo add-apt-repository --yes --update ppa:ansible\/ansible &amp;&amp; sudo apt install ansible<\/code><\/pre>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 Ansible Hosts<\/h4>\n<p>1. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <strong>sudo vim \/etc\/ansible\/hosts<\/strong><\/p>\n<p>2. \u0412\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code>[hosts] localhost [hosts:vars] ansible_connection=local ansible_python_interpreter=\/usr\/bin\/python3<\/code><\/pre>\n<p>3. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0439\u0434\u0438\u0442\u0435.\u00a0<\/p>\n<h4>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a \u043a\u043b\u044e\u0447\u0430 ECDSA, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <strong>ansible.cfg<\/strong>.<\/p>\n<p>1. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>sudo vim \/etc\/ansible\/ansible.cfg<\/code><\/p>\n<p>2. \u0423\u0434\u0430\u043b\u0438\u0442\u0435 <em>\u00ab#\u00bb<\/em> \u0434\u043b\u044f <strong>host_key_checking = False<\/strong><\/p>\n<p>3. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0439\u0434\u0438\u0442\u0435.\u00a0<\/p>\n<h4>Ansible Playbook: docker.yml<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Docker \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <strong>docker.yml<\/strong> Ansible Playbook. Playbook \u0440\u0430\u0437\u0431\u0438\u0442 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <strong>ansible.builtin.apt <\/strong>\u0438\u043b\u0438 <strong>apt<\/strong>. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0445\u043e\u0441\u0442 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <strong>main<\/strong>, \u0430 \u043d\u0435 \u043d\u0430 <strong>local<\/strong>.<\/p>\n<pre><code>--- - name: Install Docker   hosts: main   become: yes      tasks:     - name: Update apt cache       apt: update_cache=yes cache_valid_time=3600      - name: Upgrade all apt packages       apt: upgrade=dist      - name: Install dependencies       apt:         name: \"{{ packages }}\"         state: present         update_cache: yes       vars:         packages:         - apt-transport-https         - ca-certificates         - curl         - software-properties-common         - gnupg-agent            - name: Add an apt signing key for Docker       apt_key:         url: https:\/\/download.docker.com\/linux\/ubuntu\/gpg         state: present      - name: Add apt repository for stable version       apt_repository:         repo: deb [arch=amd64] https:\/\/download.docker.com\/linux\/ubuntu focal stable         state: present      - name: Install Docker       apt:         name: \"{{ packages }}\"         state: present         update_cache: yes       vars:         packages:         - docker-ce         - docker-ce-cli          - containerd.io<\/code><\/pre>\n<h3>Jenkins\u00a0<\/h3>\n<p>Jenkins Pipeline \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u044b \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 Jenkins \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 Jenkinsfile. Jenkinsfile \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u0438\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u044b\u043c. \u041e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0448\u0430\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d.<\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 Ansible \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Jenkins<\/h4>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Jenkins \u043d\u0430 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 Cloud9, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 Ansible.<\/p>\n<p>1. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>ansible-playbook playbooks\/jenkins.yml<\/code><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h4>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u043e\u0440\u0442 8080<\/h4>\n<p>1. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a Cloud9 Security Group \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 AWS.<\/p>\n<p>2. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u043e\u0440\u0442 <strong>8080<\/strong> \u043d\u0430 <strong>0.0.0.0\/0<\/strong>. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 Jenkins, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u043c\u0441\u044f \u043f\u043e\u0437\u0436\u0435 \u0441 GitHub Webhook.\u00a0<\/p>\n<p>3. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 P-\u0430\u0434\u0440\u0435\u0441\u0443 Cloud9 (Cloud9 Public IP). 8080 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 Jenkins<\/h4>\n<p>1. \u0421\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 <code>sudo cat \/var\/lib\/jenkins\/secrets\/initialAdminPassword<\/code>.<\/p>\n<p>2. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043f\u043e\u043b\u0435 \u00abUnlock Jenkins\u00bb \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Continue<\/strong>\u00bb.<\/p>\n<p>3. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Install suggested plugin<\/strong>s\u00bb (\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u044b).<\/p>\n<p>4. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a Jenkins.<\/p>\n<p>5. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Manage Jenkins<\/strong>\u00bb > \u00ab<strong>Manage Plugins<\/strong>\u00bb.<\/p>\n<p>6. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00ab<strong>Available<\/strong>\u00bb.<\/p>\n<p>7. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u00ab<strong>Ansible<\/strong>\u00bb \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<p>8. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Manage Plugins<\/strong>\u00bb > \u00ab<strong>Available<\/strong>\u00bb > \u00ab<strong>Pipeline: AWS Steps<\/strong>\u00bb \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<h3>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 Jenkins<\/h3>\n<h4>GitHub App<\/h4>\n<p>1. \u0412 GitHub \u0449\u0451\u043b\u043a\u043d\u0438\u0442\u0435 \u043d\u0430 \u0437\u043d\u0430\u0447\u043e\u043a \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00ab<strong>Settings<\/strong>\u00bb.<\/p>\n<p>2. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab<strong>Developer settings<\/strong>\u00bb<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-344133","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344133","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=344133"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344133\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=344133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=344133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=344133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}