How to configure network settings using Ansible (community.general.proxmox_kvm module)?

samo.goljat

New Member
Oct 25, 2024
1
0
1
I have managed to connect with API-user and clone virtual machine. With:


tasks:
- name: Clone VM from template
community.general.proxmox_kvm:
api_user: "{{ api_user }}"
api_password: "{{ proxmox_password }}"
api_host: "{{ api_host }}"
clone: AlmaT01 # Source VM name (template)
name: "{{ vm_name }}" # New target VM name
node: "{{ node }}" # Proxmox node
storage: dpve_LDisk01 # Storage backend
format: qcow2 # Disk format
timeout: 500 # Timeout for the operation
register: clone_result


But when it comes to configuring network parameters I can't seem to change them with this approach:

- name: Configure network settings
community.general.proxmox_kvm:
api_user: "{{ api_user }}"
api_password: "{{ proxmox_password }}"
api_host: "{{ api_host }}"
vmid: "{{ new_vmid }}"
node: "{{ node }}"
net:
model: virtio
bridge: vmbr10
ip: "{{ ip_address }}/24"
gw: "{{ gateway }}"
nameservers: "{{ dns_servers }}"
searchdomains: "{{ search_domain }}"
update: yes

https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_kvm_module.html

Am I doing it correctly (syntax-wise), or is there any other approach available for doing it.
The result I get from Ansible is:

TASK [Configure network settings] *****************************************************************************************************************************************************************************
changed: [localhost]

TASK [Verify network configuration via SSH (optional)] ********************************************************************************************************************************************************
fatal: [localhost -> 10.1.12.195]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 10.1.12.195 port 22: No route to host", "unreachable": true}

PLAY RECAP ****************************************************************************************************************************************************************************************************
localhost : ok=5 changed=3 unreachable=1 failed=0 skipped=1 rescued=0 ignored=0

So it seems it executes the task, but it does not assign properly IP address. (It uses DHCP).
I have also no clue, how to create so called Cloud-init image nor is in the options to use containers.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!