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

vmware_portgroup, "hosts" or "cluster" required when logging into ESXi #2032

Open
springer268 opened this issue Mar 15, 2024 · 2 comments
Open
Labels
documentation Improvements or additions to documentation

Comments

@springer268
Copy link

Using an example with the same params as the first vmware_portgroup examples page

- name: Add Management Network VM Portgroup
  community.vmware.vmware_portgroup:
    hostname: "{{ esxi_hostname }}"
    username: "{{ esxi_username }}"
    password: "{{ esxi_password }}"
    switch: "{{ vswitch_name }}"
    portgroup: "{{ portgroup_name }}"
    vlan_id: "{{ vlan_id }}"
  delegate_to: localhost

And logging into ESXi directly
This returns

fatal: [localhost]: FAILED! => {"changed": false, "msg": "one of the following is required: cluster_name, hosts"}

This behavior makes sense for vCenter, but not for ESXi, and does not follow the example in the docs.

@mbx64
Copy link

mbx64 commented May 14, 2024

As a workaround (until fixed) you can add esxi_hostname: foobar, literally, as the name will be ignored when connecting to ESXi:

- name: Add Management Network VM Portgroup
  community.vmware.vmware_portgroup:
    hostname: "{{ esxi_hostname }}"
    username: "{{ esxi_username }}"
    password: "{{ esxi_password }}"
    esxi_hostname: foobar
    switch: "{{ vswitch_name }}"
    portgroup: "{{ portgroup_name }}"
    vlan_id: "{{ vlan_id }}"
  delegate_to: localhost

Btw. esxi_hostname is an alias for hosts.

@ihumster
Copy link
Collaborator

Yep, this is documentation issues.

Module community.vmware.vmware_portgroup need one of two required parameters - cluster_name or hosts. Even if you work with standalone esxi, you must specify this esxi in hosts.

- name: Add Management Network VM Portgroup
  community.vmware.vmware_portgroup:
    hostname: "{{ esxi_hostname }}"
    username: "{{ esxi_username }}"
    password: "{{ esxi_password }}"
    hosts:
      - "{{ esxi_hostname }}"
    switch: "{{ vswitch_name }}"
    portgroup: "{{ portgroup_name }}"
    vlan_id: "{{ vlan_id }}"
  delegate_to: localhost

@ihumster ihumster added the documentation Improvements or additions to documentation label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants