HTTPConnectionpool(host = 'proxyhost' , port = 9480) , read timed out = 30 error on ansible 2.7.0 , remote node = windows server 2008

326 views
Skip to first unread message

sase kumar

unread,
Nov 5, 2018, 5:06:01 AM11/5/18
to Ansible Project
Hi experts,

I'm basically trying to run ansible playbook or any adhoc task on windows node (prerequisite done)  when I execute its waiting for some time and then throwing me this error

plaintext: HTTPConnectionpool(host = 'proxyhost' , port = 9480) , read timed out = 30
unreachable: true

I dont any clue on what is happening and this goes for all windows machines

Can any one advice me what are the different troubleshoot we can do for this error?

Note - I defined all the required inputs for windows machine in inventory file like user,password,port,protocol(tried ntlm,basic etc) , connection)

Jordan Borean

unread,
Nov 5, 2018, 4:16:46 PM11/5/18
to Ansible Project
Looks like you are trying to connect through a proxy? The winrm connection plugin doesn't allow you to explicitly define a proxy in the inventory so it would need to be set in the environment variables using the http_proxy/http_proxy env vars. You can use the newer psrp connection plugin to define a proxy in Ansible like;

[windows]
windows
-server

[windows:vars]
ansible_username
=username
ansible_pass
=pass
ansible_connection
=psrp
ansible_psrp_proxy
=proxyhost:9480

There are some other variables that you can set like 'ansible_psrp_cert_validation' but have a look at the docs for more info https://docs.ansible.com/ansible/latest/plugins/connection/psrp.html.

Thanks

Jordan

sase kumar

unread,
Nov 6, 2018, 5:30:00 AM11/6/18
to Ansible Project
Hi Jordan,

Thanks for your detailed reply

I dont want ansible to use the proxy host defined in the centos machine and that proxy is used by another orchestration tool . How I can set in the playbook not to use any proxy while connecting to the remote machine?

Jordan Borean

unread,
Nov 6, 2018, 7:17:00 AM11/6/18
to Ansible Project
Can you share your inventory? Do you have the http_proxy or https_proxy environment values set?
Message has been deleted

Kai Stian Olstad

unread,
Nov 6, 2018, 11:10:26 AM11/6/18
to ansible...@googlegroups.com
On Tuesday, 6 November 2018 16:53:10 CET sase kumar wrote:
> Even I would like to know how we can tell playbook to run without using any
> proxy address
>
> Appreciate any help here

How is the proxy setup on the machine.
If its environment variables http_proxy and https_proxy then you can issue
unset http_proxy; unset https_proxy
on the command line to clear the variables.

Or set the environment variable in you playbook at the play level like this.

- hosts: all
environment:
http_proxy: ''
http_proxy: ''


--
Kai Stian Olstad


sase kumar

unread,
Nov 6, 2018, 11:38:30 AM11/6/18
to Ansible Project
its set on /etc/profile
   I dont want to unset it because other applications in same machine are using it but I dont want ansible to use the same when it executes the playbook
  So is there anyway where I can set variable only at playbook level so that ansible alone will not use proxy during execution? 

Kai Stian Olstad

unread,
Nov 6, 2018, 11:45:10 AM11/6/18
to ansible...@googlegroups.com
On Tuesday, 6 November 2018 17:38:30 CET sase kumar wrote:
>
> >
> > its set on /etc/profile
>
> I dont want to unset it because other applications in same machine are
> using it but I dont want ansible to use the same when it executes the
> playbook

unset doesn't unset the variable for other processes/application, it's just unset in your current command line session.
So if you have two terminal windows open and run unset in one of them, only that session is affected, the other one still have the variable set.


> So is there anyway where I can set variable only at playbook level so
> that ansible alone will not use proxy during execution?

You need to read my previous post one more time, I have a solution for the playbook in there.

--
Kai Stian Olstad


Jordan Borean

unread,
Nov 6, 2018, 4:02:50 PM11/6/18
to Ansible Project
You cannot set the http proxy variables as part of the environment block in a playbook. That will only transfer over to the remote host and not the Ansible host. Ansible pulls the proxy information from the environment variables that are set when it is first executed so you have 4 ways of bypassing this;

  1. Don't have the proxy variable set globally and only set them for the task that is required
  2. Unset http_proxy or https_proxy before calling ansible
  3. Add your Windows host(s) to the 'no_proxy' environment variable to stop a proxy being used for that host
  4. Use psrp connection plugin (not winrm) with the 'ansible_psrp_ignore_proxy: True' variable set
Thanks

Jordan
Reply all
Reply to author
Forward
0 new messages