0

I simply want to download a file from a remote NXOS device to the ansible 2.9 controller using the fetch module. The xml looks like this:

  - name: fetch module sux
    fetch:
      src: "/tmp/deleteme/deleteme.txt"
      dest: "/ansibile-vault"
    register: output

But when i run the code i get following file not found message:

    "msg": "file not found: /tmp/deleteme/deleteme.txt",
    "invocation": {
        "module_args": {
            "src": "/tmp/deleteme/deleteme.txt"
        }
    }

I know the user i'm using has the correct access rights. I also know i'm on the right device (APIC3). And when i debug the code i can clearly see that this file exists. This is the debugging code:

  - name: check device
    nxos_command: 
      commands: "uname -a && cd /tmp && cd deleteme && ls -ahl"

Following output from debug:

    "stdout_lines": [
        [
            "Linux APIC3 4.14.211atom-1 #1 SMP Wed Dec 16 17:57:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux",
            "total 4.0K",
            "drwxr-xr-x 2 s-awx admin  60 Oct 12 11:11 .",
            "drwxrwxrwt 3 root  root  400 Oct 12 12:48 ..",
            "-rw-r--r-- 1 s-awx admin   9 Oct 12 11:11 deleteme.txt",
            "\u001b[1m\u001b[7m%\u001b[m\u001b[1m\u001b[0m"
        ]
    ]

It found the /tmp folder, it found my earlier created deleteme folder and its text-file. But it does not want to get that file and i do not understand why.

Does anyone know what i might have done wrong?

MaxWasHere
  • 55
  • 1
  • 8
  • I already tried to use the "flat: yes" option and delegate it to localhost or the apic. – MaxWasHere Oct 12 '21 at 11:06
  • Re your deleted sorting question, its non-trivial and easy to get wrong and I sometimes really rebel against SO's guidelines on this stuff. :-| Here's an example (this assumes a modern environment that has lookbehind assertions), see comments: https://jsfiddle.net/tjcrowder/usm0aqwc/ Hope that helps, and happy coding! – T.J. Crowder May 25 '22 at 10:32

0 Answers0