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_vswitch doesn't specify host #24647

Closed
silid opened this issue May 16, 2017 · 10 comments · Fixed by #30498
Closed

vmware_vswitch doesn't specify host #24647

silid opened this issue May 16, 2017 · 10 comments · Fixed by #30498
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community

Comments

@silid
Copy link
Contributor

silid commented May 16, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_vswitch

ANSIBLE VERSION
ansible 2.3.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
CONFIGURATION
OS / ENVIRONMENT

Ubuntu 16.04 LTS

SUMMARY

I'd expect that when running the vmware_vswitch module it would apply the vswitch to the host that the playbook was run against, however it doesn't seem to specify a host at all, and consequently seems to apply the playbook to the wrong host via the vsphere.

STEPS TO REPRODUCE
---
- name: vmware-switch-deploy
  hosts: all
  gather_facts: no
 
  tasks:
  - name: Add a VMware vSwitch
    local_action:
      module: vmware_vswitch
      hostname: "{{ lookup('env', 'VMWARE_HOST') }}"
      username: "{{ lookup('env', 'VMWARE_USER') }}"
      password: "{{ lookup('env', 'VMWARE_PASSWORD') }}"
      switch_name: vSwitch3
      number_of_ports: 2
      state: present
      nic_name: vmnic9
      mtu: 9000
      validate_certs: false
EXPECTED RESULTS

I expected the vSwitch to be added to the host the playbook was run against via the vSphere specified in hostname.

ACTUAL RESULTS

vSphere showed an attempt to add a switch to a different esxi host and it failed with the error: A general system error occurred: Invalid fault

Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/cloud/vmware/vmware_vswitch.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: awx
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /var/lib/awx/.ansible/tmp/ansible-tmp-1494926688.54-221130794998158 `" && echo ansible-tmp-1494926688.54-221130794998158="` echo /var/lib/awx/.ansible/tmp/ansible-tmp-1494926688.54-221130794998158 `" ) && sleep 0'
<localhost> PUT /tmp/tmpJ0Msse TO /var/lib/awx/.ansible/tmp/ansible-tmp-1494926688.54-221130794998158/vmware_vswitch.py
<localhost> EXEC /bin/sh -c 'chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1494926688.54-221130794998158/ /var/lib/awx/.ansible/tmp/ansible-tmp-1494926688.54-221130794998158/vmware_vswitch.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /var/lib/awx/.ansible/tmp/ansible-tmp-1494926688.54-221130794998158/vmware_vswitch.py; rm -rf "/var/lib/awx/.ansible/tmp/ansible-tmp-1494926688.54-221130794998158/" > /dev/null 2>&1 && sleep 0'
fatal: [esxi.example.com -> localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "hostname": "vcenter.example.com", 
            "mtu": 9000, 
            "nic_name": "vmnic9", 
            "number_of_ports": 2, 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "state": "present", 
            "switch_name": "vSwitch3", 
            "username": "example-admin", 
            "validate_certs": false
        }
    }, 
    "msg": "A general system error occurred: Invalid fault"
}
@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report cloud module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. vmware VMware community labels May 16, 2017
@nitzmahone nitzmahone removed the needs_triage Needs a first human triage before being processed. label May 19, 2017
@ansibot
Copy link
Contributor

ansibot commented Jun 23, 2017

@ansibot ansibot added the support:community This issue/PR relates to code supported by the Ansible community. label Jun 29, 2017
@Shasties
Copy link

Any updates on this? Currently running into the same issue.

@Akasurde
Copy link
Member

Akasurde commented Jul 12, 2017

@Shasties Could you please provide output of govc find / command against your VMware setup ?

@silid
Copy link
Contributor Author

silid commented Jul 12, 2017

When I run it against mine I get a full hierarchy of Datacenter through to datastores, hosts and networks
About 750 lines of output.

A snippet:

/Oxford
/Oxford/vm
/Oxford/host
/Oxford/datastore
/Oxford/network
/Oxford/network/VM Network
/Oxford/datastore/B002-Datastore
/Oxford/datastore/B003-Datastore
/Oxford/datastore/B001-Datastore
/Oxford/host/OX Cluster
/Oxford/host/OX Cluster/Resources
/Oxford/host/OX Cluster/host1.example.com
/Oxford/host/OX Cluster/host2.example.com
/Oxford/host/OX Cluster/host3.example.com
/Oxford/vm/Discovered virtual machine
/Oxford/vm/Discovered virtual machine/guest1.example.com
/Oxford/vm/Discovered virtual machine/guest2.example.com
/Oxford/vm/Discovered virtual machine/guest3.example.com

@Akasurde
Copy link
Member

@silid @Shasties Can you please check this patch and let me know if it works for your environment?

@ansibot
Copy link
Contributor

ansibot commented Jul 14, 2017

@Akasurde
Copy link
Member

@silid @Shasties Can you please test patch?

@silid
Copy link
Contributor Author

silid commented Sep 15, 2017

Hi @Akasurde Yes - that seems to work.
I would suggest that the host_system field should follow the convention in the vmware_guest module and use esxi_hostname.

Thanks.

@Akasurde
Copy link
Member

resolved_by_pr #30498

@silid
Copy link
Contributor Author

silid commented Sep 20, 2017

Great job. Thanks.

@silid silid closed this as completed Sep 20, 2017
Akasurde added a commit to Akasurde/ansible that referenced this issue Dec 1, 2017
Fix adds esxi_hostname as Ansible module argument for user
to define ESXi hostname to deploy VMware vSwitch.

Fixes: ansible#24647

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit that referenced this issue Dec 1, 2017
Fix adds esxi_hostname as Ansible module argument for user
to define ESXi hostname to deploy VMware vSwitch.

Fixes: #24647

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants