Обновить ansible/deploy_all.yml

This commit is contained in:
2025-12-28 10:11:07 +00:00
parent 6e270bbbef
commit 26ad048c76

View File

@@ -22,7 +22,7 @@
} }
- name: Total Cleanup - name: Total Cleanup
shell: "rm -rf .terraform .terraform.lock.hcl terraform.tfstate*" shell: "rm -rf .terraform .terraform.lock.hcl"
args: args:
chdir: "{{ tf_dir }}" chdir: "{{ tf_dir }}"
@@ -40,6 +40,7 @@
shell: terraform apply -auto-approve -no-color -lock=false shell: terraform apply -auto-approve -no-color -lock=false
args: args:
chdir: "{{ tf_dir }}" chdir: "{{ tf_dir }}"
register: tf_result
environment: environment:
TF_CLI_CONFIG_FILE: "/tmp/.terraformrc" TF_CLI_CONFIG_FILE: "/tmp/.terraformrc"
TF_HTTP_ADDRESS: "{{ lookup('env', 'TF_HTTP_ADDRESS') }}" TF_HTTP_ADDRESS: "{{ lookup('env', 'TF_HTTP_ADDRESS') }}"
@@ -49,30 +50,32 @@
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
debug:
var: tf_result.stdout_lines
- name: Dynamically add hosts to Ansible memory - name: Dynamically add hosts to inventory
add_host: add_host:
name: "{{ item.name }}" name: "{{ item.name }}"
groups: groups:
- k8s_new_nodes - k8s_new_nodes
- "{{ 'masters' if 'master' in item.name else 'workers' }}" - "{{ 'masters' if 'master' in item.name else 'workers' }}"
ansible_host: "{{ item.ip }}" ansible_host: "{{ item.ip }}"
ansible_user: ubuntu # ИСПОЛЬЗУЕМ ubuntu ИЗ CLOUD-INIT ansible_user: ubuntu
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no" ansible_ssh_extra_args: "-o StrictHostKeyChecking=no"
loop: loop:
- { name: 'master-01', ip: '10.33.33.201' } - { name: 'k8s-master', ip: '10.33.33.201' }
- { name: 'worker-01', ip: '10.33.33.202' } - { name: 'k8s-worker-1', ip: '10.33.33.202' }
- { name: 'worker-02', ip: '10.33.33.203' } - { name: 'k8s-worker-2', ip: '10.33.33.203' }
- name: Step 2 - Wait for SSH and Prepare - name: Step 2 - Wait for SSH
hosts: k8s_new_nodes hosts: k8s_new_nodes
gather_facts: false gather_facts: false
tasks: tasks:
- name: Wait for SSH to be ready on new VMs - name: Wait for SSH to be ready
wait_for_connection: wait_for_connection:
delay: 10 delay: 10
timeout: 300 timeout: 300
# Step 3 - Запускаем твой основной плейбук установки K8s - name: Step 3 - K8s Setup
- name: Step 3 - Install Kubernetes Cluster
import_playbook: k8s_setup.yml import_playbook: k8s_setup.yml