Ask Your Question

how to list all files in puppet and pass it to array

asked 2015-05-18 06:04:55 -0500

Chutki gravatar image


I want to list all file from /tmp/files/


need to pass it to $test = /tmp/files/* and assign it to $file_var = [$test], so my o/p should list

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-05-18 17:07:40 -0500

GregLarkin gravatar image

Can you describe exactly what you are trying to do? As you know, the files in /tmp/files are located on the agent node, but you are asking for a way to make that information known to the master.

There is a way that an agent can send information to the master during a Puppet run. If need further assistance, please post a comment back here.

edit flag offensive delete link more


I am not sure whether master must know the information of the file, my intend is I have set of files under "/tmp/file" directory wanna pass it in a array since no. of file is more than 30 can't hard code in a array like [aaa,bbb,ccc,ddd]

Chutki gravatar imageChutki ( 2015-05-18 19:37:55 -0500 )edit

is there any update, I tried all possibilities but unable to iterate or list files

Chutki gravatar imageChutki ( 2015-05-19 12:19:33 -0500 )edit

Is this related to your use of the tidy resource and wanting to delete all of the files/dirs under a directory? It would help to know exactly what you are trying to achieve.

GregLarkin gravatar imageGregLarkin ( 2015-05-19 17:44:43 -0500 )edit

No its not for tidy. I have files under /tmp/files/rmfile and /tmp/filetest, wanna delete "/tmp/files/" so before remove need to check any link between /tmp/filetest/files -> /tmp/files/rmfile , if so then need to unlink only /tmp/files/rmfile from /tmp/filetest/files not the rest of the link.

Chutki gravatar imageChutki ( 2015-05-20 06:34:32 -0500 )edit

You may be trying to use Puppet as a scripting language, to which it is not well-suited. If you really want to do that, you'll have to write a custom fact with some information about the agent's filesystem and then write code based on the value of the fact to decide what files to remove.

GregLarkin gravatar imageGregLarkin ( 2015-05-20 11:32:40 -0500 )edit

Your Answer

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

Add Answer

Question Tools


Asked: 2015-05-18 06:04:55 -0500

Seen: 106 times

Last updated: May 18 '15