Better use script module

  - name: Execute shell script
    script: create_new_folder_pradipto.sh

On Friday, December 10, 2021 at 4:11:57 PM UTC-8 [email protected] 
wrote:

> Hi Pradipto,
> As you can see the error says *"create_new_folder.sh: command not found"*.
>
> Just a little addition will resolve this issue.
>
> The yml file is
> =======================
> - 
>  name: Play1
>  hosts: web1
>  tasks:
>   - name: Execute shell script
>     shell: *sh* create_new_folder_pradipto.sh
> ==============================
>
> Try this one.
>
> Regards,
> Sarbajit Das
>
>
> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>  Virus-free. 
> www.avg.com 
> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>  
> <#m_2271404908500809854_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Thu, Dec 9, 2021 at 8:33 AM pradipto dasgupta <[email protected]> 
> wrote:
>
>>  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
>>
>> -- 
>>
> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/1027a91e-a3af-465b-afa0-48ba0684d3aan%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/1027a91e-a3af-465b-afa0-48ba0684d3aan%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a7d6fd33-c5e0-4daa-a35c-65e8a1f18a84n%40googlegroups.com.

Reply via email to