From 0416180e3e624c18456085ddc1fa7b9abf929022 Mon Sep 17 00:00:00 2001 From: Maxim Vershinin Date: Fri, 14 Aug 2026 15:34:27 +0400 Subject: [PATCH] FEATURE: adds cloud-init in roles/deploy_vm_on_proxmox --- roles/deploy_vm_on_proxmox/tasks/main.yaml | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/roles/deploy_vm_on_proxmox/tasks/main.yaml b/roles/deploy_vm_on_proxmox/tasks/main.yaml index 392bdfd..a451dee 100644 --- a/roles/deploy_vm_on_proxmox/tasks/main.yaml +++ b/roles/deploy_vm_on_proxmox/tasks/main.yaml @@ -23,6 +23,32 @@ delegate_to: localhost changed_when: false +- name: Update the cloned VM with cloud-init configuration + community.proxmox.proxmox_kvm: + validate_certs: false + node: proxmox-server + api_user: root@pam + api_host: 192.168.0.2 + api_token_id: ansible + api_token_secret: "{{ proxmox_token_secret }}" + + name: "{{ vm_hostname }}" + # Cloud-init parameters + update: true + ide: + ide2: "local:cloudinit,format=qcow2" + ciuser: "ansible" + cipassword: "{{ ansible_become_passwd }}" + ipconfig: + ipconfig0: "ip={{ vm_ip_address }},gw=192.168.0.1" + +- name: Sleep for 20 seconds just to make sure that all settings are applied + become: false + ansible.builtin.wait_for: + timeout: 20 + delegate_to: localhost + changed_when: false + - name: Tweak the hardware settings become: false community.proxmox.proxmox_kvm: @@ -51,3 +77,10 @@ name: "{{ vm_hostname }}" state: started +- name: Sleep for 2 minutes to make sure that VM has started and cloud init has done its thing + become: false + ansible.builtin.wait_for: + timeout: 120 + delegate_to: localhost + changed_when: false +