peaxol
peaxol

Reputation: 587

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

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.

Upvotes: 4

Views: 3630

Answers (1)

CERN_Fan
CERN_Fan

Reputation: 136

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.

Upvotes: 6

Related Questions