Simple puppet script to copy files

Hi, I'm new to the puppet and trying to work on a sample to copy files from one place to another. Any sample script for this?

Example: I have a file in the file d: \ temp \ test.txt, and I want to copy this file to the E: \ mycopy \ folder.

+8
puppet puppetlabs-apache
source share
1 answer

You can “guarantee” that a file at the destination location exists and provide a file to be copied as a source in the file type. A partial code snippet showing only the relevant parts:

file { 'E:\mycopy\folder\filename': ensure => present, source => "d:\temp\test.txt", } 

Check the file type documentation here and how the source attribute behaves here . This will now work with a few caveats:

  • If you use the absolute path to the file as the source, then the file must be present on the agent machine
  • If you are submitting a file from the Puppet file server, the source file must be in the appropriate location on the puppet file server.

But what is your goal? This can be achieved using the content attribute of the file type or other attributes.

+21
source share

All Articles