Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Syntax error - when using crayfishx/db2 and db2_catalog_database #918

Open
XnS opened this issue Apr 2, 2020 · 1 comment
Open

Comments

@XnS
Copy link

XnS commented Apr 2, 2020

Hi,

we use the module crayfishx/db2 to setup db2 installation on our hosts. If we try to to use one particular type, puppet-lint fails with

ERROR: Syntax error (try running `puppet parser validate <file>`) on line 63
Try running `puppet parser validate <file>`

Puppet parser has no output:

puppet parser validate --verbose --debug site/xxx/manifests/profiles/db2_catalog.pp
Debug: Runtime environment: puppet_version=6.10.1, ruby_version=2.5.5, run_mode=user, default_encoding=UTF-8

The code

      db2_catalog_database { "${db_name}_DB":
        install_root   => $db_install,
        instance       => $db_instance,
        db_name        => $db_name,
        as_alias       => $db_name,
        authentication => 'SERVER',
        node           => $db_node
      }

Line 63 is the node => $db_node part

I suspected node to be a problem because it could be some kind of magic word, but the following code is validated without any error (node is actually not a valid parameter for this type):

      db2_catalog_node { $db_node:
        instance     => $db_instance,
        install_root => $db_install,
        type         => 'tcpip',
        remote       => $db_server,
        server       => $db_port,
        node         => $db_node
      }

Does anyone have an idea why puppet-lint fails in this case?

@usev6
Copy link
Contributor

usev6 commented Apr 4, 2020

Hi @XnS,

yeah, this seems to happen because of node being treated as a special keyword by puppet-lint. Actually, I'm seeing the same error with your second code example.

There is a list of those keywords defined in lexer.rb: https://github.com/rodjek/puppet-lint/blob/a9654aebf6/lib/puppet-lint/lexer.rb#L58-L80.

During tokenising all tokens of type :NAME that are part of the list are not tokenized as names but as the particular keyword: https://github.com/rodjek/puppet-lint/blob/a9654aebf6/lib/puppet-lint/lexer.rb#L213-L217

In your case the line with node => $db_node is tokenised as

Token :INDENT (    )
Token :NODE (node)
Token :WHITESPACE (  )
Token :FARROW (=>)
Token :WHITESPACE ( )
Token :VARIABLE (db_node)
Token :NEWLINE (
)

Non-special parameter names would result in the second token being of type :NAME instead:

Token :NAME (authentication)

The actual error comes from the check unquoted_node_name. It searches for an opening curly brace after the :NODE token and doesn't find one: https://github.com/rodjek/puppet-lint/blob/a9654aebf6/lib/puppet-lint/plugins/check_nodes/unquoted_node_name.rb#L11

So a quick workaround would be to disable that check. (I'm afraid it's not possible to use inline comments to disable the check only for the code in question, since these comments don't prevent the syntax error from happening.)

Looking at Puppet's documentation for reserved words node is listed there, but as far as I understand, it is allowed as a parameter name. (Parameter names doesn't seem to be counted as bare word strings.)

I don't see an easy way to make puppet-lint accept reserved words as parameter names. @rodjek could give you more insights on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants