Hi everyone,
I''m actually working on implementing templates as it is a very
convenient and powerfull way to configure files properly. But I''m
actually meeting a little problem, not a blocking one but a strange
thing.
Basically my module is configuring the ntp client, no big deal.
manifest/init.pp of the module define a simple variable from facts to
know if it''s a VM or not
code :
***************************************
$HardwareType = $manufacturer ? { ''VMware, Inc.'' =>
''VM'', default =>
''PHYSICAL'' }
$ntpserver = ''time.au.fcl.internal''
class ntp
{
package { ''ntp'':
ensure => present,
}
file { ''/etc/ntp.conf'':
owner => root,
group => root,
mode => 644,
content => template(''/etc/puppet/modules/ntp/templates/
ntp.conf.erb''),
notify => Service[''ntpd''],
require => Package[''ntp''],
}
service { ''ntpd'':
ensure => running,
enable => true,
hasrestart => true,
require => Package[''ntp''],
}
}
***************************************
and template from the same module check if it''s a VM or not and add a
special parameter to the ntp.conf if it is.
extract from the code :
***************************************
<% if @HardwareType == "VM" %>
# VMWare Option:
# Instructs NTP not to give up if it sees a large jump in time.
# This is important for coping with large time drifts and resuming
virtual machines from their suspended state.
tinker panic 0
<% end %>
***************************************
My problem is that on the first run I got a nice error like :
***************************************
[root@foo puppet]# puppet agent --test
notice: Ignoring --listen on onetime run
err: Could not retrieve catalog from remote server: Error 400 on
SERVER: Failed to parse template /etc/puppet/modules/ntp/templates/
ntp.conf.erb: Could not find value for ''ntpserver'' at
/etc/puppet/
modules/ntp/manifests/init.pp:25 on node foo.fqdn
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run
***************************************
Second run is fine even if run directly after the first one .... ????
/etc/puppet/modules/ntp/manifests/init.pp:25 is the "content template"
line. So it seems that puppet didn''t manage to get the variable on the
first run but the second run is ok. Strange isn''t it ? Any hint ?
--
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.
On Dec 19, 2010, at 8:03 PM, Nicolas Aizier wrote:> Hi everyone, > > I''m actually working on implementing templates as it is a very > convenient and powerfull way to configure files properly. But I''m > actually meeting a little problem, not a blocking one but a strange > thing. > > Basically my module is configuring the ntp client, no big deal. > manifest/init.pp of the module define a simple variable from facts to > know if it''s a VM or not > > code : > *************************************** > > $HardwareType = $manufacturer ? { ''VMware, Inc.'' => ''VM'', default => > ''PHYSICAL'' } > $ntpserver = ''time.au.fcl.internal'' > > class ntp > { > package { ''ntp'': > ensure => present, > } > > file { ''/etc/ntp.conf'': > owner => root, > group => root, > mode => 644, > content => template(''/etc/puppet/modules/ntp/templates/ > ntp.conf.erb''), > notify => Service[''ntpd''], > require => Package[''ntp''], > } > > service { ''ntpd'': > ensure => running, > enable => true, > hasrestart => true, > require => Package[''ntp''], > } > } > *************************************** > > and template from the same module check if it''s a VM or not and add a > special parameter to the ntp.conf if it is. > > extract from the code : > *************************************** > <% if @HardwareType == "VM" %> > # VMWare Option: > # Instructs NTP not to give up if it sees a large jump in time. > # This is important for coping with large time drifts and resuming > virtual machines from their suspended state. > tinker panic 0 > <% end %> > *************************************** > > My problem is that on the first run I got a nice error like : > *************************************** > [root@foo puppet]# puppet agent --test > notice: Ignoring --listen on onetime run > err: Could not retrieve catalog from remote server: Error 400 on > SERVER: Failed to parse template /etc/puppet/modules/ntp/templates/ > ntp.conf.erb: Could not find value for ''ntpserver'' at /etc/puppet/ > modules/ntp/manifests/init.pp:25 on node foo.fqdn > warning: Not using cache on failed catalog > err: Could not retrieve catalog; skipping run > *************************************** > > Second run is fine even if run directly after the first one .... ???? > /etc/puppet/modules/ntp/manifests/init.pp:25 is the "content template" > line. So it seems that puppet didn''t manage to get the variable on the > first run but the second run is ok. Strange isn''t it ? Any hint ?Does the template use the $ntpserver line? Right now something''s not making sense and I''d guess it''s because something is left out. -- 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.
Oh yeah sorry I forgot the line concerning the variable. the template contain also this line : *********************** server <%= ntpserver %> *********************** No big deal but it seems to pose a problem during the first run. And I really don''t understand why. On Dec 20, 2:14 pm, Patrick <kc7...@gmail.com> wrote:> On Dec 19, 2010, at 8:03 PM, Nicolas Aizier wrote: > > > > > > > > > > > Hi everyone, > > > I''m actually working on implementing templates as it is a very > > convenient and powerfull way to configure files properly. But I''m > > actually meeting a little problem, not a blocking one but a strange > > thing. > > > Basically my module is configuring the ntp client, no big deal. > > manifest/init.pp of the module define a simple variable from facts to > > know if it''s a VM or not > > > code : > > *************************************** > > > $HardwareType = $manufacturer ? { ''VMware, Inc.'' => ''VM'', default => > > ''PHYSICAL'' } > > $ntpserver = ''time.au.fcl.internal'' > > > class ntp > > { > > package { ''ntp'': > > ensure => present, > > } > > > file { ''/etc/ntp.conf'': > > owner => root, > > group => root, > > mode => 644, > > content => template(''/etc/puppet/modules/ntp/templates/ > > ntp.conf.erb''), > > notify => Service[''ntpd''], > > require => Package[''ntp''], > > } > > > service { ''ntpd'': > > ensure => running, > > enable => true, > > hasrestart => true, > > require => Package[''ntp''], > > } > > } > > *************************************** > > > and template from the same module check if it''s a VM or not and add a > > special parameter to the ntp.conf if it is. > > > extract from the code : > > *************************************** > > <% if @HardwareType == "VM" %> > > # VMWare Option: > > # Instructs NTP not to give up if it sees a large jump in time. > > # This is important for coping with large time drifts and resuming > > virtual machines from their suspended state. > > tinker panic 0 > > <% end %> > > *************************************** > > > My problem is that on the first run I got a nice error like : > > *************************************** > > [root@foo puppet]# puppet agent --test > > notice: Ignoring --listen on onetime run > > err: Could not retrieve catalog from remote server: Error 400 on > > SERVER: Failed to parse template /etc/puppet/modules/ntp/templates/ > > ntp.conf.erb: Could not find value for ''ntpserver'' at /etc/puppet/ > > modules/ntp/manifests/init.pp:25 on node foo.fqdn > > warning: Not using cache on failed catalog > > err: Could not retrieve catalog; skipping run > > *************************************** > > > Second run is fine even if run directly after the first one .... ???? > > /etc/puppet/modules/ntp/manifests/init.pp:25 is the "content template" > > line. So it seems that puppet didn''t manage to get the variable on the > > first run but the second run is ok. Strange isn''t it ? Any hint ? > > Does the template use the $ntpserver line? Right now something''s not making sense and I''d guess it''s because something is left out.-- 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.
On 12/20/2010 05:03 AM, Nicolas Aizier wrote:> Hi everyone, > > I''m actually working on implementing templates as it is a very > convenient and powerfull way to configure files properly. But I''m > actually meeting a little problem, not a blocking one but a strange > thing. > > Basically my module is configuring the ntp client, no big deal. > manifest/init.pp of the module define a simple variable from facts to > know if it''s a VM or not > > code : > *************************************** > > $HardwareType = $manufacturer ? { ''VMware, Inc.'' => ''VM'', default => > ''PHYSICAL'' }Hi, this slipped me too at first, but do take note of the $virtual fact. (E.g. "facter virtual")> $ntpserver = ''time.au.fcl.internal'' > > class ntp > { > package { ''ntp'': > ensure => present, > } > > file { ''/etc/ntp.conf'': > owner => root, > group => root, > mode => 644, > content => template(''/etc/puppet/modules/ntp/templates/ > ntp.conf.erb''), > notify => Service[''ntpd''], > require => Package[''ntp''], > } > > service { ''ntpd'': > ensure => running, > enable => true, > hasrestart => true, > require => Package[''ntp''], > } > } > *************************************** > err: Could not retrieve catalog from remote server: Error 400 on > SERVER: Failed to parse template /etc/puppet/modules/ntp/templates/ > ntp.conf.erb: Could not find value for ''ntpserver'' at /etc/puppet/ > modules/ntp/manifests/init.pp:25 on node foo.fqdnAs Patrick noted, the $ntpserver variable is biting you here, which is indeed strange. You may want to try and include its declaration in the ntpserver class proper. Also, it appears valid to include a default value in your template, see http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Templating on the topic of undefined variables. HTH, Felix -- 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.