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_guest Module raise err\nsocket.error: [Errno 111] Connection refused #28577

Closed
rewilliamso opened this issue Aug 23, 2017 · 13 comments
Closed
Labels
affects_2.3 This issue/PR affects Ansible v2.3 cloud docs This issue/PR relates to or includes documentation. 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

@rewilliamso
Copy link

ISSUE TYPE
  • Documentation Report
COMPONENT NAME

vmware_guest

ANSIBLE VERSION
ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.5 (default, Sep  5 2016, 02:30:38) [GCC 4.8.5 20150623 (Red Hat 4.8.5-9)]

CONFIGURATION
OS / ENVIRONMENT

Kernel Version: 3.10.0-514.2.2.el7.x86_64 x86_64
Oracle Linux Server release 7.3

SUMMARY

When executing the playbook i get the following error a connection refused error.

STEPS TO REPRODUCE

Run playbook
ansible-playbook setip.yaml

- hosts: 127.0.0.1
  connection: local
  user: root
  sudo: false
  gather_facts: false
  serial: 1

  vars_prompt:
  - name: "some_password"
    prompt: "Enter Password"
    private: yes
  - name: "app_name"
    prompt: "Enter Server Name"
    private: no
  tasks:
  - name: Clone template and customize
    vmware_guest:
      hostname: {{ hostname }}
      username: {{ username }}
      password: "{{ some_password }}"
      validate_certs: "false"
      datacenter: "{{ datacenter }}"
      cluster: "{{ cluster }}"
      state: "poweredon"
      name: "{{app_name}}"
      template: "{{ template }}"
      networks:
        - name: VM Network
          ip: {{ guest_ip }}
          netmask: "{{ netmask }}"
          gateway: "{{ gateway }}"
          domain: tpms
          dns_servers: "{{ dns_servers }}"
    delegate_to: "localhost"

EXPECTED RESULTS

I expect a new server to be cloned from template and also the network set

ACTUAL RESULTS
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_exZNl9/ansible_module_vmware_guest.py", line 1332, in <module>
    main()
  File "/tmp/ansible_exZNl9/ansible_module_vmware_guest.py", line 1291, in main
    pyv = PyVmomiHelper(module)
  File "/tmp/ansible_exZNl9/ansible_module_vmware_guest.py", line 436, in __init__
    self.content = connect_to_api(self.module)
  File "/tmp/ansible_exZNl9/ansible_modlib.zip/ansible/module_utils/vmware.py", line 333, in connect_to_api
  File "/usr/lib/python2.7/site-packages/pyVim/connect.py", line 836, in SmartConnect
    sslContext)
  File "/usr/lib/python2.7/site-packages/pyVim/connect.py", line 718, in __FindSupportedVersion
    sslContext)
  File "/usr/lib/python2.7/site-packages/pyVim/connect.py", line 638, in __GetServiceVersionDescription
    path + "/vimServiceVersions.xml", sslContext)
  File "/usr/lib/python2.7/site-packages/pyVim/connect.py", line 604, in __GetElementTree
    conn.request("GET", path)
  File "/usr/lib64/python2.7/httplib.py", line 1017, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib64/python2.7/httplib.py", line 1051, in _send_request
    self.endheaders(body)
  File "/usr/lib64/python2.7/httplib.py", line 1013, in endheaders
    self._send_output(message_body)
  File "/usr/lib64/python2.7/httplib.py", line 864, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.7/httplib.py", line 826, in send
    self.connect()
  File "/usr/lib64/python2.7/httplib.py", line 1227, in connect
    HTTPConnection.connect(self)
  File "/usr/lib64/python2.7/httplib.py", line 807, in connect
    self.timeout, self.source_address)
  File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 111] Connection refused
