Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxmox: module is trying to start an already started instance #9696

Open
1 task done
chemnic opened this issue Feb 6, 2025 · 4 comments
Open
1 task done

proxmox: module is trying to start an already started instance #9696

chemnic opened this issue Feb 6, 2025 · 4 comments
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)

Comments

@chemnic
Copy link

chemnic commented Feb 6, 2025

Summary

I upgraded to version 10.3 from 8.6, and now the the proxmox module fails
when state=started and instance is already started.

I tried with 10.3 and main branch.

Issue Type

Bug Report

Component Name

proxmox

Ansible Version

ansible [core 2.18.2]
  config file = /home/chestrada/repos/vfmsa_ansible/ansible.cfg
  configured module search path = ['/home/chestrada/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/chestrada/py_ansible/lib/python3.11/site-packages/ansible
  ansible collection location = /home/chestrada/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/chestrada/py_ansible/bin/ansible
  python version = 3.11.11 (main, Dec  4 2024, 08:55:08) [GCC 9.4.0] (/home/chestrada/py_ansible/bin/python)
  jinja version = 3.1.5
  libyaml = True

Community.general Version

# /home/chestrada/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 10.4.0 

# /home/chestrada/py_ansible/lib/python3.11/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 10.3.0 

Configuration

CACHE_PLUGIN(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = ~/ansible_cache_vfmsa
CACHE_PLUGIN_TIMEOUT(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = 3600
CONFIG_FILE() = /home/chestrada/repos/vfmsa_ansible/ansible.cfg
DEFAULT_CALLBACK_PLUGIN_PATH(env: ANSIBLE_CALLBACK_PLUGINS) = ['/home/chestrada/py_ansible/lib/python3.11/site-packages/ara/plugins/callback']
DEFAULT_FILTER_PLUGIN_PATH(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = ['/home/chestrada/repos/chem/ansible/plugins/filter', '/home/chestrada/repos/v>
DEFAULT_FORKS(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = 20
DEFAULT_GATHERING(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = smart
DEFAULT_INTERNAL_POLL_INTERVAL(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = 0.001
DEFAULT_LOOKUP_PLUGIN_PATH(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = ['/home/chestrada/repos/chem/ansible/plugins/lookup']
DEFAULT_PRIVATE_KEY_FILE(env: ANSIBLE_PRIVATE_KEY_FILE) = /home/chestrada/.ssh/ansible
DEFAULT_REMOTE_USER(env: ANSIBLE_REMOTE_USER) = admin_remote
DEFAULT_ROLES_PATH(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = ['/home/chestrada/repos/vfmsa_roles', '/home/chestrada/repos/chem_roles', '/home/chest>
DEFAULT_TIMEOUT(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = 50
DEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /home/chestrada/.ansible_vault_vfmsa
DIFF_ALWAYS(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = True
EDITOR(env: EDITOR) = vim
HOST_PATTERN_MISMATCH(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = ignore
INJECT_FACTS_AS_VARS(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = False
INVENTORY_CACHE_ENABLED(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = True
PERSISTENT_COMMAND_TIMEOUT(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = 200
PERSISTENT_CONNECT_TIMEOUT(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = 200
RETRY_FILES_SAVE_PATH(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = /home/chestrada/.ansible-retry
USE_PERSISTENT_CONNECTIONS(/home/chestrada/repos/vfmsa_ansible/ansible.cfg) = True

OS / Environment

Target server: Proxmox 8.3.3

Controller: Ubuntu 20.04

Steps to Reproduce

- name: Make sure LXC container is started
  community.general.proxmox:
    api_host: 192.168.1.11
    api_user: root@pam
    api_password: somepassword
    validate_certs: false
    state: started
    vmid: 924
  delegate_to: localhost

Expected Results

Ansible should be idempotent and not fail when the instance is already started.

Actual Results

fatal: [test1 -> localhost]: FAILED! => 
    changed: false
    msg: 'An error occurred: 500 Internal Server Error: CT 924 already running'

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

  • plugins/modules/proxmox

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
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) labels Feb 6, 2025
@russoz
Copy link
Collaborator

russoz commented Feb 7, 2025

Hi @chemnic thanks for reporting! Could you please paste the output with -vvvv in the ansible-playbook call?

@chemnic
Copy link
Author

chemnic commented Feb 10, 2025

Sorry for the delay.

Here you have it:

ansible-playbook [core 2.18.2]
  config file = /home/chestrada/repos/vfmsa_ansible/ansible.cfg
  configured module search path = ['/home/chestrada/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/chestrada/py_ansible/lib/python3.11/site-packages/ansible
  ansible collection location = /home/chestrada/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/chestrada/py_ansible/bin/ansible-playbook
  python version = 3.11.11 (main, Dec  4 2024, 08:55:08) [GCC 9.4.0] (/home/chestrada/py_ansible/bin/python)
  jinja version = 3.1.5
  libyaml = True
Using /home/chestrada/repos/vfmsa_ansible/ansible.cfg as config file
setting up inventory plugins
Loading collection ansible.builtin from 
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/05_role_hierarchy.yml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/05_role_hierarchy.yml as it did not pass its verify_file() method
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/05_role_hierarchy.yml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/10_app_vars.yml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/10_app_vars.yml as it did not pass its verify_file() method
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/10_app_vars.yml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/15_server_role.yml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/15_server_role.yml as it did not pass its verify_file() method
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/15_server_role.yml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/20_server_site.yml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/20_server_site.yml as it did not pass its verify_file() method
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/20_server_site.yml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/25_server_vars.toml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/25_server_vars.toml as it did not pass its verify_file() method
auto declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/25_server_vars.toml as it did not pass its verify_file() method
yaml declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/25_server_vars.toml as it did not pass its verify_file() method
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/25_server_vars.toml inventory source with toml plugin
setting up inventory plugins
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/30_other.yml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/30_other.yml as it did not pass its verify_file() method
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/30_other.yml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/40_constructed.yml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/40_constructed.yml as it did not pass its verify_file() method
Using inventory plugin 'ansible_collections.ansible.builtin.plugins.inventory.constructed' to process inventory source '/home/chestrada/repos/vfmsa_ansible/inv/prod/40_constructed.yml'
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/40_constructed.yml inventory source with auto plugin
setting up inventory plugins
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/50_init.yml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/50_init.yml as it did not pass its verify_file() method
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/50_init.yml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/51_lxd_instance.yml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/51_lxd_instance.yml as it did not pass its verify_file() method
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/51_lxd_instance.yml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/52_pve_instance.yml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/52_pve_instance.yml as it did not pass its verify_file() method
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/52_pve_instance.yml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/80_constructed.yml as it did not pass its verify_file() method
script declined parsing /home/chestrada/repos/vfmsa_ansible/inv/prod/80_constructed.yml as it did not pass its verify_file() method
Using inventory plugin 'ansible_collections.ansible.builtin.plugins.inventory.constructed' to process inventory source '/home/chestrada/repos/vfmsa_ansible/inv/prod/80_constructed.yml'
Parsed /home/chestrada/repos/vfmsa_ansible/inv/prod/80_constructed.yml inventory source with auto plugin
Loading collection community.general from /home/chestrada/.ansible/collections/ansible_collections/community/general
Loading callback plugin default of type stdout, v2.0 from /home/chestrada/py_ansible/lib/python3.11/site-packages/ansible/plugins/callback/default.py
Loading callback plugin ara_default of type awesome, v2.0 from /home/chestrada/py_ansible/lib/python3.11/site-packages/ara/plugins/callback/ara_default.py
Operations to perform:
  Apply all migrations: admin, api, auth, contenttypes, db, sessions
Running migrations:
  No migrations to apply.
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: test1.yml *****************************************************************************************************************************************
Positional arguments: ./playbook_misc/test1.yml
verbosity: 4
private_key_file: /home/chestrada/.ssh/ansible
remote_user: admin_remote
connection: ssh
become_method: sudo
tags: ('all',)
diff: True
inventory: ('/home/chestrada/repos/vfmsa_ansible/inv/prod',)
subset: test1
forks: 20
1 plays in ./playbook_misc/test1.yml

PLAY [Play] *************************************************************************************************************************************************

TASK [Make sure LXC container is started] *******************************************************************************************************************
task path: /home/chestrada/repos/vfmsa_ansible/playbook_misc/test1.yml:8
File lookup using /home/chestrada/repos/secrets/hosts/non_persistent/vfm1-pves-01/linux_root as file
Trying secret FileVaultSecret(filename='/home/chestrada/.ansible_vault_vfmsa') for vault_id=default
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: chestrada
<localhost> EXEC /bin/sh -c 'echo ~chestrada && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/chestrada/.ansible/tmp `"&& mkdir "` echo /home/chestrada/.ansible/tmp/ansible-tmp-1739194103.697018-3732642-177334031886044 `" && echo ansible-tmp-1739194103.697018-3732642-177334031886044="` echo /home/chestrada/.ansible/tmp/ansible-tmp-1739194103.697018-3732642-177334031886044 `" ) && sleep 0'
Using module file /home/chestrada/.ansible/collections/ansible_collections/community/general/plugins/modules/proxmox.py
<localhost> PUT /home/chestrada/.ansible/tmp/ansible-local-3732599k29gy45j/tmp45q9p95h TO /home/chestrada/.ansible/tmp/ansible-tmp-1739194103.697018-3732642-177334031886044/AnsiballZ_proxmox.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/chestrada/.ansible/tmp/ansible-tmp-1739194103.697018-3732642-177334031886044/ /home/chestrada/.ansible/tmp/ansible-tmp-1739194103.697018-3732642-177334031886044/AnsiballZ_proxmox.py && sleep 0'
<localhost> EXEC /bin/sh -c 'no_proxy=192.168.1.11 /home/chestrada/py_ansible/bin/python /home/chestrada/.ansible/tmp/ansible-tmp-1739194103.697018-3732642-177334031886044/AnsiballZ_proxmox.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/chestrada/.ansible/tmp/ansible-tmp-1739194103.697018-3732642-177334031886044/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_community.general.proxmox_payload__fdul2e6/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/modules/proxmox.py", line 1732, in main
    proxmox.run()
  File "/tmp/ansible_community.general.proxmox_payload__fdul2e6/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/modules/proxmox.py", line 800, in run
    self.lxc_started(
  File "/tmp/ansible_community.general.proxmox_payload__fdul2e6/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/modules/proxmox.py", line 954, in lxc_started
    self.start_lxc_instance(vmid, node, timeout)
  File "/tmp/ansible_community.general.proxmox_payload__fdul2e6/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/modules/proxmox.py", line 1307, in start_lxc_instance
    taskid = getattr(proxmox_node, self.VZ_TYPE)(vmid).status.start.post()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chestrada/py_ansible/lib/python3.11/site-packages/proxmoxer/core.py", line 170, in post
    return self(args)._request("POST", data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chestrada/py_ansible/lib/python3.11/site-packages/proxmoxer/core.py", line 147, in _request
    raise ResourceException(
fatal: [test1 -> localhost]: FAILED! => 
    changed: false
    invocation:
        module_args:
            api_host: 192.168.1.11
            api_password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
            api_port: null
            api_token_id: null
            api_token_secret: null
            api_user: root@pam
            clone: null
            clone_type: opportunistic
            cores: null
            cpus: null
            cpuunits: null
            description: null
            disk: null
            disk_volume: null
            features: null
            force: false
            hookscript: null
            hostname: null
            ip_address: null
            memory: null
            mount_volumes: null
            mounts: null
            nameserver: null
            netif: null
            node: null
            onboot: null
            ostemplate: null
            ostype: auto
            password: null
            pool: null
            pubkey: null
            purge: false
            searchdomain: null
            startup: null
            state: started
            storage: local
            swap: null
            tags: null
            timeout: 30
            timezone: null
            unprivileged: true
            update: null
            validate_certs: false
            vmid: 924
    msg: 'An error occurred: 500 Internal Server Error: CT 924 already running'

PLAY RECAP **************************************************************************************************************************************************
test1                      : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   


Note: there was a typo in the original report: api_host: 192.168.1.11", with an extra quotation mark at the end. I fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)
Projects
None yet
Development

No branches or pull requests

3 participants