--- - name: Step 1 - Terraform Provisioning hosts: localhost connection: local gather_facts: false become: false tasks: - 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: Nuclear Cleanup shell: "rm -rf .terraform .terraform.lock.hcl" args: chdir: "{{ playbook_dir }}/../terraform" - 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: 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') }}" TF_VAR_proxmox_api_token_id: "{{ lookup('env', 'TF_VAR_proxmox_api_token_id') }}" 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 Apply Output debug: var: tf_result.stdout_lines - name: Step 2 - Dynamic Inventory & Setup hosts: localhost connection: local tasks: - name: Add hosts add_host: name: "{{ item }}" groups: k8s_new_nodes ansible_host: "{{ item }}" ansible_user: ubuntu loop: [10.33.33.201, 10.33.33.202, 10.33.33.203] - name: Step 3 - K8s Setup hosts: k8s_new_nodes gather_facts: false tasks: - name: Wait for SSH wait_for: host: "{{ inventory_hostname }}" port: 22 timeout: 300 delegate_to: localhost