From dcd064ae07e2adf32529be48d7750246dc39d8e7 Mon Sep 17 00:00:00 2001
From: Chris Coley <chris@codingallnight.com>
Date: Tue, 17 Jul 2018 16:36:32 -0700
Subject: [PATCH] Fix incompatibility with Ansible 2.4

The 'ping' module behaves differently between Ansible 2.4 and 2.5, so the
tasks/diagnose-unpingable.yml task list didn't work in Ansible 2.4.
---
 tasks/diagnose-unpingable.yml | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/tasks/diagnose-unpingable.yml b/tasks/diagnose-unpingable.yml
index a823794..5da41c9 100644
--- a/tasks/diagnose-unpingable.yml
+++ b/tasks/diagnose-unpingable.yml
@@ -4,16 +4,10 @@
 # being unavailable, or Python being an unsupported version.
 #
 ---
-# If the error has a defined error message and is not related to Python not
-# being found, then display that message
-- fail:
-    msg: '{{ _can_ping.msg }}'
-  when: _can_ping.msg is defined and (_can_ping.rc is not defined or _can_ping.rc != 127)
-
 # If the error is related to Python not being found, then try to find the
 # available Python interpreters
 - name: Python is not found
-  when: _can_ping.rc is defined and _can_ping.rc == 127
+  when: _can_ping.module_stdout is defined and ( 'python' in _can_ping.module_stdout and 'not found' in _can_ping.module_stdout )
   block:
     - include_tasks: '{{ role_path }}/tasks/find-python-executable.yml'
     - fail:
@@ -21,6 +15,11 @@
               Please set 'ansible_python_interpreter' to an executable Python interpreter.\n
               The host has these available: ( {{ _python_interpreters | join(' , ') }} )"
 
+# If the error has a defined error message, then display that message
+- fail:
+    msg: '{{ _can_ping.msg }}'
+  when: _can_ping.msg is defined
+
 # This block is a catchall that runs whenever an unanticipated error occurs
 - name: Something Unexpected Happened
   block:
-- 
GitLab