script module fails

38 views
Skip to first unread message

Trond Hindenes

unread,
Jun 13, 2016, 11:59:28 AM6/13/16
to Ansible Project
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. 

Matt Davis

unread,
Jun 13, 2016, 1:30:44 PM6/13/16
to Ansible Project
"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.

Matt Davis

unread,
Jun 13, 2016, 1:36:48 PM6/13/16
to Ansible Project
Sorry, also forgot the args wrapper:

- name: Configure data disk storage pool
  script: configure_disks.ps1
  args:
    creates: C:\scripts\storagepool_configured.txt

Trond Hindenes

unread,
Jun 13, 2016, 1:40:45 PM6/13/16
to Ansible Project
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.

Trond Hindenes

unread,
Jun 13, 2016, 1:47:02 PM6/13/16
to Ansible Project
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
Reply all
Reply to author
Forward
0 new messages