Hello All,
I am new in Ansible and was trying to execute a shell script in one of the remote hosts. The script runs fine when executed directly from the host. It is a simple shell script to create a folder.
The shell script is
=============
#!/bin/sh
sudo mkdir new
==============
The error I am getting is
======================
fatal: [web1]: FAILED! => {"changed": true, "cmd": "create_new_folder.sh", "delta": "0:00:00.021853", "end": "2021-12-09 02:34:21.464383", "msg": "non-zero return code", "rc": 127, "start": "2021-12-09 02:34:21.442530", "stderr": "/bin/sh: create_new_folder.sh: command not found", "stderr_lines": ["/bin/sh: create_new_folder.sh: command not found"], "stdout": "", "stdout_lines": []}
=======================
The yml file is
=======================
-
name: Play1
hosts: web1
tasks:
- name: Excute shell script
shell: create_new_folder_pradipto.sh
==============================
I also tried changing the yml file to
=======================
-
name: Play1
hosts: web1
tasks:
- name: Excute shell script
shell:
cmd: create_new_folder_pradipto.sh
==============================
Any idea what is wrong here