puppet 3 to 4 deprication error

417 views
Skip to first unread message

rhpupp...@gmail.com

unread,
Jan 22, 2016, 4:51:06 PM1/22/16
to Puppet Users
I'm planning to migrate puppet3.8 to 4.x, so testing the compatibility of code by using parser=future in puppet.conf file and was stuck at the following error when i run puppet agent. The error is pointing at the regular expression. Any help is appreciated.

Code:
---------------
if ($::enable_nfsd !~ /^false$/) and (($:: enalbe_nfsd =~ /^true$/) or ($::local_nfsd == "true"))

---------------


Error 400 on server: Evaluation Error: left match operand must result in a string value. Got an undef value at *****.pp .

Trevor Vaughan

unread,
Jan 22, 2016, 5:24:33 PM1/22/16
to puppet...@googlegroups.com
If that's a copy/paste, then your second occurrence of enable_nfsd is misspelled.

Trevor

--
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/abda8229-0c5a-417e-bebd-eefc2b545b50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699

-- This account not approved for unencrypted proprietary information --

rhpupp...@gmail.com

unread,
Jan 22, 2016, 5:38:35 PM1/22/16
to Puppet Users
I typed the code here. It's a typo here in the post. Still getting the error.


On Friday, January 22, 2016 at 11:24:33 AM UTC-6, Trevor Vaughan wrote:
If that's a copy/paste, then your second occurrence of enable_nfsd is misspelled.

Trevor
On Fri, Jan 22, 2016 at 11:51 AM, <rhpupp...@gmail.com> wrote:
I'm planning to migrate puppet3.8 to 4.x, so testing the compatibility of code by using parser=future in puppet.conf file and was stuck at the following error when i run puppet agent. The error is pointing at the regular expression. Any help is appreciated.

Code:
---------------
if ($::enable_nfsd !~ /^false$/) and (($:: enable_nfsd =~ /^true$/) or ($::local_nfsd == "true"))

---------------


Error 400 on server: Evaluation Error: left match operand must result in a string value. Got an undef value at *****.pp .

--
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/abda8229-0c5a-417e-bebd-eefc2b545b50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Trevor Vaughan

unread,
Jan 22, 2016, 6:53:57 PM1/22/16
to puppet...@googlegroups.com
From the error, I would say that not all of those values are defined at that point and that's why you're seeing issues.

You'll need to rewrite the statement to check if the variables are defined.

Trevor


For more options, visit https://groups.google.com/d/optout.

rhpupp...@gmail.com

unread,
Jan 22, 2016, 7:30:28 PM1/22/16
to Puppet Users
The values are defined and this class is working with puppet3 but showing error when i use parser=future. Any syntax errors/pup4 compatibility issue with this code ?

Hunter Haugen

unread,
Jan 22, 2016, 11:04:09 PM1/22/16
to puppet-users
I don't see anything in that line that is incompatible with puppet 4's parser. Perhaps previous lines that set the values of $enable_nfsd or $local_nfsd are affected by the parser?



-Hunter

Jeremiah Powell

unread,
Jan 24, 2016, 6:16:16 AM1/24/16
to Puppet Users
The error might be confusing since it is a programmer-ese statement from the parser instead of simple English sentence.  

The programmer-ese is straightforward to decode from the provided example. One of the variables on the left side regular expressions or the left side of the string comparison is empty.  

In Puppet 3 this would cause a comparison against the false empty string value "".  

In Puppet 4 any place code depended upon the kerning of nil values to strings causes errors like this.  For instance, I have a considerable amount of code in a Puppet 3 environment that is impacted by this, including some publicly available code.

Missing variable statements like this are simple enough to troubleshoot and only require very basic programming skills to do so.
  
The first option is to replace the code with a simple series of notify() or other 'printing' statements with the variables encoded inside strings since interpolation of a nil string won't cause the parser to fail.

The second option is to rewrite the code to use nested if statements.  Then the parser should return the line with the bad variable:

if ($::enable_nfsd !~ /^false$/) {
  if ($:: enable_nfsd =~ /^true$/) { 
# ... code ... 
  } 
  if ($::local_nfsd == "true") { 
#  ... code ... 
  }
}

Note that you'd want to abstract the '... code ...' into a shared block if you were going to keep the refactored one-line-per-variable statements.

Of course, both of these techniques can be combined.

Once you know that you can trace back to discover where the missing variable is not being set.

So, which variable is missing?

Ryan Anderson

unread,
Jan 24, 2016, 2:13:10 PM1/24/16
to Puppet Users
In updating my code for puppet4, I've found simply enclosing the facts in double-quotes is all that is needed. These cases are generally an issue where the fact involved is parsed on a system where the fact isn't defined, so by putting double-quotes, you retain the fact for platforms that have it, and it returns to nil for those that don't.
Reply all
Reply to author
Forward
0 new messages