Is there a way to symbolically link files from one directory and it's subdirectories into another directory

asked 2018-01-04 17:28:46 -0600

RS gravatar image

updated 2018-01-06 23:37:51 -0600

Currently I have:

class symboliclink::symlinker ($link_to_targets ) {
  $link_to_targets.each |String $link_to, String $target| {
    #file { "setuplink-$target":
    file { "$target":
      #path   => $target,
      ensure  => link,
      target  => $link_to,
      force   => yes,
      recurse => true,
      links   =>  'follow',

But this gives me the error:

Failed to generate additional resources using 'eval_generate': Too many levels of symbolic links @ rb_file_s_stat - /dts/env/ATEST06/tomcat-instance/logs/catalina.2017-12-18.log

Normally I would go to the directory where I want to create the links and run the command:

ln -s /opt/openerp/web/addons/*

Also, is there a way I can do this to multiple subdirectories? I do NOT want to copy the files over.

Please advise

edit retag flag offensive close merge delete


Any advice on this please?

RS gravatar imageRS ( 2018-01-05 12:22:19 -0600 )edit

What is the value of $link_to_targets? What do you expect to be the resulting file resources then? What shall link to what according to your understanding? Can't you just link the whole directory, or do you _have_ to link individual files? How 'bout a bind mount? I'm just spitballing here.

Kai Burghardt gravatar imageKai Burghardt ( 2018-01-06 23:41:20 -0600 )edit

Yes create symbolic link for files while sybmboilic link to any sub directory is fine because any files in the subdirectory will then anyways be accessible. link_to targets is a : delimited row providing the $link_to (source) basically on LHS while the $target on RHS.

RS gravatar imageRS ( 2018-01-08 09:10:39 -0600 )edit