# script module fails

**URL:** <https://forum.ansible.com/t/script-module-fails/21752>\
**Category:** Ansible Project\
**Created:** [June 13, 2016, 3:59pm UTC](https://forum.ansible.com/t/script-module-fails/21752 "2016-06-13T15:59:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [June 13, 2016, 3:59pm UTC](https://forum.ansible.com/t/script-module-fails/21752/1 "2016-06-13T15:59:28Z")

</div>

Hi all,  
I have a role where the file “configure\_disks.ps1” is placed in folder “files”.  
From the role task I’m trying to run the “script” module using that file:

- name: Configure data disk storage pool  
script:  
free\_form: “configure\_disks.ps1” (I have also tried “files/configure\_disks.ps1”)  
creates: “C:/scripts/storagepool\_configured.txt”

Shouldn’t this work? I can’t seem to find exact documentation on when I can use the “files” folder and when I can’t.

Failing that, I guess I can copy the script out to nodes first, but that means I’m unable to use the script module since that expects a source file existing on the control node, right?

I haven’t used the “script” module much, so any pointers would be great.

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [June 13, 2016, 5:30pm UTC](https://forum.ansible.com/t/script-module-fails/21752/2 "2016-06-13T17:30:44Z")

</div>

“free\_form” is a horrible doc artifact that I’m still unsure why it exists… It just means that the script/args go after the action name, eg:

- name: Configure data disk storage pool  
script: “configure\_disks.ps1”  
creates: “C:/scripts/storagepool\_configured.txt”

The script under the role’s files directory is correct (and because of DWIM, you don’t need to specify files/)- once you fix the task to point at the script in the expected way, it should work.

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [June 13, 2016, 5:36pm UTC](https://forum.ansible.com/t/script-module-fails/21752/3 "2016-06-13T17:36:48Z")

</div>

Sorry, also forgot the args wrapper:

- name: Configure data disk storage pool  
script: configure\_disks.ps1  
args:  
creates: C:\scripts\storagepool\_configured.txt

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [June 13, 2016, 5:40pm UTC](https://forum.ansible.com/t/script-module-fails/21752/4 "2016-06-13T17:40:44Z")

</div>

Thanks Matt,  
That was my idea too, but both my IDE and yamllint tells me that’s not valid yaml:

- name: Configure data disk storage pool  
script: configure\_disks.ps1  
creates: “C:/scripts/storagepool\_configured.txt”

Ansible chokes on that aswell, which is why I figured I’d had to use the “free\_form” option since that’s the one that (seemingly) takes the script name argument.

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [June 13, 2016, 5:47pm UTC](https://forum.ansible.com/t/script-module-fails/21752/5 "2016-06-13T17:47:01Z")

</div>

Gotcha, that seems to work. I guess there’s something strange with the script module, it would (at least to me ) make sense to make the necessary changes to make it compatible with “regular” ansible syntax, e.g.

script:  
src: file.ps1  
creates: something.txt
