Обновить ansible/deploy_all.yml
This commit is contained in:
@@ -8,41 +8,20 @@
|
|||||||
tf_dir: "{{ playbook_dir }}/../terraform"
|
tf_dir: "{{ playbook_dir }}/../terraform"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Create terraform mirror config
|
- name: Nuclear Cleanup (Full)
|
||||||
copy:
|
shell: "rm -rf .terraform .terraform.lock.hcl terraform.tfstate*"
|
||||||
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:
|
args:
|
||||||
chdir: "{{ tf_dir }}"
|
chdir: "{{ tf_dir }}"
|
||||||
|
|
||||||
- name: Terraform Init
|
- name: Terraform Init and Apply (Direct Access)
|
||||||
shell: terraform init -reconfigure -no-color
|
shell: |
|
||||||
|
terraform init -upgrade -no-color && \
|
||||||
|
terraform apply -auto-approve -no-color -lock=false
|
||||||
args:
|
args:
|
||||||
chdir: "{{ tf_dir }}"
|
chdir: "{{ tf_dir }}"
|
||||||
|
register: tf_out
|
||||||
environment:
|
environment:
|
||||||
TF_CLI_CONFIG_FILE: "/tmp/.terraformrc"
|
# Убираем TF_CLI_CONFIG_FILE, чтобы идти напрямую в registry.terraform.io
|
||||||
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_ADDRESS: "{{ lookup('env', 'TF_HTTP_ADDRESS') }}"
|
||||||
TF_HTTP_USERNAME: "{{ lookup('env', 'TF_HTTP_USERNAME') }}"
|
TF_HTTP_USERNAME: "{{ lookup('env', 'TF_HTTP_USERNAME') }}"
|
||||||
TF_HTTP_PASSWORD: "{{ lookup('env', 'TF_HTTP_PASSWORD') }}"
|
TF_HTTP_PASSWORD: "{{ lookup('env', 'TF_HTTP_PASSWORD') }}"
|
||||||
@@ -50,11 +29,11 @@
|
|||||||
TF_VAR_proxmox_api_token_secret: "{{ lookup('env', 'TF_VAR_proxmox_api_token_secret') }}"
|
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') }}"
|
TF_VAR_proxmox_api_url: "{{ lookup('env', 'TF_VAR_proxmox_api_url') }}"
|
||||||
|
|
||||||
- name: Show Apply Output
|
- name: Show Terraform Log
|
||||||
debug:
|
debug:
|
||||||
var: tf_result.stdout_lines
|
var: tf_out.stdout_lines
|
||||||
|
|
||||||
- name: Dynamically add hosts to inventory
|
- name: Dynamically add hosts
|
||||||
add_host:
|
add_host:
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
groups:
|
groups:
|
||||||
|
|||||||
Reference in New Issue
Block a user