I want to call ansible all -m ping to Cisco NX-OS switch (v9.x) using Ansible 2.10.8 in Ubuntu 22.04 (Python3.10.6).
But an error occurred like below
DS2 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to create temporary directory. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p \"` echo /tmp `\"&& mkdir \"` echo /tmp/ansible-tmp-1685779849.641992-40852-58343258243109 `\" && echo ansible-tmp-1685779849.641992-40852-58343258243109=\"` echo /tmp/ansible-tmp-1685779849.641992-40852-58343258243109 `\" ), exited with result 16, stdout output: Syntax error while parsing '/bin/sh -c '( umask 77 && mkdir -p \"` echo /tmp `\"&& mkdir \"` echo /tmp/ansible-tmp-1685779849.641992-40852-58343258243109 `\" && echo ansible-tmp-1685779849.641992-40852-58343258243109=\"` echo /tmp/ansible-tmp-1685779849.641992-40852-58343258243109 `\" ) && sleep 0''\n\n\nCmd exec error.\n",
"unreachable": true
}
I also changed remote_tmp variable bootflash:/xx but still error is occurred.
Please help me.
Change remote_tmp value (ansible config file)
According the information provided it seems that you try to establish a SSH connection to a switch. Such devices may not have all capabilities for Python scripts.
Because of
pingmodule – Try to connect to host, verify a usable python and return pong on success it"is NOT ICMP ping, ... just a trivial test module that requires Python on the remote-node"
is a "... test module, this module always returns pong on successful contact. It does not make sense in playbooks, but it is useful from
/usr/bin/ansibleto verify the ability to login and that a usable Python is configured."In respect to already given comments and Automating NX-OS using Ansible, you may have a look into the following minimal example playbook
Documentation
Similar Q&A