win_get_url and 'force: no' not working?

32 views
Skip to first unread message

cupcake

unread,
Apr 5, 2017, 4:26:24 PM4/5/17
to Ansible Project
ansible 2.2.1.0
windows server 2008 r2 x64

Trying to use win_get_url for an xml file update. I can curl the file and see that it notices newer timestamp but force: no does not pull the new file down.

pbook:

---
# tasks file for packages
- name:
  hosts: windows
  tasks:
  - name: Get XML file if newer
    win_get_url:
      dest: 'C:\temp\testfile.xml'
      force: no



curl original:
HTTP/1.1 200 OK
Content-Length: 123
Content-Type: text/xml
Last-Modified: Wed, 05 Apr 2017 13:27:23 GMT
Accept-Ranges: bytes
ETag: "d9df35b10aed21:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 05 Apr 2017 20:16:03 GMT





fresh run w no file pre-existing:
changed: [winserver1.foo.com] => {
    "changed": true, 
    "invocation": {
        "module_name": "win_get_url"
    }, 
    "win_get_url": {
        "dest": "C:\\temp\\testfile.xml", 
    }
}


run again w no changes to origin:
    "changed": false, 
    "invocation": {
        "module_name": "win_get_url"
    }, 
    "win_get_url": {
        "dest": "C:\\temp\\testfile.xml", 
    }
}



add line to xml and curl again:
HTTP/1.1 200 OK
Content-Length: 150
Content-Type: text/xml
Last-Modified: Wed, 05 Apr 2017 20:17:46 GMT
Accept-Ranges: bytes
ETag: W/"b7d256b049aed21:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 05 Apr 2017 20:17:48 GMT


    "changed": false, 
    "invocation": {
        "module_name": "win_get_url"
    }, 
    "win_get_url": {
        "dest": "C:\\temp\\testfile.xml", 
    }
}
 

I saw some bugs regarding force: no not working properly on older versions of ansible, but perhaps this issue still exists on 2.2.x.

J Hawkesworth

unread,
Apr 5, 2017, 6:10:58 PM4/5/17
to Ansible Project
Looks like there's only a few seconds there between the modification and the request (last example anyway).
Just wondering if the clocks are in sync between the ansible controller and the windows box - they will need to agree on UTC for this to work.
Also worth checking the timezones on both systems.
Hope this helps,
Jon

cupcake

unread,
Apr 5, 2017, 6:42:43 PM4/5/17
to Ansible Project
the second curl is the difference of the file from the earlier one, so it should have picked up but i see what you are saying if the other system is 30 sec off or so it might now.

I've just re-run it again and it still fails so it def should have picked up by now. all three systems are EST and syncing to ntp; i can also auth with kerberos. 

interestingly, if i change the url argument to say a new txt file instead such as test.txt but keep the dest file the same on target, it still does not copy the file over. 

# date
Wed Apr  5 18:29:13 EDT 2017
HTTP/1.1 200 OK
Content-Length: 5
Content-Type: text/plain
Last-Modified: Wed, 05 Apr 2017 22:27:16 GMT
Accept-Ranges: bytes
ETag: "bb360c85baed21:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 05 Apr 2017 22:30:06 GMT


and then run now:
# date
Wed Apr  5 18:30:59 EDT 2017


    "changed": false, 
    "invocation": {
        "module_name": "win_get_url"
    }, 
    "win_get_url": {
        "dest": "C:\\temp\\testfile.xml", 
    }
}


This is a new txt file with different content and timestamp that is "newer" than the other. If i fixup the dest to match the new file and do a new run it copies:
changed: [winserver1.foo.com] => {
    "changed": true, 
    "invocation": {
        "module_name": "win_get_url"
    }, 
    "win_get_url": {
        "dest": "C:\\temp\\test.txt", 
    }
}

PLAY RECAP *********************************************************************
winserver1.foo.com         : ok=2    changed=1    unreachable=0    failed=0   


now add another line to the txt file on source win server and wait a few minutes and still does not copy the changed file over.
# date
Wed Apr  5 18:36:23 EDT 2017

# curl -I http://windc1.foo.com/shares/test.txt
HTTP/1.1 200 OK
Content-Length: 5
Content-Type: text/plain
Last-Modified: Wed, 05 Apr 2017 22:27:16 GMT
Accept-Ranges: bytes
ETag: "bb360c85baed21:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 05 Apr 2017 22:36:22 GMT

# date
Wed Apr  5 18:40:13 EDT 2017
HTTP/1.1 200 OK
Content-Length: 16
Content-Type: text/plain
Last-Modified: Wed, 05 Apr 2017 22:36:47 GMT
Accept-Ranges: bytes
ETag: "e1d1181c5daed21:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 05 Apr 2017 22:41:06 GMT

    "changed": false, 
    "invocation": {
        "module_name": "win_get_url"
    }, 
    "win_get_url": {
        "dest": "C:\\temp\\test.txt", 
    }
}



J Hawkesworth

unread,
Apr 6, 2017, 3:12:17 AM4/6/17
to Ansible Project
I'm fairly certain it checks to see if the destination file exists before it attempts to retrieve last modified time - if the destination file doesn't exist then it should attempt the download anyway.

A bug fix was merged recently where the last-modified check wouldn't respect proxy settings if you were using a proxy - but that doesn't look like it applies to you.

I mostly tested this with nginx but would be surprised if IIS is anything but well-behaved when it comes to correctly setting last-modified.

Is there some network cleverness going on like squid or similar that might be confusing matter (although why it would not affect curl I can't imagine)?

cupcake

unread,
Apr 6, 2017, 6:42:37 AM4/6/17
to Ansible Project
No network cleverness here ATM, these are just test machines right now on a single subnet. Vanilla rhel7.3 install and vanilla win install. Happy to set up another test scenario if it helps.
Reply all
Reply to author
Forward
0 new messages