Forum Discussion

TNSOPS's avatar
TNSOPS
Icon for Altostratus rankAltostratus
Jan 30, 2023

Bash/ Shell commands - Error using ansible.builtin.command module "No such File or directory"

(venv) $ vi f5_shell.yml
---

- name: MY TEST PLAYBOOK
hosts: f5
gather_facts: false
connection: local
vars:
ansible_python_interpreter: $(which python)
provider:
server: "{{ansible_host}}"
user: "{{ansible_root}}"
password: "{{ansible_root_password}}"
validate_certs: false
server_port: 22
tasks:
- name: BIG IP shell commands
ansible.builtin.command: cat /var/tmp/irfantest.txt
register: command_output

==========================================================

fatal: [PP-CAGCC00-CBLBB01.devrns.devfg.rbc.com -> localhost]: FAILED! => {
"changed": true,
"cmd": [
"cat",
"/var/tmp/irfantest.txt"
],
"delta": "0:00:00.007764",
"end": "2023-01-30 14:17:57.876917",
"invocation": {
"module_args": {
"_raw_params": "cat /var/tmp/irfantest.txt",
"_uses_shell": false,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": true
}
},
"msg": "non-zero return code",
"rc": 1,
"start": "2023-01-30 14:17:57.869153",
"stderr": "cat: /var/tmp/irfantest.txt: No such file or directory",
"stderr_lines": [
"cat: /var/tmp/irfantest.txt: No such file or directory"
],
"stdout": "",
"stdout_lines": []
}

PLAY RECAP ***********************************************************************************************************
PP-CAGCC00-CBLBB01.devrns.devfg.rbc.com : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

 

Verified File does exist. Also tried shell module but getting same error

  • TNSOPS I have not had the opportunity to mess with ansible but the instances where I have seen a file issue is because the full path has not been specified, which it looks as though it has, or the user that is attempting to access this file does not have permission to the specific directory path. I would also double check that your file does indeed end with .txt because typically text files on an F5 are save without a file extension by default.