Trouble with future parser ?

32 views
Skip to first unread message

Paul Seymour

unread,
Jan 3, 2017, 5:57:03 AM1/3/17
to Puppet Users
Hi,

OK trying to evaluate how much work and effort it's going to be to move to Puppet v4.x I have switched on the future parser in our Dev environment.

I am now getting this kind of thing:-

$ puppet agent -t --trace
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call, Failed to parse template grub2/default_grub.erb:
  Filepath: /etc/puppet/environments/dev/modules/grub2/templates/default_grub.erb
  Line: 15
  Detail: undefined method `empty?' for nil:NilClass
 at /etc/puppet/environments/dev/modules/grub2/manifests/config.pp:7:16 on node vrdevpds001.iggroup.local
/usr/share/ruby/vendor_ruby/puppet/indirector/rest.rb:207:in `is_http_200?'
/usr/share/ruby/vendor_ruby/puppet/indirector/rest.rb:100:in `find'
/usr/share/ruby/vendor_ruby/puppet/indirector/indirection.rb:201:in `find'
/usr/share/ruby/vendor_ruby/puppet/configurer.rb:294:in `block in retrieve_new_catalog'
/usr/share/ruby/vendor_ruby/puppet/util.rb:335:in `block in thinmark'
/usr/share/ruby/benchmark.rb:296:in `realtime'
/usr/share/ruby/vendor_ruby/puppet/util.rb:334:in `thinmark'
/usr/share/ruby/vendor_ruby/puppet/configurer.rb:293:in `retrieve_new_catalog'
/usr/share/ruby/vendor_ruby/puppet/configurer.rb:61:in `retrieve_catalog'
/usr/share/ruby/vendor_ruby/puppet/configurer.rb:106:in `prepare_and_retrieve_catalog'
/usr/share/ruby/vendor_ruby/puppet/configurer.rb:202:in `run_internal'
/usr/share/ruby/vendor_ruby/puppet/configurer.rb:134:in `block in run'
/usr/share/ruby/vendor_ruby/puppet/context.rb:64:in `override'
/usr/share/ruby/vendor_ruby/puppet.rb:246:in `override'
/usr/share/ruby/vendor_ruby/puppet/configurer.rb:133:in `run'
/usr/share/ruby/vendor_ruby/puppet/agent.rb:47:in `block (4 levels) in run'
/usr/share/ruby/vendor_ruby/puppet/agent/locker.rb:20:in `lock'
/usr/share/ruby/vendor_ruby/puppet/agent.rb:47:in `block (3 levels) in run'
/usr/share/ruby/vendor_ruby/puppet/agent.rb:117:in `with_client'
/usr/share/ruby/vendor_ruby/puppet/agent.rb:44:in `block (2 levels) in run'
/usr/share/ruby/vendor_ruby/puppet/agent.rb:82:in `run_in_fork'
/usr/share/ruby/vendor_ruby/puppet/agent.rb:43:in `block in run'
/usr/share/ruby/vendor_ruby/puppet/application.rb:179:in `call'
/usr/share/ruby/vendor_ruby/puppet/application.rb:179:in `controlled_run'
/usr/share/ruby/vendor_ruby/puppet/agent.rb:41:in `run'
/usr/share/ruby/vendor_ruby/puppet/application/agent.rb:361:in `onetime'
/usr/share/ruby/vendor_ruby/puppet/application/agent.rb:327:in `run_command'
/usr/share/ruby/vendor_ruby/puppet/application.rb:381:in `block (2 levels) in run'
/usr/share/ruby/vendor_ruby/puppet/application.rb:507:in `plugin_hook'
/usr/share/ruby/vendor_ruby/puppet/application.rb:381:in `block in run'
/usr/share/ruby/vendor_ruby/puppet/util.rb:496:in `exit_on_fail'
/usr/share/ruby/vendor_ruby/puppet/application.rb:381:in `run'
/usr/share/ruby/vendor_ruby/puppet/util/command_line.rb:146:in `run'
/usr/share/ruby/vendor_ruby/puppet/util/command_line.rb:92:in `execute'
/usr/bin/puppet:8:in `<main>'
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

The template looks like this:-
# WARNING: This file maintained by Puppet.

