--- - 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://registry.tf-mirror.ru/" } direct { exclude = ["registry.terraform.io/*/*"] } } - name: Clean old terraform file: 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: chdir: "{{ playbook_dir }}/../terraform" register: tf_output 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 Terraform Output debug: var: tf_output.stdout_lines - name: Dynamically 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 2 - Install Kubernetes hosts: k8s_new_nodes gather_facts: false tasks: - name: Wait for SSH to be ready wait_for: host: "{{ inventory_hostname }}" port: 22 state: started timeout: 300 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