puppet-lint & Syntax

33 views
Skip to first unread message

Albert Shih

unread,
Feb 20, 2018, 7:53:21 AM2/20/18
to puppet...@googlegroups.com
Hi everyone,

I'm wonder why puppet-lint don't show any syntax error.

For example I just delete a "," at the end of a line and

[root@io manifests]$ puppet-lint init.pp
[root@io manifests]$ puppet parser validate init.pp Error: Could not parse for environment production: Syntax error at 'Boolean' (file: /home/jas/Travaux/puppet/modules/apache/manifests/init.pp, line: 19, column: 3)
[root@io manifests]$

puppet-lint seem to be a very powerfull tool. I don't understand why he
cannot complain when something very simple like a missing comma cannot be
detected.

Regards.
--
Albert SHIH
Heure local/Local time:
Tue Feb 20 13:49:31 CET 2018

Martin Alfke

unread,
Feb 20, 2018, 8:00:17 AM2/20/18
to puppet...@googlegroups.com
Hi Albert,

some lint checks are not available in lint core, but are within a lint plugin.
In your case check: https://github.com/voxpupuli/puppet-lint-trailing_comma-check.git

Complete list can be found on voxpupuli: https://voxpupuli.org/plugins/#puppet-lint

Best,
Martin
> --
> 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/20180220125301.GJ5491%40io.chezmoi.fr.
> For more options, visit https://groups.google.com/d/optout.

Albert Shih

unread,
Feb 20, 2018, 8:13:21 AM2/20/18
to puppet...@googlegroups.com
Le 20/02/2018 à 14:00:04+0100, Martin Alfke a écrit
Hi,

>
> some lint checks are not available in lint core, but are within a lint plugin.
> In your case check: https://github.com/voxpupuli/puppet-lint-trailing_comma-check.git
>
> Complete list can be found on voxpupuli: https://voxpupuli.org/plugins/#puppet-lint

Thanks.

But well the comma was just a example. The point is puppet-lint are (IMHO)
very powerfull tool, why he cannot integrate the «puppet parser» feature ?
Like rubocop does for ruby ?

Regards.
--
Albert SHIH
xmpp: j...@obspm.fr
Heure local/Local time:
Tue Feb 20 14:11:38 CET 2018

Maria Elena

unread,
Feb 20, 2018, 11:27:21 AM2/20/18
to puppet...@googlegroups.com
Hi Albert,
maybe cause puppet-lint checks only style (http://puppet-lint.com/).
Regards.
M.E.


--
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+unsubscribe@googlegroups.com.

Albert Shih

unread,
Feb 20, 2018, 4:51:27 PM2/20/18
to puppet...@googlegroups.com
20/02/2018 à 14:01:23+0100, Maria Elena a écrit
> Hi Albert,
> maybe cause puppet-lint checks only style (http://puppet-lint.com/).
> Regards.

You're perfectly right. But in fact I'm not very good in english, so I will
rephrase...

Can puppet-lint check also the syntax ? So we don't need to launch two
thing

puppet parser validate

and

puppet-lint

that would be much easier.

Regards.

JAS

> Hi everyone,
>
> I'm wonder why puppet-lint don't show any syntax error.
>
> For example I just delete a "," at the end of a line and
>
> [root@io manifests]$ puppet-lint init.pp
> [root@io manifests]$ puppet parser validate init.pp Error: Could not parse
> for environment production: Syntax error at 'Boolean' (file: /home/jas/
> Travaux/puppet/modules/apache/manifests/init.pp, line: 19, column: 3)
> [root@io manifests]$
>
> puppet-lint seem to be a very powerfull tool. I don't understand why he
> cannot complain when something very simple like a missing comma cannot be
> detected.
>
--
Albert SHIH
xmpp: j...@obspm.fr
Heure local/Local time:
Tue Feb 20 22:49:11 CET 2018

Christopher Wood

unread,
Feb 20, 2018, 5:18:07 PM2/20/18
to puppet...@googlegroups.com
Taking a stab at this...

The puppet parser will always be the authoritative source for one's puppet code validation since that is what will be parsing the code via agent or server. It will introduce any number of bugs and inconsistencies and delay to have puppet-lint keep up with what puppet does anyway.

However!

You do not need to check this all manually every time you commit. There are tools which wrap these commands that you can set up to do this automatically.

You can use puppet-git hooks to have all these checks performed right before a git commit is applied. Even better, you can set this up on the server side so that people are incapable of pushing risible crud to your main git repository.

https://github.com/drwahl/puppet-git-hooks

Under the hood, PDK uses puppet and puppet-lint and gives you the chance to add specification testing. I have this set up in our gitlab instance to run "pdk validate" and "pdk test unit" on every module we've run through "pdk convert". (You can likely have this one in a pre-commit hook too, haven't done that here.) We had some training/implementation sort of workshops and people were able to get some very basic tests done in their first time using PDK which was pleasant.

https://puppet.com/docs/pdk/1.x/pdk_install.html
> --
> 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/20180220215107.GC1284%40io.chezmoi.fr.
Reply all
Reply to author
Forward
0 new messages