run a windows script once

29 views
Skip to first unread message

Andreas Roth

unread,
Jun 9, 2015, 4:22:32 PM6/9/15
to ansible...@googlegroups.com
Hi all,

I'm trying to find a way to run a windows script just one time even if the
playbook is excuted multiple times. For me it would be perfect to have some
kind of "hook" file which defines if a script had already run.

On Linux I could use the creates argument. This does not seem to work with
the "raw" module I'm using to trigger my installscript.

Here is my non-working playbook:

- name: "install vda on W2k12"
hosts: tsasi01.bwlab.loc
vars:
deploymentshare: \\myserver.domain.loc\installshare\
tasks:
- name: Microsoft Visual C++ 2005 Redistributable
raw: '{{ deploymentshare
}}applications\vcredisp2005-sp1-x86\install.cmd'
args:
creates: 'c:\test.txt'


Are there any good working workarounds for that?!

Thanks for your help in advance,

Andreas

J Hawkesworth

unread,
Jun 10, 2015, 3:40:34 AM6/10/15
to ansible...@googlegroups.com
Something I have done in the past is wrap the command I want to run inside a powershell script but have the powershell script run a test-path first so the command only gets run if the test-path is false. That's not great though as the script always reports 'changed', so a module would be better.

There is a win_package module which hasn't yet been merged which I believe will run exe files that might be just what you need. I have not tried it but it looks worth a go.

You can use unmerged modules by copying them into your /etc/ansible/library

Hope this helps.

Jon

Reply all
Reply to author
Forward
0 new messages