Ansible proxmox_kvm IP config without using an cloud-init image

bdimitrov

New Member
Aug 8, 2024
1
0
1
Hi Community,
I am currently working on an automated rollout for UCS systems using Proxmox. To achieve this, Univention requires an existing network interface so that my Ansible playbooks can execute the profile setup and join setup to create a Primary Node (or at least test if the playbooks are executed at all).

According to the Ansible documentation, the only way to add an IP configuration is throughipconfig: ipconfig0: 'ip=<enter-ip-here/prefix>,gw=<gateway>
However, the image needs to be a cloud-init image to use the Ansible ipconfig attribute.

Another potential solution is to have a VM with the QEMU guest agent installed and try to configure the network interface.( which i tried but it didnt execute)
The VM loaded with the qcow2 image does not have the QEMU guest agent installed, and I am unsure how to add it since the image was provided to me
(There is a way to add it, but it defeats the purpose of the automatisation process, because you need to ssh into the VM and install from there)

Has anyone dealt with similar issues? What tips or solutions can you suggest to make this work?

Every bit of help is appreciated!

YAML:
---
- name: Creating Proxmox VM
  gather_facts: false
  hosts: [proxmox_host]
  serial: 1
  tasks:

    - name: Create a Virtual Machine with Template
      community.general.proxmox_kvm:
        api_user: 'api_user'
        api_host: host_ip
        api_token_id: 'token_id'
        api_token_secret: 'secret_token'
        node: 'node name'
        clone: 'VM-Template2'
        vmid: 104
        newid: 105
        full: yes
        name: UCS-Master
        timeout: 600
       
    - name: Add IP-adress to VM   #Does not work
      community.general.proxmox_kvm:
         api_user: 'api_user'
        api_host: host_ip
        api_token_id: 'token_id'
        api_token_secret: 'secret_token'
        node: 'node name'
        vmid: 105
        ipconfig:
          ipconfig0: 'ipv4/24, gw=gateway'
        nameservers:
          - 'gatewayip'
          - '8.8.4.4'
       
    - name: Update IP-Address of VM        #Also does not work because a cloud-init image is needed
      ansible.builtin.shell:
        cmd: qm set 105 --ipconfig0 ip=ipv4/24,gw=gatewayip
 
perhaps try a

YAML:
command:
  cmd:

and either append/edit the network configuration or create a file with the desired config and create a play to replace the the existing config file.
 

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!