Reputation: 86
I am looking to copy a directory its files using Puppet. The directory, as well as most files/subdirectories, will already exist at the time of copy.
The copy is working for new files and removing files that are not in the source, but existing files are not being updated.
For example, dir/index.html
will be created if it doesn't exist, but will not be updated even if the source contains an update version of the file.
Looking for help as to how I can tell puppet to copy/overwrite all the files in the directory. Wasn't sure if I should be using something like force
to achieve this.
file { "${directory}":
ensure => directory,
owner => $user,
group => "$user",
mode => '0755',
recurse => true,
source => "puppet:///modules/role/${directory}",
} ->
Thanks in advance
Upvotes: 1
Views: 2521
Reputation: 11
Unfortunately I could not comment on the answer above.
I think the "mode => ..." line should be removed, as it will result in ALL files having that mode instead of the original one.
Upvotes: -1
Reputation: 3671
According to the documentation for the file
resource, your configuration is correct and should replace files which don't match the source. This behaviour is configured by setting recurse
to true
.
I'd note the force
option only applies to directories. It is the replace
attribute which applies to files. Given that files aren't being replaced, is it possible that replace => false
has been set as a default attribute for file resources somewhere in your manifests? A default setting would look like
File {
replace => false,
}
As mentioned by John in the comments, you can override a default by explicitly setting replace
in your file resource:
file { $directory:
ensure => directory,
owner => $user,
group => $user,
mode => '0755',
recurse => true,
replace => true,
source => "puppet:///modules/role/${directory}",
}
Upvotes: 2