It seems that it is impossible to run a local task when talking to windows hosts. This is pretty much a show stopper for my current use case of Ansbile.
ansible version: ansible 2.1.1.0
using any of the following, all result in the same error
name: disable {{ inventory_hostname }} from LB
delegate_to: localhost
connection: local
command: /usr/bin/magic_lb_removal_script #local_action: command foo #delegate_to: 127.0.0.1
roles:
{ role: foo }
{ role: bar }
ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO localhost
fatal: [172.28.18.158]: UNREACHABLE! => {“changed”: false, “msg”: “plaintext: HTTPConnectionPool(host=‘localhost’, port=5985): Max retries exceeded with url: /wsman (Caused by NewConnectionError(‘<requests.packages.urllib3.connection.HTTPConnection object at 0x21aa610>: Failed to establish a new connection: [Errno 111] Connection refused’,))”, “unreachable”: true}
I suspect you may have an inventory or command issue that’s reassigning localhost’s connection type to winrm (you’re not adding -c winrm, are you?) - this sample works fine for me on both 2.1.1 and devel. The connection: local is not necessary, and works fine for me with either local_action or delegate_to: localhost.
There are definitely some issues with cross-connection delegation with pseudo-connection-var rewriting when going the other way (delegating from Linux hosts to Windows), but this one looks like a busted inventory to me.