{"id":467466,"date":"2025-07-18T21:40:38","date_gmt":"2025-07-18T21:40:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=467466"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=467466","title":{"rendered":"<span>DevOps Tutorials \u2014 Ansible: \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ma\/po\/lv\/mapolvqq4uunxfqoaviv3g9km9y.jpeg\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/ma\/po\/lv\/mapolvqq4uunxfqoaviv3g9km9y.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/ma\/po\/lv\/mapolvqq4uunxfqoaviv3g9km9y.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/> <\/p>\n<p> <\/p>\n<p> <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p> <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u044f \u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e.<\/p>\n<p> <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c Angular+Java \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 Ubuntu Linux \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible.<\/p>\n<p> <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e? \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p><a name=\"habracut\"><\/a> <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0438\u0437 2 \u0447\u0430\u0441\u0442\u0435\u0439:<\/p>\n<p> <\/p>\n<ul>\n<li>\u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u043d\u0430 JavaScript (<a href=\"https:\/\/angular.dev\/\">Angular<\/a>, \u043d\u043e \u044d\u0442\u043e \u043d\u0435\u0432\u0430\u0436\u043d\u043e), \u0441\u0442\u0430\u0442\u0438\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/nodejs.org\/en\">Node.js<\/a> (<a href=\"https:\/\/www.npmjs.com\/package\/http-server\">http-server<\/a>) (\u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/nginx.org\/\">Nginx<\/a>)<\/li>\n<li>\u0431\u044d\u043a\u0435\u043d\u0434 \u043d\u0430 Java (<a href=\"https:\/\/spring.io\/\">Spring<\/a>), \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441 \u043e\u0431\u043b\u0430\u0447\u043d\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 PostgreSQL<\/li>\n<\/ul>\n<p> <\/p>\n<p>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 <a href=\"https:\/\/about.gitlab.com\/\">GitLab<\/a>. \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 (<a href=\"https:\/\/docs.gitlab.com\/ci\/\">GitLab CI\/CD<\/a>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b \u0444\u0440\u043e\u043d\u0442\u0430 (\u0430\u0440\u0445\u0438\u0432 <code>.tar.gz<\/code>) \u0438 \u0431\u044d\u043a\u0430 (\u0444\u0430\u0439\u043b <code>.jar<\/code>) \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/help.sonatype.com\/en\/sonatype-nexus-repository.html\">Nexus<\/a>.<\/p>\n<p> <\/p>\n<p>\u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 <a href=\"https:\/\/ubuntu.com\/\">Ubuntu Linux<\/a>. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible.<\/p>\n<p> <\/p>\n<p>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f:<\/p>\n<p> <\/p>\n<ul>\n<li>\u043d\u0430 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d <code>ansible<\/code> (<a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/installation_guide\/installation_distros.html#installing-ansible-on-ubuntu\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0434\u043b\u044f Ubuntu<\/a>)<\/li>\n<li>\u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <code>ansible<\/code> \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/li>\n<\/ul>\n<p> <\/p>\n<h2 id=\"-para-slov-ob-ansible\">\u276f \u041f\u0430\u0440\u0430 \u0441\u043b\u043e\u0432 \u043e\u0431 Ansible<\/h2>\n<p> <\/p>\n<p><a href=\"https:\/\/docs.ansible.com\/\">Ansible<\/a> \u2014 \u044d\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 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0418\u0422-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a:<\/p>\n<p> <\/p>\n<ul>\n<li>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432<\/li>\n<li>\u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/li>\n<li>\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438<\/li>\n<li>\u043e\u0440\u043a\u0435\u0441\u0442\u0440\u0430\u0446\u0438\u044f (\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0430\u0448\u0438\u043d)<\/li>\n<\/ul>\n<p> <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0432\u044b\u0441\u043e\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 Ansible \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p> <\/p>\n<ul>\n<li>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 SSH \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c (\u0430\u0433\u0435\u043d\u0442\u044b \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u2014 \u044d\u0442\u043e \u0431\u0435\u0437\u0430\u0433\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430)<\/li>\n<li>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 YAML-\u0444\u0430\u0439\u043b\u0430\u0445 (\u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f playbook&#8217;\u0438).<\/li>\n<li>\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0430 \u043d\u0435 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b (\u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434)<\/li>\n<\/ul>\n<p> <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b Ansible:<\/p>\n<p> <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/th>\n<th>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Inventory<\/td>\n<td>\u0421\u043f\u0438\u0441\u043e\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0445\u043e\u0441\u0442\u043e\u0432<\/td>\n<\/tr>\n<tr>\n<td>Playbook<\/td>\n<td>YAML-\u0444\u0430\u0439\u043b \u0441 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438<\/td>\n<\/tr>\n<tr>\n<td>Task<\/td>\n<td>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442)<\/td>\n<\/tr>\n<tr>\n<td>Role<\/td>\n<td>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0437\u0430\u0434\u0430\u0447 \u0438 \u0444\u0430\u0439\u043b\u043e\u0432<\/td>\n<\/tr>\n<tr>\n<td>Module<\/td>\n<td>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>apt<\/code>, <code>yum<\/code>, <code>copy<\/code>, <code>service<\/code> \u0438 \u0434\u0440.)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p> <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e playbook&#8217;\u0430:<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\"># \u0445\u043e\u0441\u0442\u044b - \u0441\u0435\u0440\u0432\u0435\u0440\u044b - hosts: webservers   # \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c - sudo   become: yes   # \u0437\u0430\u0434\u0430\u0447\u0438   tasks:     - name: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c nginx       # \u043c\u043e\u0434\u0443\u043b\u044c       apt:         name: nginx         state: present<\/code><\/pre>\n<p> <\/p>\n<p>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 Ansible:<\/p>\n<p> <\/p>\n<ul>\n<li>\u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u2014 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0430\u0433\u0435\u043d\u0442\u043e\u0432<\/li>\n<li>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 YAML-\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/li>\n<li>\u0445\u043e\u0440\u043e\u0448\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f<\/li>\n<li>\u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0438 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u0430\u0434\u0430\u0447<\/li>\n<\/ul>\n<p> <\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b:<\/p>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/slurm\/articles\/714000\/\">Ansible \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445<\/a><\/li>\n<li><a href=\"https:\/\/skillbox.ru\/media\/code\/ansible-dlya-novichkov-chto-eto-kak-ustroen-i-zachem-nuzhen\/\">Ansible \u0434\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432: \u0447\u0442\u043e \u044d\u0442\u043e, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0438 \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d<\/a><\/li>\n<li><a href=\"https:\/\/practicum.yandex.ru\/blog\/ansible-sistema-upravleniya-serverami\/\">Ansible \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445: \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u043a\u0443\u0440\u0441 \u043d\u0430 Stepik:<\/p>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/stepik.org\/course\/123806\/promo\">Ansible \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 + \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u043f\u044b\u0442<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2 id=\"-konfiguraciya-ansible\">\u276f \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f Ansible<\/h2>\n<p> <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <a href=\"https:\/\/github.com\/harryheman\/blog-posts\/tree\/master\/devops-ansible\">devops-ansible<\/a> \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439:<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">. \u251c\u2500\u2500 ansible.cfg \u251c\u2500\u2500 inventory.yaml \u251c\u2500\u2500 playbook.yml \u251c\u2500\u2500 README.md \u2514\u2500\u2500 roles     \u251c\u2500\u2500 backend     \u2502   \u251c\u2500\u2500 defaults     \u2502   \u2502   \u2514\u2500\u2500 main.yml     \u2502   \u251c\u2500\u2500 tasks     \u2502   \u2502   \u251c\u2500\u2500 download.yml     \u2502   \u2502   \u251c\u2500\u2500 install.yml     \u2502   \u2502   \u251c\u2500\u2500 main.yml     \u2502   \u2502   \u251c\u2500\u2500 service.yml     \u2502   \u2502   \u2514\u2500\u2500 setup.yml     \u2502   \u2514\u2500\u2500 templates     \u2502       \u2514\u2500\u2500 backend.service.j2     \u2514\u2500\u2500 frontend         \u251c\u2500\u2500 defaults         \u2502   \u2514\u2500\u2500 main.yml         \u251c\u2500\u2500 tasks         \u2502   \u251c\u2500\u2500 download.yml         \u2502   \u251c\u2500\u2500 install.yml         \u2502   \u251c\u2500\u2500 main.yml         \u2502   \u251c\u2500\u2500 nodesource.yml         \u2502   \u251c\u2500\u2500 service.yml         \u2502   \u2514\u2500\u2500 setup.yml         \u2514\u2500\u2500 templates             \u2514\u2500\u2500 frontend.service.j2<\/code><\/pre>\n<p> <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 Ansible \u0432 \u0444\u0430\u0439\u043b\u0435 <code>ansible.cfg<\/code>:<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">[defaults] roles_path = .\/roles  [ssh_connection] timeout = 30<\/code><\/pre>\n<p> <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0445\u043e\u0441\u0442\u043e\u0432 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>inventory.yaml<\/code>:<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">all:   hosts:     vm1:       ansible_host: &lt;ip \u0432\u0430\u0448\u0435\u0433\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430&gt;       ansible_user: ansible<\/code><\/pre>\n<p> <\/p>\n<p><code>vm1<\/code> \u2014 \u044d\u0442\u043e \u0438\u043c\u044f \u0445\u043e\u0441\u0442\u0430 (\u0441\u0438\u043d\u043e\u043d\u0438\u043c\/\u0430\u043b\u0438\u0430\u0441), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, <code>vm1<\/code> \u2014 \u044d\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0438\u043c\u044f, \u043f\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c Ansible \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440. \u041e\u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u043c\u0430\u0448\u0438\u043d\u044b \u0438\u043b\u0438 DNS-\u0438\u043c\u0435\u043d\u0435\u043c.<\/p>\n<p> <\/p>\n<p>\u0427\u0435\u0440\u0435\u0437 <code>ansible_host<\/code> \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 IP-\u0430\u0434\u0440\u0435\u0441 (\u0438\u043b\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u043c\u044f), \u043a\u0443\u0434\u0430 Ansible \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p> <\/p>\n<p>\u0427\u0435\u0440\u0435\u0437 <code>ansible_user<\/code> \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u043f\u043e\u0434 \u043a\u0430\u043a\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043f\u043e SSH.<\/p>\n<p> <\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u044f \u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u044b\u043c \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u043e\u043c:<\/p>\n<p> <\/p>\n<ul>\n<li><code>vm1<\/code> \u2014 \u0438\u043c\u044f \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430 (\u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f)<\/li>\n<li><code>ansible_host<\/code> \u2014 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 (\u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 IP)<\/li>\n<li><code>ansible_user<\/code> \u2014 \u043a\u0442\u043e \u0437\u0432\u043e\u043d\u0438\u0442 (\u043f\u043e\u0434 \u043a\u0430\u043a\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f)<\/li>\n<\/ul>\n<p> <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0433\u0440\u0443\u043f\u043f\u044b \u0437\u0430\u0434\u0430\u0447 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>playbook.yaml<\/code>:<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- - name: \u0414\u0435\u043f\u043b\u043e\u0439 backend \u0438 frontend   hosts: all   remote_user: ansible    roles:     - backend     - frontend<\/code><\/pre>\n<p> <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>remote_user<\/code> \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 <code>ansible_user<\/code> \u0432 <code>inventory.yaml<\/code>. <code>remote_user<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445:<\/p>\n<p> <\/p>\n<ul>\n<li>\u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0432 inventory<\/li>\n<li>\u0435\u0441\u043b\u0438 \u0432 inventory \u043d\u0435\u0442 <code>ansible_user<\/code>, \u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 playbook&#8217;\u0430<\/li>\n<\/ul>\n<p> <\/p>\n<h2 id=\"-konfiguraciya-roligruppy-zadach-frontend\">\u276f \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0440\u043e\u043b\u0438\/\u0433\u0440\u0443\u043f\u043f\u044b \u0437\u0430\u0434\u0430\u0447 frontend<\/h2>\n<p> <\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0435\u0439 <code>ansible\/roles\/frontend<\/code>.<\/p>\n<p> <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>defaults\/main.yml<\/code>:<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\"># \u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044e Nexus, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0430\u0440\u0445\u0438\u0432 \u0444\u0440\u043e\u043d\u0442\u0430 `.tar.gz`. # \u0412 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b `.env` \u0441 \u044d\u0442\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 nexus_service_url: \"{{ lookup('env', 'NEXUS_SERVICE_URL') }}\" nexus_repo_frontend_name: \"{{ lookup('env', 'NEXUS_REPO_FRONTEND_NAME') }}\" nexus_repo_user: \"{{ lookup('env', 'NEXUS_REPO_USER') }}\" nexus_repo_pass: \"{{ lookup('env', 'NEXUS_REPO_PASS') }}\"  # \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0444\u0440\u043e\u043d\u0442\u0430 frontend_user: \"www-data\" # \u0414\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0430\u0440\u0445\u0438\u0432\u0430 frontend_dest: \"\/var\/www-data\"  # \u0412\u0435\u0440\u0441\u0438\u044f Node.js (20+) node_version: \"20.x\"  # \u041f\u043e\u0440\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0430\u0447\u0438 \u0441\u0442\u0430\u0442\u0438\u043a\u0438 frontend_port: 80 # \u0410\u0434\u0440\u0435\u0441 \u0431\u044d\u043a\u0430 backend_url: \"http:\/\/localhost:8080\"<\/code><\/pre>\n<p> <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0433\u0440\u0443\u043f\u043f\u044b \u0437\u0430\u0434\u0430\u0447 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>tasks\/main.yml<\/code>:<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- # \u0417\u0430\u0434\u0430\u0447\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f - include_tasks: nodesource.yml - include_tasks: install.yml - include_tasks: setup.yml - include_tasks: download.yml - include_tasks: service.yml<\/code><\/pre>\n<p> <\/p>\n<p><em>\u0417\u0430\u0434\u0430\u0447\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f NodeSource (<code>nodesource.yml<\/code>):<\/em><\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- - name: \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c GPG-\u043a\u043b\u044e\u0447 NodeSource   become: true   # \u0427\u0442\u043e\u0431\u044b apt \u0434\u043e\u0432\u0435\u0440\u044f\u043b \u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044e   apt_key:     url: 'https:\/\/deb.nodesource.com\/gpgkey\/nodesource.gpg.key'     state: present  - name: \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c NodeSource \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439   become: true   # \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Node.js \u0447\u0435\u0440\u0435\u0437 apt \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442,   # \u043d\u043e \u0438\u0437 NodeSource, \u0430 \u043d\u0435 \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f   apt_repository:     repo: 'deb https:\/\/deb.nodesource.com\/node_{{ node_version }} {{ ansible_distribution_release }} main'     state: present     filename: 'nodesource'<\/code><\/pre>\n<p> <\/p>\n<p>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d NodeSource \u043f\u0435\u0440\u0435\u0434 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 Node.js? NodeSource \u2014 \u044d\u0442\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 Node.js, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u0445 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043e\u0432 Linux (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e Debian\/Ubuntu).<\/p>\n<p> <\/p>\n<p><em>\u0417\u0430\u0434\u0430\u0447\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Node.js (\u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435 \u0441 npm) \u0438 http-server (<code>install.yml<\/code>):<\/em><\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- - name: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Node.js \u0438 npm   become: true   apt:     name:       - nodejs     state: present     update_cache: yes  - name: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c http-server   become: true   community.general.npm:     name: http-server     # \u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430     global: yes<\/code><\/pre>\n<p> <\/p>\n<p>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 <code>update_cache: yes<\/code>? \u042d\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 apt, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u044d\u0448 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 (<code>apt update<\/code>) \u043f\u0435\u0440\u0435\u0434 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443:<\/p>\n<p> <\/p>\n<ul>\n<li>\u0435\u0441\u043b\u0438 \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, NodeSource), apt \u0435\u0449\u0435 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0442\u0430\u043c \u043f\u0430\u043a\u0435\u0442\u0430\u0445, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u0442 \u043a\u044d\u0448<\/li>\n<li>\u0431\u0435\u0437 <code>update_cache: yes<\/code> \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435<\/li>\n<\/ul>\n<p> <\/p>\n<p><em>\u0417\u0430\u0434\u0430\u0447\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0430\u0440\u0445\u0438\u0432\u0430 \u0444\u0440\u043e\u043d\u0442\u0430 (<code>setup.yml<\/code>):<\/em><\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- - name: \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f www-data   become: true   user:     name: '{{ frontend_user }}'     # \u041d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043e\u043c\u0430\u0448\u043d\u044e\u044e\/\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e     create_home: no     # \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c     system: yes     shell: \/usr\/sbin\/nologin  - name: \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e {{ frontend_dest }}   become: true   file:     path: '{{ frontend_dest }}'     state: directory     owner: '{{ frontend_user }}'     group: '{{ frontend_user }}'     mode: '0755'<\/code><\/pre>\n<p> <\/p>\n<p><code>shell: \/usr\/sbin\/nologin<\/code> \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0432\u0445\u043e\u0434 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b (SSH, \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u0442.\u0434.). \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443:<\/p>\n<p> <\/p>\n<ul>\n<li>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <code>www-data<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438\u043b\u0438 \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u0430 \u043d\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0442 \u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438<\/li>\n<li>\u044d\u0442\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438<\/li>\n<\/ul>\n<p> <\/p>\n<p><em>\u0417\u0430\u0434\u0430\u0447\u0438 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0430\u0440\u0445\u0438\u0432\u0430 \u0444\u0440\u043e\u043d\u0442\u0430 (<code>download.yml<\/code>):<\/em><\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- - name: \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0430 \u0438\u0437 Nexus   uri:     # \u0410\u0434\u0440\u0435\u0441 Nexus-\u0441\u0435\u0440\u0432\u0435\u0440\u0430     # `sort=version` \u2014 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0432\u0435\u0440\u0441\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0431\u044b\u043b\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435     url: '{{ nexus_service_url }}\/rest\/v1\/search\/assets?repository={{ nexus_repo_frontend_name }}&amp;sort=version'     method: GET     url_username: '{{ nexus_repo_user }}'     url_password: '{{ nexus_repo_pass }}'     # \u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c basic auth     force_basic_auth: yes     # \u0412\u0435\u0440\u043d\u0443\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 (`.json`), \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0441 \u043d\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c     return_content: yes   # \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e `nexus_response`   register: nexus_response  - name: \u0418\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0430 \u0438\u0437 Nexus   set_fact:     download_url: \"{{ nexus_response.json['items'][0].downloadUrl }}\"  - name: \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0430 \u0438\u0437 Nexus   get_url:     url: '{{ download_url }}'     # \u041a\u0443\u0434\u0430 \u0441\u043a\u0430\u0447\u0430\u0442\u044c?     dest: '\/tmp\/frontend.tar.gz'     url_username: '{{ nexus_repo_user }}'     url_password: '{{ nexus_repo_pass }}'     force_basic_auth: yes  - name: \u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434   become: true   unarchive:     src: '\/tmp\/frontend.tar.gz'     # \u041a\u0443\u0434\u0430 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c?     dest: '{{ frontend_dest }}'     # \u0424\u0430\u0439\u043b \u0443\u0436\u0435 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b     remote_src: yes<\/code><\/pre>\n<p> <\/p>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>set_fact<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>download_url<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u044f\u043c\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0432\u0435\u0436\u0435\u0433\u043e \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u0430:<\/p>\n<p> <\/p>\n<ul>\n<li><code>items[0]<\/code> \u2014 \u043f\u0435\u0440\u0432\u044b\u0439 (\u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0441\u0430\u043c\u044b\u0439 \u043d\u043e\u0432\u044b\u0439) \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u043e\u0432 (\u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u043f\u043e \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435)<\/li>\n<li><code>downloadUrl<\/code> \u2014 \u043a\u043b\u044e\u0447 \u0432 JSON, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0444\u0430\u0439\u043b<\/li>\n<\/ul>\n<p> <\/p>\n<p><em>\u0417\u0430\u0434\u0430\u0447\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0444\u0440\u043e\u043d\u0442\u0430 (<code>service.yml<\/code>):<\/em><\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- - name: \u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c systemd unit-\u0444\u0430\u0439\u043b   become: true   template:     src: frontend.service.j2     dest: \/etc\/systemd\/system\/frontend.service     mode: '0644'  - name: \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c systemd   become: true   systemd:     daemon_reload: yes  - name: \u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0430   become: true   systemd:     name: frontend     enabled: yes     state: started<\/code><\/pre>\n<p> <\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0444\u0440\u043e\u043d\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a (<code>templates\/frontend.service.j2<\/code>):<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">[Unit] Description=Frontend Service After=network.target  [Service] User={{ frontend_user }} Group={{ frontend_user }} WorkingDirectory={{ frontend_dest }}\/dist\/frontend ExecStart=\/usr\/bin\/http-server -p {{ frontend_port }} --proxy {{ backend_url }} Restart=always AmbientCapabilities=CAP_NET_BIND_SERVICE  [Install] WantedBy=multiuser.target<\/code><\/pre>\n<p> <\/p>\n<h2 id=\"-konfiguraciya-roligruppy-zadach-backend\">\u276f \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0440\u043e\u043b\u0438\/\u0433\u0440\u0443\u043f\u043f\u044b \u0437\u0430\u0434\u0430\u0447 backend<\/h2>\n<p> <\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0435\u0439 <code>ansible\/roles\/backend<\/code>.<\/p>\n<p> <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>defaults\/main.yml<\/code>:<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\"># \u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044e Nexus, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u0431\u044d\u043a\u0430 `.jar`. # \u0412 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b `.env` \u0441 \u044d\u0442\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 nexus_service_url: \"{{ lookup('env', 'NEXUS_SERVICE_URL') }}\" nexus_repo_backend_name: \"{{ lookup('env', 'NEXUS_REPO_BACKEND_NAME') }}\" nexus_repo_user: \"{{ lookup('env', 'NEXUS_REPO_USER') }}\" nexus_repo_pass: \"{{ lookup('env', 'NEXUS_REPO_PASS') }}\"  # \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u044d\u043a\u0430 backend_user: 'backend'  # \u041f\u0443\u0442\u044c \u043a \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443. # app-name - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f jar_path: '\/opt\/app-name\/bin\/backend.jar'<\/code><\/pre>\n<p> <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0433\u0440\u0443\u043f\u043f\u044b \u0437\u0430\u0434\u0430\u0447 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>tasks\/main.yml<\/code>:<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- # \u0417\u0430\u0434\u0430\u0447\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f - import_tasks: install.yml - import_tasks: setup.yml - import_tasks: download.yml - import_tasks: service.yml<\/code><\/pre>\n<p> <\/p>\n<p><em>\u0417\u0430\u0434\u0430\u0447\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Java \u043d\u0443\u0436\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 (<code>install.yml<\/code>)<\/em><\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- - name: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c OpenJDK 16   become: true   apt:     # \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0432\u0435\u0440\u0441\u0438\u044e Java \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e     name: openjdk-16-jdk     state: present     update_cache: yes<\/code><\/pre>\n<p> <\/p>\n<p><em>\u0417\u0430\u0434\u0430\u0447\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0431\u044d\u043a\u0430 (<code>setup.yml<\/code>):<\/em><\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- - name: \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f backend   become: true   user:     name: '{{ backend_user }}'     create_home: no     system: yes     shell: \/usr\/sbin\/nologin  - name: \u0423\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \/opt\/app-name\/bin \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442   become: true   file:     path: \/opt\/app-name\/bin     state: directory     owner: '{{ backend_user }}'     group: '{{ backend_user }}'     mode: '0755'  - name: \u0423\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \/var\/app-name \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442   become: true   file:     path: \/var\/app-name     state: directory     owner: '{{ backend_user }}'     group: '{{ backend_user }}'     mode: '0755'<\/code><\/pre>\n<p> <\/p>\n<p><code>\/opt\/app-name\/bin<\/code> \u2014 \u044d\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0431\u044d\u043a\u0430, \u0430 \u0437\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f <code>\/var\/app-name<\/code>? <code>\/var\/<\/code> \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u0434\u043b\u044f:<\/p>\n<p> <\/p>\n<ul>\n<li>\u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043b\u043e\u0433\u0438, \u043a\u044d\u0448, \u0411\u0414 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>sqlite<\/code>) \u0438 \u0442.\u0434.<\/li>\n<li>\u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 <code>\/opt<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c, \u0431\u044d\u043a\u0430\u043f\u0430\u043c, \u0440\u043e\u0442\u0430\u0446\u0438\u0438 \u043b\u043e\u0433\u043e\u0432 \u0438 \u0442.\u043f.<\/li>\n<\/ul>\n<p> <\/p>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043b\u043e\u0433\u0438 \u0431\u044d\u043a\u0430.<\/p>\n<p> <\/p>\n<p><em>\u0417\u0430\u0434\u0430\u0447\u0430 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0431\u044d\u043a\u0430 (<code>download.yml<\/code>):<\/em><\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- - name: \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u043e\u0432 \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u0438\u0437 Nexus   uri:     url: '{{ nexus_service_url }}\/rest\/v1\/search\/assets?repository={{ nexus_repo_backend_name }}&amp;maven.extension=jar&amp;sort=version'     method: GET     url_username: '{{ nexus_repo_user }}'     url_password: '{{ nexus_repo_pass }}'     force_basic_auth: yes     return_content: yes   register: nexus_response  - name: \u0418\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u0438\u0437 Nexus   set_fact:     download_url: \"{{ nexus_response.json['items'][0].downloadUrl }}\"  - name: \u0421\u043a\u0430\u0447\u0430\u0442\u044c  \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u0438\u0437 Nexus   become: true   get_url:     url: '{{ download_url }}'     dest: '{{ jar_path }}'     url_username: '{{ nexus_repo_user }}'     url_password: '{{ nexus_repo_pass }}'     force_basic_auth: yes<\/code><\/pre>\n<p> <\/p>\n<p><em>\u0417\u0430\u0434\u0430\u0447\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u044d\u043a\u0430 (<code>service.yml<\/code>):<\/em><\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">--- - name: \u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c systemd unit-\u0444\u0430\u0439\u043b   become: true   template:     src: backend.service.j2     dest: \/etc\/systemd\/system\/backend.service     mode: '0644'  - name: \u041f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c systemd   become: true   systemd:     daemon_reload: yes  - name: \u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0431\u044d\u043a\u0435\u043d\u0434\u0430   become: true   systemd:     name: backend     state: started     enabled: yes<\/code><\/pre>\n<p> <\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u044d\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a (<code>templates\/backend.service.j2<\/code>):<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">[Unit] Description=Backend Service After=network.target  [Service] User={{ backend_user }} Group={{ backend_user }} StandardOutput=append:\/var\/app-name\/backend.log WorkingDirectory=\/opt\/app-name\/bin ExecStart=\/usr\/bin\/java -jar backend.jar Restart=always  [Install] WantedBy=multi-user.target<\/code><\/pre>\n<p> <\/p>\n<h2 id=\"-itogo\">\u276f \u0418\u0442\u043e\u0433\u043e<\/h2>\n<p> <\/p>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Ansible:<\/p>\n<p> <\/p>\n<pre><code class=\"bash\"># \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 (`ansible`). # \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b `.env` \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u043c Nexus source .env &amp;&amp; ansible-playbook playbook.yml -i inventory.yaml<\/code><\/pre>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/harryheman\/blog-posts\/tree\/master\/devops-ansible\">devops-ansible \u043d\u0430 GitHub<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<p>\u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 Ansible, \u043d\u043e \u0434\u0443\u043c\u0430\u044e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0438 \u043a\u0430\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442. \u041d\u0430\u0440\u044f\u0434\u0443 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0418\u0422-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 (Terraform, Docker, Kubernetes \u0438 \u0442.\u0434.), Ansible \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u0430\u0440\u0441\u0435\u043d\u0430\u043b\u0430 DevOps-\u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430.<\/p>\n<p> <\/p>\n<p>Happy devopsing!<\/p>\n<p> <\/p>\n<hr\/>\n<p> <\/p>\n<blockquote><p><a href=\"https:\/\/t.me\/timewebru\"><b>\u041d\u043e\u0432\u043e\u0441\u0442\u0438, \u043e\u0431\u0437\u043e\u0440\u044b \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u0438 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u044b \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b Timeweb.Cloud \u2014 \u0432 \u043d\u0430\u0448\u0435\u043c Telegram-\u043a\u0430\u043d\u0430\u043b\u0435<\/b><\/a> <b>\u21a9<\/b><\/p><\/blockquote>\n<p><a href=\"https:\/\/timeweb.cloud\/?utm_source=habr&amp;utm_medium=banner&amp;utm_campaign=promo\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/6r\/9j\/sr\/6r9jsrljpzsgcfyj1jjupubij5e.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/6r\/9j\/sr\/6r9jsrljpzsgcfyj1jjupubij5e.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/6r\/9j\/sr\/6r9jsrljpzsgcfyj1jjupubij5e.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/a><\/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\/articles\/913426\/\"> https:\/\/habr.com\/ru\/articles\/913426\/<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ma\/po\/lv\/mapolvqq4uunxfqoaviv3g9km9y.jpeg\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/ma\/po\/lv\/mapolvqq4uunxfqoaviv3g9km9y.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/ma\/po\/lv\/mapolvqq4uunxfqoaviv3g9km9y.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/> <\/p>\n<p> <\/p>\n<p> <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p> <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u044f \u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e.<\/p>\n<p> <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c Angular+Java \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 Ubuntu Linux \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible.<\/p>\n<p> <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e? \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-467466","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/467466","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=467466"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/467466\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=467466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=467466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=467466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}