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;
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?
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: ''
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?
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;
Don’t have the proxy variable set globally and only set them for the task that is required
Unset http_proxy or https_proxy before calling ansible
Add your Windows host(s) to the ‘no_proxy’ environment variable to stop a proxy being used for that host
Use psrp connection plugin (not winrm) with the ‘ansible_psrp_ignore_proxy: True’ variable set
Thanks