From 89aac926e607b62051c8430fd3111578c8d4b866 Mon Sep 17 00:00:00 2001 From: ogrechko Date: Sun, 28 Dec 2025 10:28:47 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20ansible/deploy=5Fall.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ansible/deploy_all.yml | 43 +++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/ansible/deploy_all.yml b/ansible/deploy_all.yml index feb8686..24d0c7d 100644 --- a/ansible/deploy_all.yml +++ b/ansible/deploy_all.yml @@ -8,20 +8,41 @@ tf_dir: "{{ playbook_dir }}/../terraform" tasks: - - name: Nuclear Cleanup (Full) - shell: "rm -rf .terraform .terraform.lock.hcl terraform.tfstate*" + - name: Create terraform mirror config + copy: + dest: "/tmp/.terraformrc" + content: | + provider_installation { + network_mirror { + url = "https://terraform-mirror.yandexcloud.net/" + } + direct { + exclude = ["registry.terraform.io/*/*"] + } + } + + - name: Total Cleanup + shell: "rm -rf .terraform .terraform.lock.hcl" args: chdir: "{{ tf_dir }}" - - name: Terraform Init and Apply - shell: | - terraform init -reconfigure -upgrade -no-color && \ - terraform apply -auto-approve -no-color -lock=false + - name: Terraform Init + shell: terraform init -reconfigure -no-color args: chdir: "{{ tf_dir }}" - register: tf_out environment: - # Убираем TF_CLI_CONFIG_FILE, чтобы идти напрямую в registry.terraform.io + TF_CLI_CONFIG_FILE: "/tmp/.terraformrc" + TF_HTTP_ADDRESS: "{{ lookup('env', 'TF_HTTP_ADDRESS') }}" + TF_HTTP_USERNAME: "{{ lookup('env', 'TF_HTTP_USERNAME') }}" + TF_HTTP_PASSWORD: "{{ lookup('env', 'TF_HTTP_PASSWORD') }}" + + - name: Terraform Apply + shell: terraform apply -auto-approve -no-color -lock=false + args: + chdir: "{{ tf_dir }}" + register: tf_result + environment: + TF_CLI_CONFIG_FILE: "/tmp/.terraformrc" TF_HTTP_ADDRESS: "{{ lookup('env', 'TF_HTTP_ADDRESS') }}" TF_HTTP_USERNAME: "{{ lookup('env', 'TF_HTTP_USERNAME') }}" TF_HTTP_PASSWORD: "{{ lookup('env', 'TF_HTTP_PASSWORD') }}" @@ -29,11 +50,11 @@ TF_VAR_proxmox_api_token_secret: "{{ lookup('env', 'TF_VAR_proxmox_api_token_secret') }}" TF_VAR_proxmox_api_url: "{{ lookup('env', 'TF_VAR_proxmox_api_url') }}" - - name: Show Terraform Log + - name: Show Apply Output debug: - var: tf_out.stdout_lines + var: tf_result.stdout_lines - - name: Dynamically add hosts + - name: Dynamically add hosts to inventory add_host: name: "{{ item.name }}" groups: