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

community.vmware.vmware_guest_disk: changing "disk_mode" has no effect #2096

Open
Shiroi opened this issue Jun 19, 2024 · 0 comments
Open

community.vmware.vmware_guest_disk: changing "disk_mode" has no effect #2096

Shiroi opened this issue Jun 19, 2024 · 0 comments

Comments

@Shiroi
Copy link

Shiroi commented Jun 19, 2024

SUMMARY

I try to change the disk_mode on an existing vm disk. If the disk is "independent_persistent" and I want to change it to "persistent" no change will be made. Other combinations also won't work.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.vmware.vmware_guest_disk

ANSIBLE VERSION
ansible [core 2.17.0]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION
Collection        Version
----------------- -------
ansible.utils     4.1.0
community.general 9.0.1
community.vmware  4.4.0
CONFIGURATION
ANSIBLE_PIPELINING(/etc/ansible/ansible.cfg) = True
CONFIG_FILE() = /etc/ansible/ansible.cfg
DEFAULT_JINJA2_NATIVE(/etc/ansible/ansible.cfg) = True
OS / ENVIRONMENT

vSphere 7u3r with ESXi 7.0u3q
Tried different VM hardware versions and different controllers (SCSI, NVME)

STEPS TO REPRODUCE

Create a virtual machine with an harddisk configured to disk_mode "independent_persistent".

---

- name: Reconfigure all disks to persistent
  hosts: '*'
  connection: local
  gather_facts: false
  tasks:
    - name: Gather disk info from VM
      community.vmware.vmware_guest_disk_info:
        hostname: "{{ vc }}"
        username: "{{ vcUser }}"
        password: "{{ vcPassword }}"
        datacenter: "{{ datacenter }}"
        name: "{{ vm }}"
      register: disk_info

    - name: Set Disk to persistent
      community.vmware.vmware_guest_disk:
        hostname: "{{ vc }}"
        username: "{{ vcUser }}"
        password: "{{ vcPassword }}"
        datacenter: "{{ datacenter }}"
        name: "{{ vm }}"
        disk:
          - controller_number: "{{ item.value.controller_bus_number }}"
            controller_type: "{{ item.value.controller_type }}"
            unit_number: "{{ item.value.unit_number }}"
            size_kb: "{{ item.value.capacity_in_kb }}"
            disk_mode: "persistent"
      loop: "{{ disk_info.guest_disk_info | dict2items }}"
EXPECTED RESULTS

All hard disks should be reconfigured to "persistent".

ACTUAL RESULTS

The hard disk won't be changed. The module just reports "ok".

ansible-playbook [core 2.17.0]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Loading collection ansible.builtin from
Set default localhost to localhost
Parsed localhost, inventory source with host_list plugin
Loading collection community.vmware from /root/.ansible/collections/ansible_collections/community/vmware
Loading callback plugin default of type stdout, v2.0 from /usr/local/lib/python3.10/dist-packages/ansible/plugins/callback/default.py
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: Set_Harddisks_Persistant.yml *********************************************************************************
Positional arguments: Set_Harddisks_Persistant.yml
verbosity: 4
connection: ssh
become_method: sudo
tags: ('all',)
inventory: ('localhost,',)
extra_vars: ('vm=test_ansible vc=myVCENTER datacenter=myDatacenter vcUser=myUser vcPassword=myPassword',)
forks: 5
1 plays in Set_Harddisks_Persistant.yml

PLAY [Reconfigure all disks to persistent] *****************************************************************************

TASK [Gather disk info from VM] ****************************************************************************************
task path: /Set_Harddisks_Persistant.yml:8
<localhost> Attempting python interpreter discovery
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'python3.12'"'"'; command -v '"'"'python3.11'"'"'; command -v '"'"'python3.10'"'"'; command -v '"'"'python3.9'"'"'; command -v '"'"'python3.8'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python3'"'"'; echo ENDFOUND && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3.10 && sleep 0'
<localhost> Python interpreter discovery fallback (unsupported Linux distribution: ubuntu)
Using module file /root/.ansible/collections/ansible_collections/community/vmware/plugins/modules/vmware_guest_disk_info.py
Pipelining is enabled.
<localhost> EXEC /bin/sh -c '/usr/bin/python3.10 && sleep 0'
[WARNING]: Platform linux on host localhost is using the discovered Python interpreter at /usr/bin/python3.10, but
future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible-core/2.17/reference_appendices/interpreter_discovery.html for more information.
ok: [localhost] => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3.10"
    },
    "changed": false,
    "guest_disk_info": {
        "0": {
            "backing_datastore": "myLUN",
            "backing_disk_mode": "independent_persistent",
            "backing_diskmode": "independent_persistent",
            "backing_eagerlyscrub": false,
            "backing_filename": "[myLUN] test_ansible/test_ansible.vmdk",
            "backing_sharing": "sharingNone",
            "backing_thinprovisioned": false,
            "backing_type": "FlatVer2",
            "backing_uuid": "6000C291-fc3f-7b00-1bb7-4fb9d914d4de",
            "backing_writethrough": false,
            "capacity_in_bytes": 17179869184,
            "capacity_in_kb": 16777216,
            "controller_bus_number": 0,
            "controller_key": 1000,
            "controller_type": "paravirtual",
            "iolimit_limit": -1,
            "iolimit_shares_level": "normal",
            "iolimit_shares_limit": 1000,
            "key": 2000,
            "label": "Hard disk 1",
            "shares_level": "normal",
            "shares_limit": 1000,
            "summary": "16,777,216 KB",
            "unit_number": 0
        }
    },
    "invocation": {
        "module_args": {
            "datacenter": "myDatacenter",
            "folder": null,
            "hostname": "myVCENTER",
            "moid": null,
            "name": "test_ansible",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "proxy_host": null,
            "proxy_port": null,
            "use_instance_uuid": false,
            "username": "myUser",
            "uuid": null,
            "validate_certs": true
        }
    }
}

