script file is not getting executed on target machine using ansible script module.
I have written a script file on control-node wants that to copy it on target machine and then from there i wants to run the script file using ansible script module.
playbook:
---
- name: execute script file on target
hosts: all
tasks:
- name: copy script file
copy:
src: /home/ansibleuser/practice-ansible/pre-check.sh
dest: /home/ansibleuser/
mode: 0777
- name: execute the script on destination servers
script:
cmd: /home/ansibleuser/pre-check.sh
args:
removes: /home/ansibleuser/pre-check.sh
register: output
Error:
"changed": false,
"msg": "Could not find or access '/home/ansibleuser/pre-check.sh' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option"