Justin Lloyd
2011-Nov-08 22:54 UTC
[Puppet Users] Fetching puppet files and templates from Maven
How would one go about fetching a template from Maven? For example, the
normal way of using a file resource for an application config file might be:
file { "/etc/app/app.xml":
mode => "0755",
owner => "appuser",
group => "appuser",
content => template("app/app.xml.erb"), # retrieved from
modules/app/templates/app.xml
notify => Service[app],
require => Package[app];
}
However, what if app.xml.erb is in a separate Maven repository on some
other server? How would you go about retrieving and evaluating the template?
How might you go about this for a normal file, i.e. instead of source =>
"puppet://..." ?
I guess you could use an exec resource for a normal file but probably not
for a template since Puppet needs to evaluate the code in the template file.
Thoughts?
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2011-Nov-08 23:33 UTC
Re: [Puppet Users] Fetching puppet files and templates from Maven
On Tue, Nov 8, 2011 at 5:54 PM, Justin Lloyd <jstnlld@gmail.com> wrote:> How would one go about fetching a template from Maven? For example, the > normal way of using a file resource for an application config file might be: > > file { "/etc/app/app.xml": > mode => "0755", > owner => "appuser", > group => "appuser", > content => template("app/app.xml.erb"), # retrieved from > modules/app/templates/app.xml > notify => Service[app], > require => Package[app]; > } > > However, what if app.xml.erb is in a separate Maven repository on some other > server? How would you go about retrieving and evaluating the template? > > How might you go about this for a normal file, i.e. instead of source => > "puppet://..." ? > > I guess you could use an exec resource for a normal file but probably not > for a template since Puppet needs to evaluate the code in the template file. > > Thoughts?What you need is a custom function that can retrieve the file and process it as a template. I would look at the inline_template function and create something like remote_template where you retrieve the file from a remote location and process it. Thanks, Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Justin Lloyd
2011-Nov-09 18:16 UTC
Re: [Puppet Users] Fetching puppet files and templates from Maven
Ah, cool. So something like this if I understand custom functions:
module Puppet::Parser::Functions
newfunction(:remote_template, :url) do |args|
Puppet::Parser::Functions.autoloader.loadall
# TODO fetch the template from its remote source
# TODO and save locally as a temporary template file
# TODO referenced by the variable temp_template
function_template(temp_template)
end
end
On Tue, Nov 8, 2011 at 3:33 PM, Nan Liu <nan@puppetlabs.com> wrote:
> On Tue, Nov 8, 2011 at 5:54 PM, Justin Lloyd <jstnlld@gmail.com>
wrote:
> > How would one go about fetching a template from Maven? For example,
the
> > normal way of using a file resource for an application config file
might
> be:
> >
> > file { "/etc/app/app.xml":
> > mode => "0755",
> > owner => "appuser",
> > group => "appuser",
> > content => template("app/app.xml.erb"), # retrieved
from
> > modules/app/templates/app.xml
> > notify => Service[app],
> > require => Package[app];
> > }
> >
> > However, what if app.xml.erb is in a separate Maven repository on some
> other
> > server? How would you go about retrieving and evaluating the template?
> >
> > How might you go about this for a normal file, i.e. instead of source
=>
> > "puppet://..." ?
> >
> > I guess you could use an exec resource for a normal file but probably
not
> > for a template since Puppet needs to evaluate the code in the template
> file.
> >
> > Thoughts?
>
> What you need is a custom function that can retrieve the file and
> process it as a template. I would look at the inline_template function
> and create something like remote_template where you retrieve the file
> from a remote location and process it.
>
> Thanks,
>
> Nan
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.