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

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)

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

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?

Can you share your inventory? Do you have the http_proxy or https_proxy environment values set?

Hi ,

here is my inventory

[wins2008]
172.17.4.81

[wins2008:vars]
ansible_user=Administrator
ansible_password=1nf0M@t1csPh!lt0r
#ansible_password=1nf0M@t1csPh!lt0r
#ansible_user=Test
#ansible_ssh_pass=test@123
ansible_connection=winrm
#ansible_ssh_port=5985
ansible_port=5985
ansible_winrm_message_encryption=auto
ansible_winrm_transport=ntlm

[wins2012]
172.17.6.35

[wins2012:vars]
ansible_user=ops68\phiadmin
ansible_password=1nf0M@t1csPh!lt0r
ansible_port=5985
ansible_winrm_transport=credssp
ansible_winrm_message_encryption=auto
ansible_connection=winrm

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: ''

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?

>
> 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.

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