How do I copy a directory as well containing files with Puppet

How do I copy a directory as well containing files with Puppet,puppet,Puppet,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

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


#1

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}",
    }

#2

... and the OP could override such a resource default by explicitly specifying replace => true in their file resource.

#3

This is the correct answer and should be noted as such.