Search code examples
puppet

puppet does not conform to the naming rule


This is the piece of the puppet script i am not able to understand why this error is happening. can any one please help with this.

  if $facts['hostname'] =~ /^acmetest[0-9][0-9][0-9]+/  {
       exec {
        'ExecuteAcme':
        alias       => 'ExecuteAcme',
        command     => '/usr/sbin/lspci|grep -i nvidia',
        refreshonly => true,
      }

    if $ExecuteAcme =~ /controller: NVIDIA Corporation/ {
      class { 'install_acme': }
    }
  }


Error :

Error: Could not parse for environment production: Illegal variable name, The given name 'ExecuteAcme' does not conform to the naming rule /^((::)?[a-z]\w*)*((::)?[a-z_]\w*)$/
pdk (ERROR): puppet-syntax: Could not parse for environment production:
        Illegal variable name, The given name 'ExecuteAcme' does not
        conform to the naming rule /^((::)?[a-z]\w*)*((::)?[a-z_]\w*)$/
        (manifests/example_acme.pp:72:8)

When i check online using regexp validator it works fine .. using string name = 13:00.0 3D controller: NVIDIA Corporation GA100 [A100 PCIe 80GB] (rev a1) and regexp = /controller: NVIDIA Corporation/


Solution

  • The Puppet compiler error is throwing on the variable name of ExecuteAcme. It fails the regular expression described in the error message. This is specifically due to the capitalization of the variable. This can be most easily fixed with:

    if $executeAcme =~ /controller: NVIDIA Corporation/ {
    

    and similarly anywhere else the illegal name is used. Note that the easiest fix is to camelCase, but that normal Puppet convention is for snake case, so you may want to go a bit further anyway:

    if $execute_acme =~ /controller: NVIDIA Corporation/ {