puppetlabs / puppet-lint

Check that your Puppet manifests conform to the style guide

Home Page:https://puppetlabs.github.io/puppet-lint/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Notify problem

marek130 opened this issue · comments

Describe the Bug

When a manifest contains notify {"${notify}": } , the puppet lint is failing. The variable name notify should be ok because it is not keyword if I am correct.

Expected Behavior

Running validation with autofix correctly

Steps to Reproduce

Steps to reproduce the behavior:
1.write a manifest
2. run pdk validate -a


puppet-lint version: 4.0.0
ruby version: 2.7.8-p225
platform: x86_64-linux
file path: manifests/audit.pp
file contents:

# @summary A short summary of the purpose of this class
#
# A description of what this class does
#
# @example
#   include logrotate::audit
class logrotate::audit (
  String $file_path = undef,
  # add this class definition to ../modules/profile/manifests/base/sles.pp
  # include logrotate:audit
) {
  include logrotate::sles
  include logrotate::rhel
  include logrotate::ubuntu

  if $facts['os']['name'] in ['SLES','Ubuntu','RedHat'] {
    $service_name = 'auditd.service'
    $notify       = Service[$service_name]
  } else {
    $notify = undef
  }

  notify {"${notify}": }

#  file { "${file_path}":
#    ensure   => 'present',
#    mode     => '0644',
#    group    => 'root',
#    owner    => 'root',
#    source   => 'puppet:///modules/logrotate/audit/audit',
#    require  => Package['logrotate'],
#  }

#  file_line { 'disable-auditd-logrotate':
#    ensure  => present,
#    path    => '/etc/audit/auditd.conf',
#    line    => 'max_log_file_action = ignore',
#    match   => '^max_log_file_action\ =',
#    notify   => $notify,
#  }
}

error:

NoMethodError: undefined method `-' for nil:NilClass
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/data.rb:67:in `insert'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/checkplugin.rb:62:in `add_token'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-manifest_whitespace-check-0.3.0/lib/puppet-lint/plugins/check_manifest_whitespace_opening_brace.rb:87:in `fix'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/checkplugin.rb:42:in `block in fix_problems'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/checkplugin.rb:38:in `each'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/checkplugin.rb:38:in `fix_problems'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/checks.rb:67:in `block in run'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/checks.rb:65:in `each'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/checks.rb:65:in `run'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint.rb:226:in `run'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/bin.rb:85:in `block in run'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/bin.rb:80:in `each'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/lib/puppet-lint/bin.rb:80:in `run'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-4.0.0/bin/puppet-lint:7:in `<top (required)>'
/etc/puppetlabs/code/environments/s5muu6_cleanup/modules/logrotate/bin/puppet-lint:27:in `load'
/etc/puppetlabs/code/environments/s5muu6_cleanup/modules/logrotate/bin/puppet-lint:27:in `<main>'

/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-manifest_whitespace-check-0.3.0/lib/puppet-lint/plugins/check_manifest_whitespace_opening_brace.rb:87:in `fix'

I think this is actually in https://github.com/voxpupuli/puppet-lint-manifest_whitespace-check and in particular here: https://github.com/voxpupuli/puppet-lint-manifest_whitespace-check/blob/527d8690bd90d88bf4a9fb0f911b82a29e579813/lib/puppet-lint/plugins/check_manifest_whitespace_opening_brace.rb#L90

It wants to correct this part:

  notify {"${notify}": }

To:

  notify { "${notify}": }

Somehow that fails. It may very well be fixed with voxpupuli/puppet-lint-manifest_whitespace-check@0697e65 that's currently unreleased.

Hey @marek130 it seems the fix as @ekohl has mentioned above has now been released. I am going to close this issue, however if you disagree, please accept my apology and feel free to reopen.

Thank you for flagging this issue to us, the team really appreciate your input.