Ask Your Question
0

Iterate on filenames

asked 2014-01-13 05:49:26 -0500

cdams gravatar image

Hi,

In my puppet script, I've got several classes. In the first class, I copy and move several folders / files

In the second class, I would like to iterate on the filenames of a folder, and call a function. In my idea, the code should be something like this :

$list = exec('/bin/ls /tmp/PA/04.38.00')  
  each($list) |$shared| {
    wls::resourcedeployer{ 'sharedlib': 
        domain         => $wlsDomainName,
        adapterPath    => $shared,
        adapterType    => 'library',
        address        => $address,
     }
}

But of course, it doesn't work :( How could I do ?

Thanks in advance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-01-14 04:08:17 -0500

doc75 gravatar image

I think that you have to create a facter function that will populate $list so that you can use it afterwards. You have quite clear explanation on how to do it here: http://docs.puppetlabs.com/guides/custom_functions.html

The only problem I could foresee is that facter will check the directory content before you run your manifest and therefore you could have only the expected result during second run of puppet.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-01-13 05:49:26 -0500

Seen: 72 times

Last updated: Jan 14 '14