pull defined type into puppet template?

30 views
Skip to first unread message

Trey Ormsbee

unread,
Oct 23, 2014, 11:50:04 AM10/23/14
to puppet...@googlegroups.com
I working with a dynamic config file template,  I have a section for global options,  then a dynamic section that i want to populate with multiple defined entries.

example config file

#global options
config_option1=setting1
config_option2=setting2
config_option3=setting3
...
#dynamic section
entry=dynamic entry number 1
    option1=setting1
    option2=setting2
    option3=setting3

entry=dynamic entry number 2
    option1=setting1
    option2=setting2
    option3=setting3

....

Is there a way i can dynamically create these entries in a single template?

for instance a defined type:

define application::configs (

  $entry,

  $option1

  $option2

  $option3

) {

#not sure what I would put here

 }


Then pull those entries into the .erb with some kind of function?  Is this even possible to do?
Message has been deleted

Trey Ormsbee

unread,
Oct 23, 2014, 6:32:30 PM10/23/14
to puppet...@googlegroups.com
I think I have determined this just flat out is not possible.  I've went thought many modules on puppet forge and can not find one doing anything close to what I am trying to achieve.

I will auto generate the rest of the data with top level variables from foreman or similar.

james.e...@fasthosts.com

unread,
Oct 24, 2014, 3:07:55 AM10/24/14
to puppet...@googlegroups.com
 Hi Trey,

You could always use the concat module.
https://forge.puppetlabs.com/puppetlabs/concat
Create the global fragment in the class and then use a defined type to create a concat fragment for each entry that you want.  You can pass a template to each fragment.

Trey Ormsbee

unread,
Oct 24, 2014, 10:08:18 AM10/24/14
to puppet...@googlegroups.com
Concat might work,  let me toy with this,  ill post back if i get a working example.

Trey Ormsbee

unread,
Oct 24, 2014, 12:04:07 PM10/24/14
to puppet...@googlegroups.com
James  thanks for suggesting concat,  it worked perfectly;  the examples on the page were more then enough to get me going.

Thanks,

Wil Cooley

unread,
Oct 24, 2014, 1:07:54 PM10/24/14
to puppet-users group
And you then want to declare multiple application::config resources and have them all show up in the resulting file, generated from a template?

It's not possible to have many-to-1 like that with the contents of a File resource, although I myself have wished for something like that. Instead, you can model your configs at a more finely-grained level than just a File resource using other resources/modules, as Trey suggested, the `concat::fragment` type in the puppetlabs/concat module, `ini_setting` type in the puppetlabs/inifile module, or by using Augeas.

Wil

Wil Cooley

unread,
Oct 24, 2014, 1:09:30 PM10/24/14
to puppet-users group
On Fri, Oct 24, 2014 at 10:07 AM, Wil Cooley <wco...@nakedape.cc> wrote:
 as Trey suggested, the `concat::fragment` type in the puppetlabs/concat module,

Er, as James suggested; sorry.

Wil 
Reply all
Reply to author
Forward
0 new messages