community.general icon indicating copy to clipboard operation
community.general copied to clipboard

proxmox_kvm : ipconfig "gw not in schema"

Open fxrsliberty opened this issue 2 months ago • 5 comments

Summary

when cloning a cloud-init template I am unable to pass the "ipconfig0" information as documented. https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_kvm_module.html#parameter-ipconfig

cloud-init: Set the IP configuration. A hash/dictionary of network ip configurations. ipconfig='{"key":"value", "key":"value"}'. Keys allowed are - ipconfig[n] where 0 ≤ n ≤ network interfaces. Values allowed are - "[gw=<GatewayIPv4>] [,gw6=<GatewayIPv6>] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>]".

Issue Type

Bug Report

Component Name

proxmox_kvm.py ipconfig

Ansible Version

$ ansible --version
jtremblay@alma-lptp pve_vms]$ ansible --version
ansible [core 2.15.10]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/jtremblay/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/jtremblay/.local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/jtremblay/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/jtremblay/.local/bin/ansible
  python version = 3.9.18 (main, Jan  4 2024, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
[jtremblay@alma-lptp pve_vms]$ ansible-galaxy collection list community.general

# /home/jtremblay/.local/lib/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 7.5.2  

# /usr/lib/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 6.6.2  

# /usr/share/ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 7.5.0  

Configuration

[jtremblay@alma-lptp pve_vms]$ ansible-config dump --only-changed CONFIG_FILE() = /etc/ansible/ansible.cfg

[jtremblay@alma-lptp pve_vms]$ cat /etc/ansible/ansible.cfg

Since Ansible 2.12 (core):

To generate an example config file (a "disabled" one with all default settings, commented out):

$ ansible-config init --disabled > ansible.cfg

Also you can now have a more complete file by including existing plugins:

ansible-config init --disabled -t all > ansible.cfg

For previous versions of Ansible you can check for examples in the 'stable' branches of each version

Note that this file was always incomplete and lagging changes to configuration settings

for example, for 2.9: https://github.com/ansible/ansible/blob/stable-2.9/examples/ansible.cfg

[jtremblay@alma-lptp pve_vms]$

SEE STEPS TO REPRODUCE

OS / Environment

PVE quest on Proxmox 8.1.10 quest OS Alma 9.3 cloud init image

Steps to Reproduce

---

- name: Clone template
  hosts: localhost
  gather_facts: true
  vars_prompt:

    - name: "api_host"
      prompt: "PVE API host?: "
      default: "kvmh0"
      private: false

    - name: "pve_node"
      prompt: "PVE target node?: "
      default: "kvmh0"
      private: false

    - name: "api_user"
      prompt: "PVE API user?: "
      default: "root@pam"
      private: false

    - name: "api_token_id"
      prompt: "PVE API Token ID?: "
      default: "ansible_api"
      private: false

    - name: "api_password"
      prompt: "PVE API password?: "
      default: ""
      private: true

    - name: "api_token_secret"
      prompt: "PVE API Token secret?: "
      default: ""
      private: true

    - name: "vmname"
      prompt: "vmname?: "
      default: ""
      private: false

    - name: "vmid"
      prompt: "vmid?: "
      default: ""
      private: false

    - name: "ip_address"
      prompt: "ip_address(there are 26 available starting with default?:"
      default: "192.168.1.169"
      private: false

    - name: "subnet_mask"
      prompt: "subnet_mask_cidr?:"
      default: "24"
      private: false

    - name: "gateway"
      prompt: "gateway?:"
      default: "192.168.1.1"
      private: false


  tasks:
    - name: Clone template
      community.general.proxmox_kvm:
        node: "{{ pve_node }}"
        api_user: "{{ api_user }}"
        api_password: "{{ api_password }}"
        api_host: "{{ api_host }}"
        clone: 'alma9-cloud'
        vmid: "{{ 9999 }}"
        name: "{{ vmname }}"
        newid: '{{ vmid }}'
        full: true
        storage: 'nas_vm'
        format: qcow2
        timeout: 500

    - name: Wait on VM creation
      pause:
        seconds: 10  # waiting until vm is created

    - name: Update
      community.general.proxmox_kvm:
        node: "{{ pve_node }}"
        api_host: "{{ api_host }}"
        api_user: "{{ api_user }}"
        api_password: "{{ api_password }}"
        name: "{{ vmname }}"
        ipconfig:
          ipconfig0: ip={{ ip_address }}/{{ subnet_mask }}, gw={{ gateway }}
        update: true


    - name: Start VM
      community.general.proxmox_kvm:
        api_user: "{{ api_user }}"
        api_password: "{{ api_password }}"
        api_host: "{{ api_host }}"
        node: "{{ pve_node }}"
        name: "{{ vmname }}"
        state: started

Expected Results


expected target VM to have IP address with gateway changed from DHCP to Static

Actual Results

    "msg": "Unable to update vm test102 with vmid 101102=400 Bad Request: Parameter verification failed. - {'ipconfig0': 'invalid format - format error\\nipconfig0. gw: property is not defined in schema and the schema does not allow additional properties\\n'}",



### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct

fxrsliberty avatar Apr 21 '24 21:04 fxrsliberty