Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple puppet script to copy files

Hi I'm new to puppet and trying to work on a sample to copy files from one location to another location. Any sample script to do that?

Ex: I've my file at d:\temp\test.txt and I want to copy this file to E:\mycopy\ folder.

like image 337
jestges Avatar asked Nov 15 '13 06:11

jestges


People also ask

What is init PP in puppet?

The init. pp manifest is the main class of a module and, unlike other classes or defined types, it is referred to only by the name of the module itself. For example, the class in init. pp in the puppetlabs-motd module is the mot d class.

What is a puppet file?

A Puppetfile specifies detailed information about each environment's Puppet code and data, including where to get the code and data from, where to install it, and what version of it to install.


1 Answers

You can "ensure" that the file at target location exists and provide the file to be copied as source in file type. A partial code snippet only showing relevant parts:

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

Check the documentation of file type here and how source attribute behaves here. Now this will work with a few caveats :

  • If you are using absolute file path as source - then the file should be present on agent machine
  • If you are serving file from Puppet's file server then the source file should be in appropriate location in puppet's file server.

But what is your exact purpose? Similar thing can be achieved with content attribute of file type or other attributes

like image 143
Vishal Biyani Avatar answered Sep 28 '22 17:09

Vishal Biyani