vmware_guest module with disk extra parameter

44 views
Skip to first unread message

Daniel S.

unread,
Apr 19, 2022, 3:51:59 PM4/19/22
to Ansible Project
Hello everyone, i was using ansible 2.10.3, and all was working as well.

I've tried to upgrade my project to ansible 4.10.0, but i'm facing this issue.

I have the fallowing message:

{
  "msg": "Unsupported parameters for (vmware_guest) module: disk.lvnames, disk.vgname. Supported parameters include: state, linked_clone, resource_pool, cdrom, customization, wait_for_customization, datacenter, convert, guest_id, is_template, snapshot_src, wait_for_ip_address, nvdimm, customvalues, esxi_hostname, port, use_instance_uuid, delete_from_inventory, password (pass, pwd), networks, template (template_src), advanced_settings, datastore, name_match, wait_for_ip_address_timeout, proxy_host, validate_certs, cluster, hardware, wait_for_customization_timeout, username (admin, user), state_change_timeout, proxy_port, vapp_properties, name, disk, annotation (notes), customization_spec, uuid, force, folder, hostname.",
  "invocation": {
    "module_args": {
      "hostname": "***",
      "username": "****",
      "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "datacenter": "***",
      "cluster": "***",
      "resource_pool": "*** ",
      "validate_certs": true,
      "uuid": "none",
      "folder": " ***  ",
      "name": " ***  ",
      "guest_id": "***",
      "disk": [
        {
          "datastore": " *** ",
          "size_gb": 20,
          "type": "thick",
          "autoselect_datastore": null,
          "controller_number": null,
          "controller_type": null,
          "disk_mode": null,
          "filename": null,
          "size": null,
          "size_kb": null,
          "size_mb": null,
          "size_tb": null,
          "unit_number": null
        },
        {
          "datastore": " *** ",
          "lvnames": [],
          "size_gb": 30,
          "type": "thick",
          "vgname": "data_vg",
          "autoselect_datastore": null,
          "controller_number": null,
          "controller_type": null,
          "disk_mode": null,
          "filename": null,
          "size": null,
          "size_kb": null,
          "size_mb": null,
          "size_tb": null,
          "unit_number": null
        }
      ],
      "cdrom": {
        "type": "iso",

....
}


This extra params (lvnames et vgname) are used by another role on my collection.

is there a way (simple or not) to achieve this? 

Thanks for your help.

Cheers

Todd Lewis

unread,
Apr 19, 2022, 11:00:39 PM4/19/22
to ansible...@googlegroups.com, uto...@gmail.com

The closest thing I've come up with is, when you pass the "disk:" value in your module invocation, (assuming your variable name is "disk"), do this:

  disk: |
          {%- for disc in disk -%}
          {{    disc | dict2items | list | rejectattr('key', 'in', ['lvnames', 'vgname']) | list | items2dict }},
          {%- endfor -%}

It's not pretty, and I'm not proud of it, but it seems to work at least in a debug task with your data.
This should be a lot easier.

Daniel S.

unread,
Apr 22, 2022, 9:19:28 AM4/22/22
to Ansible Project
Hi Uto,

Thanks for your feedback,

i do it with this way:

        {%- for disc in server.disk -%}
          {%- if disc.vgname is defined -%}
            {%- do disc.pop('vgname') -%}
            {%- do disc.pop('lvnames') -%}
          {%- endif -%}
        {%- endfor -%}

all working now. 

Thanks for putting me on the right track

Cheers
Reply all
Reply to author
Forward
0 new messages