-1

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)

U880D
  • 8,601
  • 6
  • 24
  • 40
network
  • 11
  • 6
  • 1
    Please read [ask] and pay attention to the [mre] section and then [edit] your question to add the missing bits. Specifically, we have no idea what your inventory looks like and which connection plugin your are using. Note that connecting to a cisco switch most probably requires using one of the plugins provided in the [`cisco.nxos` collection](https://docs.ansible.com/ansible/latest/collections/cisco/nxos/index.html). Also note your question is on the edge of being [off-topic](/help/on-topic) on SO and is probably better suited for https://serverfault.com. – Zeitounator Jun 03 '23 at 13:56
  • Thank you for the correction. Next time, I will remember what you told me and upload it. – network Jun 04 '23 at 14:33
  • you should still [edit] your question even if you have an answer to make both more useful for future readers. – Zeitounator Jun 04 '23 at 16:13

1 Answers1

1

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 ping module – 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/ansible to 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

---
- hosts: nx-os
  gather_facts: false

  vars:
  
    ansible_connection: ansible.netcommon.network_cli
    ansible_network_os: cisco.nxos.nxos 
    ansible_become: true
    ansible_become_method: enable

  tasks:
  
  - name: Gather only the config and default facts
    cisco.nxos.nxos_facts:
      gather_subset:
      - config

  - name: Show Gathered Facts
    debug:
      msg: "{{ ansible_facts }}"
 
  - name: Run show version on Remote Device
    cisco.nxos.nxos_command:
      commands: show version
    register: results

  - name: Show results
    debug:
      msg: "{{ results.stdout_lines }}"

Documentation

Similar Q&A

U880D
  • 8,601
  • 6
  • 24
  • 40
  • 1
    @network Please read [What to do when someone answers my question](/help/someone-answers) where you will learn that the actual way to say thank your on SO is to up-vote and/or accept (green tick) answers that you find usefull. If this fixed your issue, this is what you should do. – Zeitounator Jun 04 '23 at 16:10