create_resources with hiera

44 views
Skip to first unread message

Darren Claughton

unread,
Jun 19, 2014, 9:29:44 AM6/19/14
to puppet...@googlegroups.com
Hi,

I am trying to use create_resources with hiera.

My hiera testing.yaml (snippet) looks like this

tomcat::confs:
  "%{hiera('webapps_dir')}/tomcat/conf/context.xml":
    content: template('tomcat/context.xml.erb')

tomcat::default_confs:
  ensure: present
  owner: "%{hiera('tomcat::user')}"
  group: "%{hiera('tomcat::group')}"

And my manifest (snippet) looks like this

create_resources(file, hiera('tomcat::confs'), hiera('tomcat::default_confs'))

Everything is working as it should apart from the fact that when the context.xml is created, the content is template('tomcat/context.xml.erb') not my actual erb file.

Thanks,

Darren

Christopher Wood

unread,
Jun 19, 2014, 2:34:54 PM6/19/14
to puppet...@googlegroups.com
The "template('tomcat/context.xml.erb')" is taken as a literal string when read from hiera.

In this case you might wrap the file in a define to use the puppet template() function:

define mymodule::hieratesting ( $content ) {
file { $name:
content => template($content),
}
}
create_resources('mymodule::hieratesting', 'tomcat::confs')
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/64a173c1-cdbc-4647-b7e9-551267969454%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/64a173c1-cdbc-4647-b7e9-551267969454%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout
Reply all
Reply to author
Forward
0 new messages