GRUB_DEFAULT=<%= @default_entry %>
GRUB_TIMEOUT=<%= @timeout %>
<% if @hidden_timeout != nil -%>
GRUB_HIDDEN_TIMEOUT=<%= @hidden_timeout %>
<% end -%>
<% if @hidden_timeout_quiet != nil -%>
GRUB_HIDDEN_TIMEOUT_QUIET="<%= @hidden_timeout_quiet %>"
<% end -%>

GRUB_DISTRIBUTOR=<%= @distributor %>
GRUB_CMDLINE_LINUX_DEFAULT="quiet"

<% if !@cmdline_linux.empty? -%>
GRUB_CMDLINE_LINUX="<%= @grub2_options %>"
<% else %>
GRUB_CMDLINE_LINUX=""
<% end -%>

Which parses via erb fine and was working before.

I cannot see what the issue might actually be ? 

Any help would be appreciated.

Thanks
Paul

R.I.Pienaar

unread,
Jan 3, 2017, 5:59:42 AM1/3/17
to puppet-users


----- Original Message -----
> From: "Paul Seymour" <paul.s...@ig.com>
> To: "puppet-users" <puppet...@googlegroups.com>
> Sent: Tuesday, 3 January, 2017 11:57:02
> Subject: [Puppet Users] Trouble with future parser ?

> Hi,
>
> OK trying to evaluate how much work and effort it's going to be to move to
> Puppet v4.x I have switched on the future parser in our Dev environment.
>
> I am now getting this kind of thing:-
>
> $ puppet agent -t --trace
> Info: Retrieving pluginfacts
> Info: Retrieving plugin
> Info: Loading facts
> Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
> Evaluation Error: Error while evaluating a Function Call, Failed to parse
> template grub2/default_grub.erb:
> Filepath:
> /etc/puppet/environments/dev/modules/grub2/templates/default_grub.erb
> Line: 15
> Detail: undefined method `empty?' for nil:NilClass

I'm guessing it's due to the empty? call on the @cmdline_linux variable?
You'll have to show the class code etc.

My guess would be that particular variable is not known within the scope of
the class where you use the template, older puppet had dynamic scope for templates
and that's been removed.
> --
> 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 puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/f6288744-d465-439a-826d-5e1e20eca311%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Paul Seymour

unread,
Jan 3, 2017, 6:05:46 AM1/3/17
to Puppet Users
Thanks. Slightly cut down 

class grub2::params {
  $config_template       = 'grub2/default_grub.erb'
  $cmdline_linux         = 'vconsole.font=latarcyrheb-sun16 rd.lvm.lv=vg01/root crashkernel=auto vconsole.keymap=uk zswap.enabled=1 net.ifnames=0 ipv6.disable=1'
  $cmdline_linux_default = ''
  $default_entry         = '0'
  $device_install        = ''
  $update_binary         = '/usr/sbin/grub2-mkconfig'
  $grub2_options         = hiera('grub2::options', $cmdline_linux)
...
}

class grub2 (
  $cmdline_linux         = $grub2::params::cmdline_linux,
  $grub2_options         = $grub2::params::grub2_options,
  $cmdline_linux_default = $grub2::params::cmdline_linux_default,
  $config_file           = $grub2::params::config_file,
  $build_file            = $grub2::params::build_file,
  $config_template       = $grub2::params::config_template,
  $update_binary         = $grub2::params::update_binary,
  $update_grub           = $grub2::params::update_grub,
  $transparent_hugepages = $grub2::params::transparent_hugepages,
...
) inherits grub2::params {

class grub2::config {
  file { $::grub2::config_file:
    ensure  => 'file',
    owner   => '0',
    group   => '0',
    mode    => '0644',
    content => template($::grub2::config_template),
    require => Class['grub2::install'],
  }

The scoping thing is more than likely I would say.

Thanks,

R.I.Pienaar

unread,
Jan 3, 2017, 6:07:53 AM1/3/17
to puppet-users
yes, so this class needs access to the variable in question, best to pass it
into it as a property

Paul Seymour

unread,
Jan 3, 2017, 6:10:44 AM1/3/17
to Puppet Users


On Tuesday, 3 January 2017 11:07:53 UTC, R.I. Pienaar wrote:



yes, so this class needs access to the variable in question, best to pass it
into it as a property

Yeah got it thanks. What I missed looks way more obvious when I lay it out in a mail. Not fully back after the holidays !
 
Reply all
Reply to author
Forward
0 new messages