Docu review done: Mon 03 Jul 2023 17:07:54 CEST
Table of Content
- Description
- Installation
- Run puppet lint
- Sample puppet lint command
- Fix parameter
- Control Comments
- URL
Description
puppet-lint
is an application which helps you to find issues in your puppet module or syntax changes which improves your manifests
Installation
# ;)
package { 'puppet-lint': ensure => installed }
$ apt install puppet-lint
Run puppet lint
$ puppet-lint /path/to/your/modules/or/direct/manifest
Sample puppet lint command
$ puppet-lint ~/puppet/modules
foo/manifests/bar.pp - ERROR: trailing whitespace found on line 1
apache/manifests/server.pp - WARNING: variable not enclosed in {} on line 56
...
Fix parameter
The --fix
paramert lets puppet-lint
try to resolve the detected issues on its own
$ puppet-lint --fix ~/puppet/modules
foo/manifests/bar.pp - FIXED: trailing whitespace found on line 1
apache/manifests/server.pp - FIXED: variable not enclosed in {} on line 56
...
Control Comments
Blocks of lines in your manifest can be ignored by boxing them in with lint:ignore:<check name>
and lint:endignore
comments
class foo {
$bar = 'bar'
# lint:ignore:double_quoted_strings
$baz = "baz"
$gronk = "gronk"
# lint:endignore
}
You can also ignore just a single line by adding a trailing lint:ignore:<check name>
comment to the line
$this_line_has_a_really_long_name_and_value = "[snip]" # lint:ignore:140chars
Multiple checks can be ignored in one comment by listing them with whitespace separator
# lint:ignore:double_quoted_strings lint:ignore:slash_comments
$baz = "baz"
// my awesome comment
# lint:endignore
Telling puppet-lint
to ignore certain problems won’t prevent them from being detected, they just won’t be displayed (or fixed) by default. If you want to see which problems puppet-lint
is ignoring, you can add --show-ignored
to your puppet-lint invocation.
$ puppet-lint --show-ignored
foo/manifests/bar.pp - IGNORED: line has more than 140 characters on line 1
For the sake of your memory (and your coworkers), any text in your comment after lint:ignore:<check name>
will be considered the reason for ignoring the check and will be displayed when showing ignored problems.
$ puppet-lint --show-ignored
foo/manifests/bar.pp - IGNORED: line has more than 140 characters on line 1
there is a good reason for this