{"id":378014,"date":"2024-06-04T15:01:31","date_gmt":"2024-06-04T15:01:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=378014"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=378014","title":{"rendered":"<span>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 Argo CD \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible \u0447\u0435\u0440\u0435\u0437 API \u0432\u044b\u0437\u043e\u0432\u044b<\/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<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4b8\/1a3\/f64\/4b81a3f64bace1ce2bbb3d771ac3c735.png\" width=\"1362\" height=\"790\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4b8\/1a3\/f64\/4b81a3f64bace1ce2bbb3d771ac3c735.png\"\/><\/figure>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e DevOps \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0440\u0430\u0437\u043d\u043e\u0440\u043e\u0434\u043d\u0430\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 (\u043e\u0431\u043b\u0430\u043a\u0430, Kubernetes, \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b \u0438 \u0442.\u0434.).<\/p>\n<p>\u0421\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0442\u0430 \u043d\u0430 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430: <\/p>\n<ul>\n<li>\n<p>\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u00a0ArgoCD \u0447\u0435\u0440\u0435\u0437 API \u0437\u0430\u043f\u0440\u043e\u0441\u044b<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Ansible \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p><em>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b ArgoCD, Ansible, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0440\u0430\u0432\u0430 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u044b.<\/em><\/p>\n<h3>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u00a0ArgoCD \u0447\u0435\u0440\u0435\u0437 API \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/h3>\n<h4>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430<\/h4>\n<p>\u0414\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 ArgoCD \u0447\u0435\u0440\u0435\u0437 API \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0442\u043e\u043a\u0435\u043d. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438: \u0447\u0435\u0440\u0435\u0437 API \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u043b\u0438 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 API \u0437\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<p>\u0422\u043e\u043a\u0435\u043d \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e API \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"bash\">curl $ARGOCD_SERVER\/api\/v1\/session -d $'{\"username\":\"admin\",\"password\":\"your_password_here\"}'<\/code><\/pre>\n<p><strong>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u0442\u043e\u043a\u0435\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/strong><\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d \u2014 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ArgoCD:<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e <\/p>\n<p>1.  \u041e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u00a0configMap, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00a0<code>argocd-cm<\/code>\u00a0\u0432 <code>namespace<\/code> ArgoCD, \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u043d \u0442\u0430\u043a \u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00a0<code>argocd<\/code>. \u041d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u00a0<code>data<\/code>:<\/p>\n<pre><code class=\"yaml\">data:   accounts.admin: apiKey, login <\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0434\u0435\u043f\u043b\u043e\u0439\u043c\u0435\u043d\u0442\u00a0<code>argo-cd-argocd-server<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f &#8216;admin&#8217; \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ArgoCD:<\/p>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u00a0<code>\/settings\/accounts\/admin<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 Token ID \u0432\u044b\u0431\u0435\u0440\u0430\u0442\u044c\u00a0<code>Generate NEW \u2018Token ID\u2019<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f &#8216;admin&#8217; \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0442\u043e\u043a\u0435\u043d.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b API \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h4>\n<p>\u042d\u043a\u0441\u043f\u043e\u0440\u0442 \u0442\u043e\u043a\u0435\u043d\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"bash\">export ARGOCD_TOKEN=\"\u0432\u0430\u0448 \u0442\u043e\u043a\u0435\u043d \u0437\u0434\u0435\u0441\u044c\"<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 ArgoCD \u0447\u0435\u0440\u0435\u0437 cURL \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"bash\">curl -X POST -H \"Authorization: Bearer $ARGOCD_TOKEN\" -H \"Content-Type: application\/json\" \\   -d '{     \"metadata\": {       \"name\": \"test-api-app\",       \"namespace\": \"argocd\"     },     \"spec\": {       \"project\": \"default\",       \"source\": {         \"repoURL\": \"https:\/\/your-argocd-instance\/helm.git\",         \"path\": \"vault-secrets-webhook\",         \"targetRevision\": \"master\",         \"helm\": {           \"parameters\": [             {\"name\": \"resources.limits.memory\", \"value\": \"256Mi\"},             {\"name\": \"resources.limits.cpu\", \"value\": \"250m\"}           ]         }       },       \"destination\": {         \"server\": \"https:\/\/kubernetes.default.svc\",         \"namespace\": \"test-app-yaml\"       },       \"syncPolicy\": {         \"automated\": {\"prune\": true, \"selfHeal\": true}       }     }   }' \\   https:\/\/your-argocd-instance\/api\/v1\/applications <\/code><\/pre>\n<p> \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e API \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"bash\">curl -X DELETE -H \"Authorization: Bearer $ARGOCD_TOKEN\" https:\/\/your-argocd-instance\/api\/v1\/applications\/test-api-app<\/code><\/pre>\n<h4>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 API ArgoCD \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Swagger<\/h4>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 API \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Swagger. \u0414\u043b\u044f \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 Swagger:<\/p>\n<pre><code class=\"bash\">https:\/\/your-argocd-instance\/swagger-ui<\/code><\/pre>\n<h3>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f Ansible \u0441 ArgoCD<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Ansible \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 ArgoCD.<\/p>\n<p>Ansible  \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 ArgoCD \u0447\u0435\u0440\u0435\u0437 \u043c\u043e\u0434\u0443\u043b\u044c URI, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c API \u0437\u0430\u043f\u0440\u043e\u0441\u044b.  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 1: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u00a0ArgoCD <\/p>\n<p>\u0412\u043e\u0442 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u043f\u043b\u0435\u0439\u0431\u0443\u043a Ansible \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 ArgoCD:<\/p>\n<pre><code class=\"yaml\">- hosts: localhost   tasks:     - name: Create ArgoCD application       uri:         url: \"https:\/\/{{ ARGOCD_URL }}\/api\/v1\/applications\"         method: POST         headers:           Authorization: \"Bearer {{ ARGOCD_TOKEN }}\"           Content-Type: \"application\/json\"         body_format: json         body:           metadata:             name: \"{{ APP_NAME }}\"             namespace: \"argocd\"           spec:             project: \"default\"             source:               repoURL: \"https:\/\/{{ ARGOCD_HELM_REPO }}\/stash\/scm\/do\/helm.git\"               path: \"vault-secrets-webhook\"               targetRevision: \"master\"               helm:                 parameters:                   - name: \"replicaCount\"                     value: \"1\"                   - name: \"env.VAULT_IMAGE\"                     value: \"vault:1.11.11\"                   - name: \"resources.limits.memory\"                     value: \"256Mi\"                   - name: \"resources.limits.cpu\"                     value: \"250m\"             destination:               server: \"https:\/\/kubernetes.default.svc\"               namespace: \"test-app-yaml\"             syncPolicy:               automated:                 prune: true                 selfHeal: true         return_content: yes         validate_certs: no       register: response      - name: Display API response       debug:         var: response.content <\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u043b\u0435\u0439\u0431\u0443\u043a\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0432\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435\u00a0<code>ARGOCD_URL<\/code>,\u00a0<code>ARGOCD_TOKEN<\/code>\u00a0\u0438\u00a0<code>APP_NAME<\/code>\u00a0\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 2: \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 ArgoCD<\/strong><\/p>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"yaml\">- hosts: localhost   tasks:   - name: Delete ArgoCD application     uri:       url: \"https:\/\/{{ ARGOCD_URL }}\/api\/v1\/applications\/{{ APP_NAME }}\"       method: DELETE       headers:         Authorization: \"Bearer {{ ARGOCD_TOKEN }}\"         Content-Type: \"application\/json\"       status_code: 200,202,204       validate_certs: no <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435\u00a0<code>ARGOCD_URL<\/code>,\u00a0<code>ARGOCD_TOKEN<\/code>\u00a0\u0438\u00a0<code>APP_NAME<\/code>\u00a0\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043b\u0435\u0439\u0431\u0443\u043a\u0430.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b Ansible \u0440\u043e\u043b\u0438<\/h4>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/p>\n<pre><code class=\"yaml\">roles\/app-k8s-deploy \u251c\u2500\u2500 defaults \u2502   \u2514\u2500\u2500 main.yaml \u251c\u2500\u2500 tasks \u2502   \u251c\u2500\u2500 create_application.yml \u2502   \u251c\u2500\u2500 delete_application.yml \u2502   \u2514\u2500\u2500 main.yaml<\/code><\/pre>\n<p>\u0412\u00a0<code>defaults\/main.yaml<\/code>\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<pre><code class=\"bash\">ARGOCD_URL: \"https:\/\/your-argocd-instance\" ARGOCD_TOKEN: \"\" ARGOCD_APP_NAME: \"test-api-app\" # ... (\u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435) <\/code><\/pre>\n<p>\u041f\u043b\u0435\u0439\u0431\u0443\u043a\u00a0<code>main.yaml<\/code>\u00a0\u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"yaml\">--- - name: Include create application tasks   include_tasks: create_application.yml   when: task == 'install'  - name: Include delete application tasks   include_tasks: delete_application.yml   when: task == 'delete' <\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438\u00a0<code>create_application.yml<\/code>\u00a0\u0438\u00a0<code>delete_application.yml<\/code>\u00a0\u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.<\/p>\n<h4>\u041f\u043b\u0435\u0439\u0431\u0443\u043a \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0440\u043e\u043b\u0438<\/h4>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0440\u043e\u043b\u044c \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043b\u0435\u0439\u0431\u0443\u043a\u0430<\/p>\n<pre><code class=\"yaml\">--- - hosts: \"{{ exec_hosts | default(['localhost']) | join(',') }}\"   roles:   - { role: app-k8s-deploy, task: install } <\/code><\/pre>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0438 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 ArgoCD \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible. \u0423\u0434\u0430\u0447\u043d\u043e\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438!<\/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\/articles\/819439\/\"> https:\/\/habr.com\/ru\/articles\/819439\/<\/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<figure class=\"full-width\"><\/figure>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e DevOps \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0440\u0430\u0437\u043d\u043e\u0440\u043e\u0434\u043d\u0430\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 (\u043e\u0431\u043b\u0430\u043a\u0430, Kubernetes, \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b \u0438 \u0442.\u0434.).<\/p>\n<p>\u0421\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0442\u0430 \u043d\u0430 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430: <\/p>\n<ul>\n<li>\n<p>\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u00a0ArgoCD \u0447\u0435\u0440\u0435\u0437 API \u0437\u0430\u043f\u0440\u043e\u0441\u044b<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Ansible \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p><em>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b ArgoCD, Ansible, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0440\u0430\u0432\u0430 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u044b.<\/em><\/p>\n<h3>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u00a0ArgoCD \u0447\u0435\u0440\u0435\u0437 API \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/h3>\n<h4>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430<\/h4>\n<p>\u0414\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 ArgoCD \u0447\u0435\u0440\u0435\u0437 API \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0442\u043e\u043a\u0435\u043d. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438: \u0447\u0435\u0440\u0435\u0437 API \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u043b\u0438 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 API \u0437\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<p>\u0422\u043e\u043a\u0435\u043d \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e API \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"bash\">curl $ARGOCD_SERVER\/api\/v1\/session -d $'{\"username\":\"admin\",\"password\":\"your_password_here\"}'<\/code><\/pre>\n<p><strong>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u0442\u043e\u043a\u0435\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/strong><\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d \u2014 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ArgoCD:<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e <\/p>\n<p>1.  \u041e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u00a0configMap, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00a0<code>argocd-cm<\/code>\u00a0\u0432 <code>namespace<\/code> ArgoCD, \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u043d \u0442\u0430\u043a \u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00a0<code>argocd<\/code>. \u041d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u00a0<code>data<\/code>:<\/p>\n<pre><code class=\"yaml\">data:   accounts.admin: apiKey, login <\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0434\u0435\u043f\u043b\u043e\u0439\u043c\u0435\u043d\u0442\u00a0<code>argo-cd-argocd-server<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f &#8216;admin&#8217; \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ArgoCD:<\/p>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u00a0<code>\/settings\/accounts\/admin<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 Token ID \u0432\u044b\u0431\u0435\u0440\u0430\u0442\u044c\u00a0<code>Generate NEW \u2018Token ID\u2019<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f &#8216;admin&#8217; \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0442\u043e\u043a\u0435\u043d.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b API \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h4>\n<p>\u042d\u043a\u0441\u043f\u043e\u0440\u0442 \u0442\u043e\u043a\u0435\u043d\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"bash\">export ARGOCD_TOKEN=\"\u0432\u0430\u0448 \u0442\u043e\u043a\u0435\u043d \u0437\u0434\u0435\u0441\u044c\"<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 ArgoCD \u0447\u0435\u0440\u0435\u0437 cURL \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"bash\">curl -X POST -H \"Authorization: Bearer $ARGOCD_TOKEN\" -H \"Content-Type: application\/json\" \\   -d '{     \"metadata\": {       \"name\": \"test-api-app\",       \"namespace\": \"argocd\"     },     \"spec\": {       \"project\": \"default\",       \"source\": {         \"repoURL\": \"https:\/\/your-argocd-instance\/helm.git\",         \"path\": \"vault-secrets-webhook\",         \"targetRevision\": \"master\",         \"helm\": {           \"parameters\": [             {\"name\": \"resources.limits.memory\", \"value\": \"256Mi\"},             {\"name\": \"resources.limits.cpu\", \"value\": \"250m\"}           ]         }       },       \"destination\": {         \"server\": \"https:\/\/kubernetes.default.svc\",         \"namespace\": \"test-app-yaml\"       },       \"syncPolicy\": {         \"automated\": {\"prune\": true, \"selfHeal\": true}       }     }   }' \\   https:\/\/your-argocd-instance\/api\/v1\/applications <\/code><\/pre>\n<p> \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e API \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"bash\">curl -X DELETE -H \"Authorization: Bearer $ARGOCD_TOKEN\" https:\/\/your-argocd-instance\/api\/v1\/applications\/test-api-app<\/code><\/pre>\n<h4>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 API ArgoCD \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Swagger<\/h4>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 API \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Swagger. \u0414\u043b\u044f \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 Swagger:<\/p>\n<pre><code class=\"bash\">https:\/\/your-argocd-instance\/swagger-ui<\/code><\/pre>\n<h3>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f Ansible \u0441 ArgoCD<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Ansible \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 ArgoCD.<\/p>\n<p>Ansible  \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 ArgoCD \u0447\u0435\u0440\u0435\u0437 \u043c\u043e\u0434\u0443\u043b\u044c URI, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c API \u0437\u0430\u043f\u0440\u043e\u0441\u044b.  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 1: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u00a0ArgoCD <\/p>\n<p>\u0412\u043e\u0442 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u043f\u043b\u0435\u0439\u0431\u0443\u043a Ansible \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 ArgoCD:<\/p>\n<pre><code class=\"yaml\">- hosts: localhost   tasks:     - name: Create ArgoCD application       uri:         url: \"https:\/\/{{ ARGOCD_URL }}\/api\/v1\/applications\"         method: POST         headers:           Authorization: \"Bearer {{ ARGOCD_TOKEN }}\"           Content-Type: \"application\/json\"         body_format: json         body:           metadata:             name: \"{{ APP_NAME }}\"             namespace: \"argocd\"           spec:             project: \"default\"             source:               repoURL: \"https:\/\/{{ ARGOCD_HELM_REPO }}\/stash\/scm\/do\/helm.git\"               path: \"vault-secrets-webhook\"               targetRevision: \"master\"               helm:                 parameters:                   - name: \"replicaCount\"                     value: \"1\"                   - name: \"env.VAULT_IMAGE\"                     value: \"vault:1.11.11\"                   - name: \"resources.limits.memory\"                     value: \"256Mi\"                   - name: \"resources.limits.cpu\"                     value: \"250m\"             destination:               server: \"https:\/\/kubernetes.default.svc\"               namespace: \"test-app-yaml\"             syncPolicy:               automated:                 prune: true                 selfHeal: true         return_content: yes         validate_certs: no       register: response      - name: Display API response       debug:         var: response.content <\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u043b\u0435\u0439\u0431\u0443\u043a\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0432\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435\u00a0<code>ARGOCD_URL<\/code>,\u00a0<code>ARGOCD_TOKEN<\/code>\u00a0\u0438\u00a0<code>APP_NAME<\/code>\u00a0\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 2: \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 ArgoCD<\/strong><\/p>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"yaml\">- hosts: localhost   tasks:   - name: Delete ArgoCD application     uri:       url: \"https:\/\/{{ ARGOCD_URL }}\/api\/v1\/applications\/{{ APP_NAME }}\"       method: DELETE       headers:         Authorization: \"Bearer {{ ARGOCD_TOKEN }}\"         Content-Type: \"application\/json\"       status_code: 200,202,204       validate_certs: no <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435\u00a0<code>ARGOCD_URL<\/code>,\u00a0<code>ARGOCD_TOKEN<\/code>\u00a0\u0438\u00a0<code>APP_NAME<\/code>\u00a0\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043b\u0435\u0439\u0431\u0443\u043a\u0430.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b Ansible \u0440\u043e\u043b\u0438<\/h4>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/p>\n<pre><code class=\"yaml\">roles\/app-k8s-deploy \u251c\u2500\u2500 defaults \u2502   \u2514\u2500\u2500 main.yaml \u251c\u2500\u2500 tasks \u2502   \u251c\u2500\u2500 create_application.yml \u2502   \u251c\u2500\u2500 delete_application.yml \u2502   \u2514\u2500\u2500 main.yaml<\/code><\/pre>\n<p>\u0412\u00a0<code>defaults\/main.yaml<\/code>\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<pre><code class=\"bash\">ARGOCD_URL: \"https:\/\/your-argocd-instance\" ARGOCD_TOKEN: \"\" ARGOCD_APP_NAME: \"test-api-app\" # ... (\u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435) <\/code><\/pre>\n<p>\u041f\u043b\u0435\u0439\u0431\u0443\u043a\u00a0<code>main.yaml<\/code>\u00a0\u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"yaml\">--- - name: Include create application tasks   include_tasks: create_application.yml   when: task == 'install'  - name: Include delete application tasks   include_tasks: delete_application.yml   when: task == 'delete' <\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438\u00a0<code>create_application.yml<\/code>\u00a0\u0438\u00a0<code>delete_application.yml<\/code>\u00a0\u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.<\/p>\n<h4>\u041f\u043b\u0435\u0439\u0431\u0443\u043a \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0440\u043e\u043b\u0438<\/h4>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0440\u043e\u043b\u044c \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043b\u0435\u0439\u0431\u0443\u043a\u0430<\/p>\n<pre><code class=\"yaml\">--- - hosts: \"{{ exec_hosts | default(['localhost']) | join(',') }}\"   roles:   - { role: app-k8s-deploy, task: install } <\/code><\/pre>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0438 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 ArgoCD \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible. \u0423\u0434\u0430\u0447\u043d\u043e\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438!<\/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\/articles\/819439\/\"> https:\/\/habr.com\/ru\/articles\/819439\/<\/a><br \/><\/br><\/br><\/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-378014","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378014","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=378014"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378014\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=378014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=378014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=378014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}