Selector Inside A Resource


You should not intermingle conditionals with resource declarations. When using conditionals for data assignment, you should separate conditional code from the resource declarations (style guide).

What you have done

file { '/tmp/readme.txt':
  mode => $::operatingsystem ? {
    debian => '0777',
    redhat => '0776',
    fedora => '0007',
  }
}

What you should have done:

$file_mode = $::operatingsystem ? {
  debian => '0007',
  redhat => '0776',
  fedora => '0007',
}

file { '/tmp/readme.txt':
  mode => $file_mode,
}

Disabling the check

To disable this check you can add --no-selector_inside_resource-check to your puppet-lint command line.

$ puppet-lint --no-selector_inside_resource-check path/to/file.pp

Alternatively, if you’re calling puppet-lint via the Rake task, you should insert the following line to your Rakefile.

PuppetLint.configuration.send('disable_selector_inside_resource')