Copying files between nodes

80 views
Skip to first unread message

warden

unread,
Apr 23, 2014, 12:00:30 PM4/23/14
to puppet...@googlegroups.com
Hi,

I am trying to copy files between nodes using exported resources.
What I want to do is to copy contents of the file from node1 to node2 (exactly same location), basicly rsync functionality.

Here is my scenario:

node1 and node2 include a common class

in common.pp i have:
  @@file { "filename-${hostname}":
    path => "/file/path/somefile",
  }
 
As I understand this is collecting filename-node1 and filename-node2.
Then, in node2 I have a line:

File<<| title == 'filename-node2' |>>

Unfortunately, I get always an empty file on node2. Did I misunderstand the way Exported Resources work?

Thanks,
Radek

Antoine Cotten

unread,
Apr 23, 2014, 12:28:11 PM4/23/14
to puppet...@googlegroups.com
Hi Warden,

Exporting a file resource will not export its content, unless the content is part of the resource (ie. using "content => " or "source => "). By just giving a path you will always end-up with an empty file.
I guess a better approach would be to maintain all files somewhere on your Puppet master, and them deploy them to your nodes. This even works recursively with directories.

Toni

José Luis Ledesma

unread,
Apr 23, 2014, 12:28:32 PM4/23/14
to puppet...@googlegroups.com

Mmm, not very used to exported resources, but perhaps if you set replace=>false in the exported resource this may work.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/7097f0ee-c00a-4158-9fa4-7b4858c5fa0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jcbollinger

unread,
Apr 23, 2014, 12:37:25 PM4/23/14
to puppet...@googlegroups.com


Yes, you did.  Exported resources would be more precisely described as "exported declarations".  They provide a way to declare a resource in the context of compiling one node's catalog that later can be incorporated by reference into other nodes' catalogs (or the same node's).  Exporting a resource has nothing directly to do with the physical resource on the target node; it is all about the declaration.

More generally, Puppet provides no special facility for moving data between nodes, and it provides only a narrow mechanism for moving data from nodes to the master (i.e. node facts).  If the master copy of your file resides on a shared filesystem then you could use a File resource to ensure that other copies were synced to the master copy.  Alternatively, if you put the master copy on your Puppet master then you can sync it to all nodes that need it.  The latter is the mechanism that best fits the Puppet paradigm.


John

warden

unread,
Apr 23, 2014, 12:49:07 PM4/23/14
to puppet...@googlegroups.com
Thanks for your replies. Now I get it that ER are just a way for let's say "sharing facts" from the puppetmaster to some nodes (or the same puppetmaster even).
Unfortunately I wanted exactly the rsync behavior, I do not have a copy of the file on the master (although, that might not be a bad idea to change the approach).

Thanks!
Radek

Matthew Burgess

unread,
Apr 23, 2014, 1:55:15 PM4/23/14
to puppet...@googlegroups.com
On 23 April 2014 17:49, warden <radek.a...@gmail.com> wrote:

Unfortunately I wanted exactly the rsync behavior, I do not have a copy of the file on the master (although, that might not be a bad idea to change the approach).

​Another approach might be to package the file(s) into a native package format for your OS (e.g. rpm, deb) and then manage the deployment via a Package resource.​
​  Or, if it just an individual file, then maintaining the master copy on the Puppet master and deploying it via a File resource ​would be my preferred approach.


Regards,

Matt.
Reply all
Reply to author
Forward
0 new messages