Hi,
I am running ansible playbook from centos machine to talk to windows to run basic command(ipconfig). But I am getting below error. Please help me on it.
both the instance(centos & windows) are from AWS ec2. I have added inbound port 5985 in security group to allow traffic from ec2 centos machine. your help is highly appreciated.
Error:-
fatal: [172.28.48.57]: UNREACHABLE! => {
“changed”: false,
“msg”: “plaintext: HTTPConnectionPool(host=‘172.28.48.57’, port=5985): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x7ff07175a350>, ‘Connection to 172.28.48.57 timed out. (connect timeout=30)’))”,
“unreachable”: true
}
Ansible playbook that I am using:
- name: test raw module
hosts: windows-instance
tasks:
- name: run ipconfig
raw: ipconfig
register: ipconfig
- debug: var=ipconfig
/etc/ansible/hosts file:
[windows-instance]
172.28.48.57
[windows-instance:vars]
ansible_ssh_user=Administrator
ansible_ssh_pass=xxxxxx #removed password
ansible_ssh_port=5985
ansible_connection=winrm
Command that I am running:
ansible-playbook -i /etc/ansible/hosts windows_playbook.yaml -vvv
Full output:
ansible-playbook -i /etc/ansible/hosts windows_playbook.yaml -vvv
No config file found; using defaults
PLAYBOOK: windows_playbook.yaml **********************************************************************************************************************************************************************************************************************************************
1 plays in windows_playbook.yaml
PLAY [test raw module] *******************************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************************************************************************************************************************************
Using module file /usr/local/lib/python2.7/site-packages/ansible/modules/windows/setup.ps1
<172.28.48.57> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 172.28.48.57
fatal: [172.28.48.57]: UNREACHABLE! => {
“changed”: false,
“msg”: “plaintext: HTTPConnectionPool(host=‘172.28.48.57’, port=5985): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x7ff07175a350>, ‘Connection to 172.28.48.57 timed out. (connect timeout=30)’))”,
“unreachable”: true
}
to retry, use: --limit @/home/rama.gopisetti/ansible/windows_playbook.retry
PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************
172.28.48.57 : ok=0 changed=0 unreachable=1 failed=0
********Same error log from python
python
Python 2.7.12 (default, Sep 1 2016, 22:14:00)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
import winrm
s = winrm.Session(‘172.28.48.57’, auth=(‘Administrator’, ‘Gj=aWHl@Vqc9vJO4K(-Dd3C3xTC)aA-F’))
r = s.run_cmd(‘ipconfig’, [‘/all’])
r.status_code
r.std_out
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python2.7/site-packages/winrm/init.py”, line 37, in run_cmd
shell_id = self.protocol.open_shell()
File “/usr/local/lib/python2.7/site-packages/winrm/protocol.py”, line 132, in open_shell
res = self.send_message(xmltodict.unparse(req))
File “/usr/local/lib/python2.7/site-packages/winrm/protocol.py”, line 207, in send_message
return self.transport.send_message(message)
File “/usr/local/lib/python2.7/site-packages/winrm/transport.py”, line 184, in send_message
response = self.session.send(prepared_request, timeout=self.read_timeout_sec)
File “/usr/local/lib/python2.7/site-packages/requests/sessions.py”, line 639, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python2.7/site-packages/requests/adapters.py”, line 494, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host=‘172.28.48.57’, port=5985): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x7fd143c81a90>, ‘Connection to 172.28.48.57 timed out. (connect timeout=30)’))
r.status_code
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘r’ is not defined
r.std_out
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘r’ is not defined
exit
Use exit() or Ctrl-D (i.e. EOF) to exit