run a windows script once

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

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