TASK [Set Disk to persistent] ******************************************************************************************
task path: /Set_Harddisks_Persistant.yml:17
Using module file /root/.ansible/collections/ansible_collections/community/vmware/plugins/modules/vmware_guest_disk.py
Pipelining is enabled.
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '/usr/bin/python3.10 && sleep 0'
ok: [localhost] => (item={'key': '0', 'value': {'key': 2000, 'label': 'Hard disk 1', 'summary': '16,777,216 KB', 'backing_filename': '[myLUN] test_ansible/test_ansible.vmdk', 'backing_datastore': 'myLUN', 'backing_sharing': 'sharingNone', 'backing_uuid': '6000C291-fc3f-7b00-1bb7-4fb9d914d4de', 'backing_writethrough': False, 'backing_diskmode': 'independent_persistent', 'backing_disk_mode': 'independent_persistent', 'iolimit_limit': -1, 'iolimit_shares_level': 'normal', 'iolimit_shares_limit': 1000, 'shares_level': 'normal', 'shares_limit': 1000, 'controller_key': 1000, 'unit_number': 0, 'capacity_in_kb': 16777216, 'capacity_in_bytes': 17179869184, 'backing_type': 'FlatVer2', 'backing_thinprovisioned': False, 'backing_eagerlyscrub': False, 'controller_bus_number': 0, 'controller_type': 'paravirtual'}}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "disk_changes": {},
    "disk_data": {
        "0": {
            "backing_datastore": "myLUN",
            "backing_disk_mode": "independent_persistent",
            "backing_diskmode": "independent_persistent",
            "backing_eagerlyscrub": false,
            "backing_filename": "[myLUN] test_ansible/test_ansible.vmdk",
            "backing_sharing": "sharingNone",
            "backing_thinprovisioned": false,
            "backing_type": "FlatVer2",
            "backing_uuid": "6000C291-fc3f-7b00-1bb7-4fb9d914d4de",
            "backing_writethrough": false,
            "capacity_in_bytes": 17179869184,
            "capacity_in_kb": 16777216,
            "controller_bus_number": 0,
            "controller_key": 1000,
            "controller_type": "paravirtual",
            "iolimit_limit": -1,
            "iolimit_shares_level": "normal",
            "iolimit_shares_limit": 1000,
            "key": 2000,
            "label": "Hard disk 1",
            "shares_level": "normal",
            "shares_limit": 1000,
            "summary": "16,777,216 KB",
            "unit_number": 0
        }
    },
    "invocation": {
        "module_args": {
            "datacenter": "myDatacenter",
            "disk": [
                {
                    "autoselect_datastore": null,
                    "bus_sharing": "noSharing",
                    "cluster_disk": false,
                    "compatibility_mode": null,
                    "controller_number": 0,
                    "controller_type": "paravirtual",
                    "datastore": null,
                    "destroy": true,
                    "disk_mode": "persistent",
                    "filename": null,
                    "iolimit": null,
                    "rdm_path": null,
                    "scsi_controller": null,
                    "scsi_type": null,
                    "shares": null,
                    "sharing": false,
                    "size": null,
                    "size_gb": null,
                    "size_kb": 16777216,
                    "size_mb": null,
                    "size_tb": null,
                    "state": "present",
                    "type": null,
                    "unit_number": 0
                }
            ],
            "folder": null,
            "hostname": "myVCENTER",
            "moid": null,
            "name": "test_ansible",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "proxy_host": null,
            "proxy_port": null,
            "use_instance_uuid": false,
            "username": "myUser",
            "uuid": null,
            "validate_certs": true
        }
    },
    "item": {
        "key": "0",
        "value": {
            "backing_datastore": "myLUN",
            "backing_disk_mode": "independent_persistent",
            "backing_diskmode": "independent_persistent",
            "backing_eagerlyscrub": false,
            "backing_filename": "[myLUN] test_ansible/test_ansible.vmdk",
            "backing_sharing": "sharingNone",
            "backing_thinprovisioned": false,
            "backing_type": "FlatVer2",
            "backing_uuid": "6000C291-fc3f-7b00-1bb7-4fb9d914d4de",
            "backing_writethrough": false,
            "capacity_in_bytes": 17179869184,
            "capacity_in_kb": 16777216,
            "controller_bus_number": 0,
            "controller_key": 1000,
            "controller_type": "paravirtual",
            "iolimit_limit": -1,
            "iolimit_shares_level": "normal",
            "iolimit_shares_limit": 1000,
            "key": 2000,
            "label": "Hard disk 1",
            "shares_level": "normal",
            "shares_limit": 1000,
            "summary": "16,777,216 KB",
            "unit_number": 0
        }
    }
}

PLAY RECAP *************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant