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

This commit is contained in:
2025-12-28 09:54:01 +00:00
parent f45d3ebb2a
commit 24d30805c5

View File

@@ -6,10 +6,6 @@
become: false become: false
tasks: tasks:
- name: Test DNS resolution
shell: host terraform-mirror.yandexcloud.net || ping -c 1 8.8.8.8
ignore_errors: true # Просто для информации в логах
- name: Create terraform mirror config - name: Create terraform mirror config
copy: copy:
dest: "/tmp/.terraformrc" dest: "/tmp/.terraformrc"
@@ -23,18 +19,26 @@
} }
} }
- name: Clean old terraform - name: Nuclear Cleanup
file: shell: "rm -rf .terraform .terraform.lock.hcl"
path: "{{ playbook_dir }}/../terraform/.terraform"
state: absent
- name: Terraform Init and Apply
shell: |
terraform init -reconfigure -upgrade -no-color && \
terraform apply -auto-approve -no-color -lock=false
args: args:
chdir: "{{ playbook_dir }}/../terraform" chdir: "{{ playbook_dir }}/../terraform"
register: tf_output
- name: Terraform Init
shell: terraform init -reconfigure -no-color
args:
chdir: "{{ playbook_dir }}/../terraform"
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') }}"
- name: Terraform Apply
shell: terraform apply -auto-approve -no-color -lock=false
args:
chdir: "{{ playbook_dir }}/../terraform"
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') }}"
@@ -44,41 +48,29 @@
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 Terraform Output - name: Show Apply Output
debug: debug:
var: tf_output.stdout_lines var: tf_result.stdout_lines
- name: Dynamically add hosts - name: Step 2 - Dynamic Inventory & Setup
hosts: localhost
connection: local
tasks:
- name: Add hosts
add_host: add_host:
name: "{{ item }}" name: "{{ item }}"
groups: k8s_new_nodes groups: k8s_new_nodes
ansible_host: "{{ item }}" ansible_host: "{{ item }}"
ansible_user: ubuntu ansible_user: ubuntu
loop: loop: [10.33.33.201, 10.33.33.202, 10.33.33.203]
- 10.33.33.201
- 10.33.33.202
- 10.33.33.203
- name: Step 2 - Install Kubernetes - name: Step 3 - K8s Setup
hosts: k8s_new_nodes hosts: k8s_new_nodes
gather_facts: false gather_facts: false
tasks: tasks:
- name: Wait for SSH to be ready - name: Wait for SSH
wait_for: wait_for:
host: "{{ inventory_hostname }}" host: "{{ inventory_hostname }}"
port: 22 port: 22
state: started
timeout: 300 timeout: 300
delegate_to: localhost delegate_to: localhost
become: false
- name: Now gather facts
setup:
become: true
- name: Install base packages
apt:
name: [curl, apt-transport-https, qemu-guest-agent]
state: present
update_cache: yes
become: true