Check_mode is not working for vmware_rest api module

62 views
Skip to first unread message

Deepak B K

unread,
Jun 6, 2023, 4:42:04 AM6/6/23
to Ansible Project
We are testing  ansible vmware module were we wanted to test in dry run mode the playbooks which has vmware rest modules used and we see the --check  or check_mode = yes is not working  its deletes the vm  where its except to just dry run the task . Just wanted to understand the dryrun works for vmware modules?

Thanks 
Deepak Kumar

Andrew Latham

unread,
Jun 6, 2023, 9:06:46 AM6/6/23
to ansible...@googlegroups.com
Deepak

You may get more responses if you provide actual examples in the form of playbook/task/role you are attempting. Please also identify the Ansible version and the VMWare module/version you are using.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4a885873-a30e-48c9-bb69-8f93975e924bn%40googlegroups.com.


--
- Andrew "lathama" Latham -

Deepak B K

unread,
Jun 7, 2023, 3:17:43 AM6/7/23
to Ansible Project
Hi  Andrew, 

Please find the details . 
COMPONENT NAME

vmware.vmware_rest.vcenter_vm:

ANSIBLE VERSION
config file = None configured module search path = ['/home/deep/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/deep/.local/lib/python3.10/site-packages/ansible ansible collection location = /home/deep/.ansible/collections:/usr/share/ansible/collections executable location = /home/deep/.local/bin/ansible python version = 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] jinja version = 3.1.2 libyaml = True
COLLECTION VERSION

`# /home/deep/.ansible/collections/ansible_collections
Collection Version

vmware.vmware_rest 2.3.1

##### CONFIGURATION <!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes --> ```paste below
OS / ENVIRONMENT

PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

STEPS TO REPRODUCE

Try to dry run the playbook delvm.yml
ansible-playbook delvm.yml --check -i inventory --limit test-host

--

  • name: Delete VM
    hosts: all
    gather_facts: false
    become: false

    tasks:

Lookup VM ID from the vm name

- name: "Lookup VM: {{ vm_name }}" vmware.vmware_rest.vcenter_vm_info: vcenter_hostname: "{{ vcenter.hostname }}" vcenter_username: "{{ vcenter.username }}" vcenter_password: "{{ vcenter.password }}" vcenter_validate_certs: "{{ vcenter.validate_certs }}" filter_names: "{{ vm_name }}" register: lookup_result delegate_to: "{{ delegation_host }}"
Collect VM ID from the vm name
- name: "Collect information about VM: {{ vm_name }}" vmware.vmware_rest.vcenter_vm_info: vcenter_hostname: "{{ vcenter.hostname }}" vcenter_username: "{{ vcenter.username }}" vcenter_password: "{{ vcenter.password }}" vcenter_validate_certs: "{{ vcenter.validate_certs }}" vm: "{{ lookup_result.value[0].vm }}" register: vm_info delegate_to: "{{ delegation_host }}"
@title Delete VM@comment This task deletes the VM from the vcenter

- name: "Delete VM: {{ vm_name }}" vmware.vmware_rest.vcenter_vm: vcenter_hostname: "{{ vcenter.hostname }}" vcenter_username: "{{ vcenter.username }}" vcenter_password: "{{ vcenter.password }}" vcenter_validate_certs: "{{ vcenter.validate_certs }}" state: absent vm: "{{ vm_info.id }}" delegate_to: "{{ delegation_host }}"
<!--- HINT: You can paste gist.github.com links for larger files --> ##### EXPECTED RESULTS excepted result its should not remove the vm and just dry run the steps but unfortunately with option --check it is removing the vm in vcenter not performing dry run.

Stefan Schnell

unread,
Apr 11, 2024, 8:57:01 AM4/11/24
to Ansible Project
Hello Deepak,
I am also currently considering with the question you raised. As far as I can say at the moment is the supports_check_mode parameter is always set to true, but the check_mode is not queried or checked anywhere. This means that it is indicated that the check mode is supported, although it is not. The --check parameter therefore has no effect. The check mode is not supported.
Best regards
Stefan

Reply all
Reply to author
Forward
0 new messages