fatal: [127.0.0.1 -> localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_exZNl9/ansible_module_vmware_guest.py\", line 1332, in <module>\n    main()\n  File \"/tmp/ansible_exZNl9/ansible_module_vmware_guest.py\", line 1291, in main\n    pyv = PyVmomiHelper(module)\n  File \"/tmp/ansible_exZNl9/ansible_module_vmware_guest.py\", line 436, in __init__\n    self.content = connect_to_api(self.module)\n  File \"/tmp/ansible_exZNl9/ansible_modlib.zip/ansible/module_utils/vmware.py\", line 333, in connect_to_api\n  File \"/usr/lib/python2.7/site-packages/pyVim/connect.py\", line 836, in SmartConnect\n    sslContext)\n  File \"/usr/lib/python2.7/site-packages/pyVim/connect.py\", line 718, in __FindSupportedVersion\n    sslContext)\n  File \"/usr/lib/python2.7/site-packages/pyVim/connect.py\", line 638, in __GetServiceVersionDescription\n    path + \"/vimServiceVersions.xml\", sslContext)\n  File \"/usr/lib/python2.7/site-packages/pyVim/connect.py\", line 604, in __GetElementTree\n    conn.request(\"GET\", path)\n  File \"/usr/lib64/python2.7/httplib.py\", line 1017, in request\n    self._send_request(method, url, body, headers)\n  File \"/usr/lib64/python2.7/httplib.py\", line 1051, in _send_request\n    self.endheaders(body)\n  File \"/usr/lib64/python2.7/httplib.py\", line 1013, in endheaders\n    self._send_output(message_body)\n  File \"/usr/lib64/python2.7/httplib.py\", line 864, in _send_output\n    self.send(msg)\n  File \"/usr/lib64/python2.7/httplib.py\", line 826, in send\n    self.connect()\n  File \"/usr/lib64/python2.7/httplib.py\", line 1227, in connect\n    HTTPConnection.connect(self)\n  File \"/usr/lib64/python2.7/httplib.py\", line 807, in connect\n    self.timeout, self.source_address)\n  File \"/usr/lib64/python2.7/socket.py\", line 571, in create_connection\n    raise err\nsocket.error: [Errno 111] Connection refused\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}
        to retry, use: --limit @/etc/ansible/setip.retry
@ansibot
Copy link
Contributor

ansibot commented Aug 23, 2017

@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 cloud docs_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community labels Aug 23, 2017
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Aug 24, 2017
Akasurde added a commit to Akasurde/ansible that referenced this issue Aug 24, 2017
Fix updates logic of connection in vmware module_utils.

Fixes: ansible#28577

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@Akasurde
Copy link
Member

resolved_by_pr #28586

@rewilliamso
Copy link
Author

rewilliamso commented Aug 24, 2017

Sorry, I am new to this whole github issue section.

I have the following vmware.py scripts on my machine:

  1. /usr/lib/python2.7/site-packages/sos/plugins/vmware.py
  2. /usr/lib/python2.7/site-packages/ansible/module_utils/vmware.py
  3. /usr/lib/python2.7/site-packages/ansible/utils/module_docs_fragments/vmware.py

I believe i need to update #2. So would the fix be to upgrade or pull the vmware.py file located at https://github.com/Akasurde/ansible/blob/f2395ac21d1117c697922780ec869724c29ad3dd/lib/ansible/module_utils/vmware.py ?

@rewilliamso
Copy link
Author

rewilliamso commented Aug 24, 2017

I added the following file to /usr/lib/python2.7/site-packages/ansible/module_utils/vmware.py and I get a different error now. Should I update all vmware.py scripts on the machine?

   }, 
    "msg": "Unknown error connecting to vCenter or ESXi API at vcloud.scriptpro.com: [Errno 111] Connection refused"
}

@rewilliamso
Copy link
Author

rewilliamso commented Aug 24, 2017

Okay, I got the firewall opened to allow http/https ports and that appears to get me passed the issue below.

"msg": "Unknown error connecting to vCenter or ESXi API at vcloud.scriptpro.com: [Errno 111] Connection refused"
}.

The network is being set which is great and I am able to login to the server via ssh. I did notice a few problems.

  1. Inside my /etc/sysconfig/network-scripts/ifcfg-eth0 file. There is an added line that has the following at the bottom of the file. Thoughts?
check_link_down() {
return 1;
}

Also, my dns did not get setup correctly as I am not able to ping any servers. I have this set in my setip.yaml playbook. I would like for this to work but since I am able to ssh into the box now, I could simply copy a resolv.conf file there.

@dagwieers
Copy link
Contributor

The network configuration files are part of the VMware VM customizations. This has nothing to do with us, really. We cannot influence how VMware is doing this. But you are free to mofidy those files as you please with Ansible.

Your DNS is also part of the VM customizations. I wonder what you put in there, it should be a list of servers (not a string of servers). The examples are quite clear on that, di you look at the documentation ?

@rewilliamso
Copy link
Author

rewilliamso commented Aug 24, 2017

Yes , I did see the documentation and that's how i originally had it set. I will try it like that again.

networks:
      - name: VM Network
        ip: 192.168.1.100
        netmask: 255.255.255.0
        gateway: 192.168.1.1
        mac: 'aa:bb:dd:aa:00:14'
        domain: my_domain
        dns_servers:
        - 192.168.1.1
        - 192.168.1.2

Thanks,

@rewilliamso
Copy link
Author

I tried with the following example and the dns is still not being set. When you mentioned modifying VMware VM customizations files were you referring to the vmware.py script?

bcoca pushed a commit that referenced this issue Aug 26, 2017
Fix updates logic of connection in vmware module_utils.

Fixes: #28577

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@dagwieers
Copy link
Contributor

@rewilliamso No, the VMware VM customizations is something VMware wrote to provision various supported operating systems (Linux, Windows, etc...). We simply provide the required information that we can customize during provisioning and VMware takes care of it.

@dagwieers
Copy link
Contributor

Maybe you could try this for new VMs:

    customization:
      dns_servers:
      - 192.168.1.1
      - 192.168.1.2
      domain: my_domain

The VM customizations only runs when creating a new VM, it cannot be used for modifying an existing VM.

@dav1x
Copy link
Contributor

dav1x commented Aug 28, 2017

@rewilliamso I use the exact same syntax as @dagwieers listed above'

customization:
      domain: "{{dns_zone}}"
      dns_servers:
      - "{{ vm_dns }}"

@Akasurde
Copy link
Member

@rewilliamso @dagwieers Can we close this issue ?

@rewilliamso
Copy link
Author

rewilliamso commented Sep 11, 2017 via email

@ansibot ansibot added docs This issue/PR relates to or includes documentation. and removed docs_report labels Mar 1, 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 cloud docs This issue/PR relates to or includes documentation. 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

No branches or pull requests

7 participants