ping is not working with ansible in max os

Hi,
I have mac OS and already installed ansible, this is my first time to try it. I started it by using a simple ping to the local host, but it is not working please check below the output

AHMALI-M-K035:~ ahmali$ ansible localhost -m ping

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 0: ordinal not in range(128)

localhost | FAILED! => {

“failed”: true,

“msg”: “Unexpected failure during module execution.”,

“stdout”: “”

}

AHMALI-M-K035:~ ahmali$ ansible localhost -m ping -vvv

ansible 2.4.0.0

config file = None

configured module search path = [u’/Users/ahmali/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]

ansible python module location = /Users/ahmali/anaconda/lib/python2.7/site-packages/ansible

executable location = /Users/ahmali/anaconda/bin/ansible

python version = 2.7.12 |Anaconda 4.2.0 (x86_64)| (default, Jul 2 2016, 17:43:17) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)]

No config file found; using defaults

Parsed /etc/ansible/hosts inventory source with ini plugin

META: ran handlers

The full traceback is:

Traceback (most recent call last):

File “/Users/ahmali/anaconda/lib/python2.7/site-packages/ansible/executor/task_executor.py”, line 88, in run

items = self._get_loop_items()

File “/Users/ahmali/anaconda/lib/python2.7/site-packages/ansible/executor/task_executor.py”, line 181, in _get_loop_items

self._play_context.update_vars(play_context_vars)

File “/Users/ahmali/anaconda/lib/python2.7/site-packages/ansible/playbook/play_context.py”, line 667, in update_vars

var_val = getattr(self, prop)

File “/Users/ahmali/anaconda/lib/python2.7/site-packages/ansible/playbook/base.py”, line 58, in _generic_g_method

return getattr(self, method)()

File “/Users/ahmali/anaconda/lib/python2.7/site-packages/ansible/playbook/play_context.py”, line 686, in _get_attr_connection

if not check_for_controlpersist(self.ssh_executable):

File “/Users/ahmali/anaconda/lib/python2.7/site-packages/ansible/utils/ssh_functions.py”, line 38, in check_for_controlpersist

cmd = subprocess.Popen([ssh_executable, ‘-o’, ‘ControlPersist’], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

File “/Users/ahmali/anaconda/lib/python2.7/subprocess.py”, line 711, in init

errread, errwrite)

File “/Users/ahmali/anaconda/lib/python2.7/subprocess.py”, line 1343, in _execute_child

raise child_exception

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 0: ordinal not in range(128)

localhost | FAILED! => {

“failed”: true,

“msg”: “Unexpected failure during module execution.”,

“stdout”: “”

}

AHMALI-M-K035:~ ahmali$

Do you have nonascii characters in your path to the ssh binary? If
so, that would do it. I can put in a fix for that for 2.4.1.

Please give this PR a try to see if it solves the issue for you:
https://github.com/ansible/ansible/pull/30779

it works fine,
really appreciate the fast reply

AHMALI-M-K035:ansible ahmali$ ansible localhost -m ping

localhost | SUCCESS => {

“changed”: false,

“failed”: false,

“ping”: “pong”

}

AHMALI-M-K035:ansible ahmali$

Hi Mate

try to ping with ansible localhost -m ping -u -k