Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In ansible, when to use shell vs script module to run a shell script

Tags:

ansible

I have a shell script - I can execute it using both shell module and script module on the local host. What are advantages of one over the other?

From https://docs.ansible.com/ansible/latest/modules/script_module.html#examples, looks like script module also copies over the script to remote host and then executes it there. So am I correct in assuming that for local hosts or if scripts are already present remotely, there is no difference between the two.

like image 638
peaxol Avatar asked Oct 24 '25 04:10

peaxol


1 Answers

The shell-module can only access scripts that are already present on the remote machine. The scripte-module copies a script from localhost to the remote machine and executes it. If the script is present on both localhost and the remotemachine you can use either (if you use the correct paths). If localhost is the target for your playbook, this is always the case.

like image 195
CERN_Fan Avatar answered Oct 26 '25 22:10

CERN_Fan