Ask Your Question

Iteration Puppet 3.8.x

asked 2016-02-25 10:28:21 -0600

branh0913 gravatar image

updated 2016-02-27 05:00:37 -0600

Hello. I am having an issue in which I need to set up a bareos director server. However this will require iteration as I set up new clients. For example, if I have a file called <clientname>-dir.conf, the contents point to another configuration file


In an ideal production environment, we obviously don't want to to add this manually every time. So the solution proposed is that we do iteration. Ideally we would have a hiera yamal file like so

- clientname: "bigClient1"
  clientIpAddress:  ""
- clientname: "bigClient2"
  clientIpAddress: ""

So in puppet I would define a corresponding has

class bareos::director(
  clients = {
     clientname => "placeholder",
     clientIpAddress => "placeholder",
) {

   #some code


The issue is that in the file system we want to be able to generate different paths based on the client, and that seemingly can only be achieved through iteration. If I were to represent it in pseudo code it would look like this


for items in clienthash
   //generate directory based on client hash

I know the Lambdas are supported in future versions of Puppet. But my management said that we cannot use the future parser in our production code. I know the other suggestion is defined types, but correct me if I'm wrong, doesn't this bind it to a node? I know that at the very least I would have to create a whole new resource, which would be heavy handed considering I only need to do one thing.

So my question to the group is, would it make more sense to to upgrade Puppet? Or are there other work arounds without having to use defined types?

edit retag flag offensive close merge delete


I'm not following. You provide a hash of hostnames, IP addresses and then propose iterating over this to "generate directories". If you could update removing the pseudo code and adding actual Puppet 4 code, I can probably answer.

Alex Harvey gravatar imageAlex Harvey ( 2016-02-27 05:04:08 -0600 )edit

What's the problem with defined types? It's how this issue is solved without future parser. If you can't currently use future parser for your code, upgrading won't make any difference.

lavaman gravatar imagelavaman ( 2016-02-27 18:48:24 -0600 )edit

I was able to solve this with defined types I am guessing this is the most idiomatic way to do it in Puppet 3.

branh0913 gravatar imagebranh0913 ( 2016-03-05 19:09:04 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-08 16:14:52 -0600

branh0913 gravatar image

I was able to solve this with defined types. It looks like this is just flat out the only way to do iteration in Puppet 3 without the future parser.

edit flag offensive delete link more


Yep, pretty much.

Alex Harvey gravatar imageAlex Harvey ( 2016-03-08 18:45:17 -0600 )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

1 follower


Asked: 2016-02-25 10:28:21 -0600

Seen: 266 times

Last updated: Mar 08 '16