ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
834 stars 1.54k forks source link

No `state: current` option available in the latest version of proxmox_kvm. (6.6.0) #6484

Open PC-Admin opened 1 year ago

PC-Admin commented 1 year ago

Summary

In the docs one of the available for options for state is apparently 'current':

https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_kvm_module.html#parameter-state

Yet this doesn't actually appear to be an option? This code:

    - name: Check if each VM already exists
      community.general.proxmox:
        api_user: "{{ proxmox_user }}"
        api_token_id: "{{ proxmox_token_id }}"
        api_token_secret: "{{ proxmox_token_secret }}"
        api_host: proxmox.estuary.tech
        node: "{{ proxmox_nodes[item % 8] }}"
        name: "{{ vm_name }}{{ '%02d' | format(item) }}"
        state: current
      loop: "{{ range(starting_number_target | int, vm_count | int + starting_number_target | int) | list }}"
      loop_control:
        index_var: loop_index
      ignore_errors: true
      register: vm_check

generates this error:

TASK [Check if each VM already exists] **********************************************************************************************************
failed: [localhost] (item=1) => {"ansible_index_var": "loop_index", "ansible_loop_var": "item", "changed": false, "item": 1, "loop_index": 0, "msg": "value of state must be one of: present, absent, stopped, started, restarted, got: current"}
failed: [localhost] (item=2) => {"ansible_index_var": "loop_index", "ansible_loop_var": "item", "changed": false, "item": 2, "loop_index": 1, "msg": "value of state must be one of: present, absent, stopped, started, restarted, got: current"}
failed: [localhost] (item=3) => {"ansible_index_var": "loop_index", "ansible_loop_var": "item", "changed": false, "item": 3, "loop_index": 2, "msg": "value of state must be one of: present, absent, stopped, started, restarted, got: current"}
...ignoring

Issue Type

Documentation Report

Component Name

proxmox_kvm

Ansible Version

$ ansible --version
ansible [core 2.14.3]
  config file = None
  configured module search path = ['/home/pcadmin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/pcadmin/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /home/pcadmin/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 6.6.0  

Configuration

(venv) pcadmin@workstation:~/MyVault/Estuary_LIVE/estuary-hosted-infrastructure$ ansible-config dump --only-changed
CONFIG_FILE() = None

OS / Environment

Debian 12 Bookworm

Steps to Reproduce

(see summary for code example) With code like this, and the latest community.general modules installed, try and query proxmox using state: current

Expected Results

That this option, as it's explained in the documentation, would actually exist/function. (or at least there would be no mention of it in the docs)

Actual Results

(see summary for error message)

Code of Conduct

ansibullbot commented 1 year ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 1 year ago

cc @Ajpantuso @Thulium-Drake @helldorado @joshainglis @karmab @tleguern click here for bot help

felixfontein commented 1 year ago

Looks like the documentation needs to be fixed and that wrong example be removed.

PC-Admin commented 1 year ago

Is there actually any way of probing if a VM exists with proxmox_kvm right now?

I'm very curious if anyone has an example that does work.

felixfontein commented 1 year ago

I created #6498 to remove that example. I cannot answer your question since I'm not familiar with the proxmox modules, maybe some of the module maintainers can answer this.

I'm leaving this issue open as a Feature Request for adding querying functionality. A proxmox_kvm_info module would surely be nice to have and should provide the information you need.

PC-Admin commented 1 year ago

I'm leaving this issue open as a Feature Request for adding querying functionality. A proxmox_kvm_info module would surely be nice to have and should provide the information you need.

That would be fantastic. :) Thank you for cleaning up these docs, it'll help other people experimenting with these modules.

ansibullbot commented 1 year ago

cc @UnderGreen click here for bot help

drewburr commented 1 year ago

Hey @felixfontein, I'm using state: current on 7.1.0 of community.general and this is working for me. I also just opened #6828 to add additional functionality to this state.

@PC-Admin it looks like you're using community.general.proxmox, when you'll actually want to use community.general.proxmox_kvm to get the state of a VM.

In my case, the task looks like the following:

- name: Get VM state
  community.general.proxmox_kvm:
    proxmox_default_behavior: no_defaults
    api_user: "{{ pmox_user }}"
    api_password: "{{ pmox_password }}"
    api_host: "{{ pmox_url }}"
    node: "{{ vm_node }}"
    name: "{{ vm_name }}"
    state: current
  register: vm_state
drewburr commented 1 year ago

It also looks like we had a small mix-up on #6498, since the module name being referenced by OP was community.general.proxmox. The example removed from community.general.proxmox_kvm is valid and working

felixfontein commented 1 year ago

Thanks for noticiting this! I've reverted the commit in #6832.

In any case, state current should be deprecated and removed and replaced by a proper proxmox_kvm_info module. And a proxmox_info module is apparently also missing...

felixfontein commented 1 year ago

Creating info modules isn't hard, so if someone wants to contribute one (or two)... :)

UnderGreen commented 1 year ago

@PC-Admin, @drewburr Done via https://github.com/ansible-collections/community.general/pull/6852. Let me know if the new module fits your needs.

ansibullbot commented 9 months ago

cc @krauthosting click here for bot help