I need a way to pass a given variable - lets say thearch - to several different files within a given class. I need to be able to state the contents of this variable for each file individually.
I have tried the following:
file { "xxx":
thearch => "i386",
path => "/xxx/yyyy",
owner => root,
group => root,
mode => 644,
content => template("module/test.erb"),
}
This doesn't pass this variable so I can use it with a <%=thearch%> statement within the erb file as I expect.
What am I doing wrong here?
You'll need to wrap the file in a define that does take that parameter, so that it's available when the template is called, and then call that define. If a lot of the parameters are usually the same, set them as defaults while you're at it just to keep the code clean.
You can't define arbitrary meta parameters for the File resource like "thearch". The only meta parameters available are the ones here. You could use the existing architecture fact from the nodes which might give you the functionality you want.
or perhaps
You can't do that. Arguments to a resource are not arbitrary values. You could do this, though: