coping linked files problem

35 views
Skip to first unread message

rjl

unread,
May 3, 2012, 2:03:59 PM5/3/12
to puppet...@googlegroups.com
Hi,
It seems like this should be pretty easy but I can't find a solution.

On my puppet master, I have a directory of zipped files. These are created by another application. When a new zipped file is added to the directory, the other application attaches a symlink to it called current.

/somepath/repo-1.tar.gz -> current

Then later...

/somepath/repo1.tar.gz
/somepath/repo-2.tar.gz -> current

I want puppet to copy the file pointed to by 'current' to the clients.

So far I have the following which will copy the file but, the name of the file on the client is 'current'. I want it to be the actual name of the file and not the name of the link.

 class ams::config
{
   file {
        "ams_repos":
           path    => "/tmp/current", #????
           owner   => 'root',
           group   => 'root',
           mode    => 0644,
           backup  => true,
           ensure  => present,
           links   => follow,
           source  => "puppet:///repo_files/current",
   }
}

Any help would be greatly appreciated.

Thanks in advance!

Thomas A. Fine

unread,
May 3, 2012, 3:24:27 PM5/3/12
to puppet...@googlegroups.com
It looks like you should be able to do something like this:

$linkvalue = generate('/usr/bin/readlink', '/somepath/current');
$linkbasename = generate('/usr/bin/basename', $linkvalue);

and then

path -> "destinationpath/$linkbasename",

tom
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/_iquOLoCVQwJ.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

rjl

unread,
May 3, 2012, 4:17:18 PM5/3/12
to puppet...@googlegroups.com
Thanks for the reply Tom (didn't need the basename call). That works great for getting the filename. However, now my path is not getting evaluated correctly. I have this in my /etc/puppet/fileserver.conf

[ams_repo_path]
   path /opt/level3/component/ams/repo
   allow *


Here is my class

class ams::config
{
   $realname = generate('/usr/bin/readlink','/opt/level3/component/ams/repo/current')
   file {
        "repo_files":
           path    => "/tmp/$realname",
           owner   => 'root',
           group   => 'root',
           mode    => 0644,
           backup  => true,
           #links   => ignore,
           ensure  => present,
           source  => "puppet:///ams_repo_path/$realname",
   }
}


My client is now complaining...

May  3 20:40:40 devrep0114 puppet-agent[32264]: (/Stage[main]/Ams::Config/File[repo_files]) Could not evaluate: Could not retrieve information from source(s) puppet:///ams_repo_path/1329498772.tar.gz  at /etc/puppet/modules/ams/manifests/config.pp:22

If I change replace the $realname variable above with the link name (current), then puppet will copy the tar file over but it will be named 'current'. This indicates that 'ams_repo_path' is being properly evaluated.

Ideas?
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

> puppet-users+unsubscribe@googlegroups.com.

rjl

unread,
May 3, 2012, 4:36:39 PM5/3/12
to puppet...@googlegroups.com
Found the problem. Looks like a return character...here is my solution.

$realname = regsubst(generate('/usr/bin/readlink','/opt/level3/component/ams/repo/current'),'^(.*)\n$','\1')
Reply all
Reply to author
Forward
0 new messages