win_stat poses an error when i try to get info about a file symbolic link actively in use by a processor

37 views
Skip to first unread message

ishan jain

unread,
Mar 21, 2016, 1:48:53 AM3/21/16
to Ansible Project
I am trying to check if some symbolic links exists or not on a windows 2012 R2 machine using win_file module. It works fine in case of directory symbolic links but poses an error when the path specified is a file symbolic link that is actively being used by a process. This link is a link to jar file and here is what i am using in ansible:

win_stat: path=E:\folder\link2\some_dir\link3.jar

I get the following error because the file is actively in use:

"msg": {
        "changed": false,
        "exception": "At C:\\Users\\Ishan\\AppData\\Local\\Temp\\ansible-tmp-1458122016.24-112690440585191\\win_stat.ps1:231 char:9\r\n+         $fp = [System.IO.File]::Open($path, [System.IO.Filemode]::Open, [System. ...\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
        "failed": true,
        "msg": "Exception calling \"Open\" with \"3\" argument(s): \"The process cannot access the file 'E:\\folder\\link2\\some_dir\\link3.jar' because it is being used by another process.\""
    }

The script i am writing will need to check if a sym link exists and most of the time it will check that on an active jar file link. How can i make it not pose an error ?

J Hawkesworth

unread,
Mar 21, 2016, 9:49:11 AM3/21/16
to Ansible Project
It looks like a fix for this has already been made in latest development version of ansible.


Are you able to try latest development version?

Jon

ishan jain

unread,
Mar 22, 2016, 4:42:02 AM3/22/16
to Ansible Project
I will try with the development branch and will post the results.
Do we have an official image of Ansible's latest devel branch on docker hub ?

Uditha Desilva

unread,
Mar 23, 2016, 7:47:07 AM3/23/16
to Ansible Project
It was made clear at AnsibleFest London that Ansible no longer support any Docker images thereof, so you'll have to roll your own.
Reply all
Reply to author
Forward
0 new messages