# Understanding the script module

**URL:** <https://forum.ansible.com/t/understanding-the-script-module/29090>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [November 21, 2018, 3:19pm UTC](https://forum.ansible.com/t/understanding-the-script-module/29090 "2018-11-21T15:19:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [November 21, 2018, 3:19pm UTC](https://forum.ansible.com/t/understanding-the-script-module/29090/1 "2018-11-21T15:19:44Z")

</div>

Hello, all.

We have an occasional need to update a particular piece of a core business application across a number of Windows servers. The process involves a number of steps, most done via the application UI. It’s tedious and time consuming so, of course, I’ve created a python script to do the actual update (fortunately, the update process can be done from the command line, albeit via a number of steps), and a playbook to execute it. Here’s the playbook:

> * * *
> 
> - hosts: all  
> gather\_facts: false  
> any\_errors\_fatal: true  
> tasks:
> - name: reload DAO  
> local\_action: script /etc/ansible/files/DAO\_update.py {{ inventory\_hostname }}  
> register: dao\_output
> - debug: var=dao\_output.stdout\_lines

Note the use of local\_action. When I tried to simply use the script module (script: /etc/ansible/files/DAO\_update.py {{ inventory\_hostname }}), I got no errors, but the script didn’t execute. I determined this by running tcpdump, which returned no output. If I ran the script manually, tcpdump returned expected output. However, If I ran the playbook with local\_action (as above), tcpdump returned the expected output; e.g. the script executed properly. Why did using the script module not work? According to the script module documentation, among other things, python isn’t required to be installed on the target. An explanation would be appreciated.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [November 21, 2018, 3:34pm UTC](https://forum.ansible.com/t/understanding-the-script-module/29090/2 "2018-11-21T15:34:53Z")

</div>

The first line in the documentation is  
"script - Runs a local script on a remote node after transferring it"

So the script module copy the script from ansible controller to the \_remote\_ and execute the script on \_remote\_ host.

The script module doesn't require python installed, but if you are running a Python script on the remote host of course you need Python on the remote host.

So if you are intending to execute this script on the Ansible controller, use the command module and "local\_action/delegate\_to: localhost" or just set the "connection: local" in the playbook with the command module.

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [November 21, 2018, 3:47pm UTC](https://forum.ansible.com/t/understanding-the-script-module/29090/3 "2018-11-21T15:47:34Z")

</div>

Thanks, Kai. So, am i misinterpreting this line from the documentation?:

- This module does not require python on the remote system, much like the [raw](https://docs.ansible.com/ansible/2.7/modules/raw_module.html#raw-module) module.  
That seems to mean (to me, at least) just what is says, that there’s no need for python to be installed on the Windows systems in which the script is being executed.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [November 21, 2018, 4:01pm UTC](https://forum.ansible.com/t/understanding-the-script-module/29090/4 "2018-11-21T16:01:50Z")

</div>

Yes for the module script it self, Python is not required.

But if you copy over a Python script to the Windows system and execute it you must have Python installed.  
Ansible is not magic, it can execute something on remote system that is doesn't support.

You use script with a Powershell script, but you still need Powershell installed on the Windows machine to execute it.

So the script module only copy the script over(does not require Python) and start the script(does not require Python), but the remote system must support the language you wrote the script with.

If the script you wrote is Powershell, you need Powershell install on remote, but the remote don't need Python to use the script module.

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [November 21, 2018, 4:11pm UTC](https://forum.ansible.com/t/understanding-the-script-module/29090/5 "2018-11-21T16:11:17Z")

</div>

OK, and thanks, as always for your input/insight. I figured that when I first used the script module, and it “failed”. That’s when I turned to local\_action. Still, I think that the documentation could be a bit more clear.
