summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Borean <jborean93@gmail.com>2018-03-07 08:55:39 +1000
committerGitHub <noreply@github.com>2018-03-07 08:55:39 +1000
commit33773624fbcbdc529db1965c68c8b2f0dea86b20 (patch)
tree4f23edf7ff22597e33f8ea04899121fa6516a1c8
parentf0a808e02c6cb780ebc4321b6f6f5af0cc785ebc (diff)
downloadansible-33773624fbcbdc529db1965c68c8b2f0dea86b20.tar.gz
win_wait_for: fix local port check on port not accessible externally (#37093)
* win_wait_for: use loopback IP instead of hostname if 127.0.0.1 is used (#36762) * win_wait_for: use loopback IP instead of hostname if 127.0.0.1 is used * removed reverse dns lookup in port check (cherry picked from commit 67ffde4ac1be60cc851709df6a4ea2f31861610e) * Added changelog for win_wait_for local port fix
-rw-r--r--changelogs/fragments/win_wait_for-local-port-fix.yaml2
-rw-r--r--lib/ansible/modules/windows/win_wait_for.ps110
2 files changed, 3 insertions, 9 deletions
diff --git a/changelogs/fragments/win_wait_for-local-port-fix.yaml b/changelogs/fragments/win_wait_for-local-port-fix.yaml
new file mode 100644
index 0000000000..d70b6ec6d5
--- /dev/null
+++ b/changelogs/fragments/win_wait_for-local-port-fix.yaml
@@ -0,0 +1,2 @@
+bugfixes:
+- win_wait_for - fixed issue when trying to check a localport when the port is not available externally
diff --git a/lib/ansible/modules/windows/win_wait_for.ps1 b/lib/ansible/modules/windows/win_wait_for.ps1
index dee606ff33..66fd884dea 100644
--- a/lib/ansible/modules/windows/win_wait_for.ps1
+++ b/lib/ansible/modules/windows/win_wait_for.ps1
@@ -54,17 +54,9 @@ if ($port -ne $null) {
}
Function Test-Port($hostname, $port) {
- # try and resolve the IP/Host, if it fails then just use the host passed in
- try {
- $resolve_hostname = ([System.Net.Dns]::GetHostEntry($hostname)).HostName
- } catch {
- # oh well just use the IP addres
- $resolve_hostname = $hostname
- }
-
$timeout = $connect_timeout * 1000
$socket = New-Object -TypeName System.Net.Sockets.TcpClient
- $connect = $socket.BeginConnect($resolve_hostname, $port, $null, $null)
+ $connect = $socket.BeginConnect($hostname, $port, $null, $null)
$wait = $connect.AsyncWaitHandle.WaitOne($timeout, $false)
if ($wait) {