Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File does not get updated when the file is updated #52

Closed
dannythk opened this issue Aug 13, 2015 · 5 comments
Closed

File does not get updated when the file is updated #52

dannythk opened this issue Aug 13, 2015 · 5 comments

Comments

@dannythk
Copy link

My code:

wget::fetch { 'somefile':
source => "someURL",
destination => "destFilePath/fileName",
timeout => 0,
verbose => false,
}

When I alter the destination file, puppet run does not revert my destination file back to the source file.
When I alter the source file, puppet run does not update my destination file with the latest update.
The only time it fetch for the file is when I remove the destination file....Is there a way that I could use this module to pull the file similar to "file" resource type? I am not able to use the "File" resource because it is not located inside the Puppet master server.

I also try to put in the cache_dir:

wget::fetch { 'somefile':
source => "someURL",
destination => "$destFilePath/fileName",
cache_dir => '/var/cache/wget',
timeout => 0,
verbose => false,
}

Using the cache_dir works great!! But if the source and destination files are identical, the "wget:fetch" still run as normal. That would give Puppet a false alert that "something" change.

@johnzimm
Copy link

I'm having the same issue. Using the v1.7.0 release.

@carlossg
Copy link
Member

Using cache it calls wget with -P, you can get the full command line running puppet win debug mode and see if calling wget directly the behavior is the same.
The way -P works is documented in http://www.gnu.org/software/wget/manual/wget.html#HTTP-Time_002dStamping-Internals

For the notification see #48

@johnzimm
Copy link

I think I understand why this is happening I guess. I can see the command line. The behavior isn't what I initially expected.

I have the following snippet:

wget::fetch { 'http://example.com/path/to/file':
  destination => '/local/path/to/file',
  cache_dir   => '/var/cache/wget',
}

This grabs the file fine and updates when the file is changed. Except it execs / notifies every time the puppet agent runs.

Removing the cache_dir doesn't cause the subsequent notifications after the initial file placement, but also doesn't update the file when it is new on the web server.

Ultimately what I'm trying to mimic is if I were able to specify an http url in a file resource definition as if it were being delivered via the puppet file server or nfs. It's likely this is just he wrong way to go about it.

In #48 subscribing to the resulting file in the wget::fetch definition gives me an error with Puppet 4.2 of "Error: Failed to apply catalog: Found 2 dependency cycles:".

@carlossg
Copy link
Member

the exec inside wget will always be executed to check if the remote file has changed, that's why it emits a refresh
In #48 it recommends to write your other code (NOT the wget:fetch) with a require to the file File['/local/path/to/file'] so it only runs when the file changes

@carlossg
Copy link
Member

To sum up, file does get updated when the http file is updated, you just need to use cache_dir (or redownload, but that is inefficient)

This has become a dupe of #48, about how to subscribe to events when the file is updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants