On Thu, Jul 16, 2015 at 11:21 AM Fabien Delpierre <
[email protected]> wrote:

> Hi folks,
> First off, let me underline that I'm completely new to Puppet. I'm an
> intermediate Chef user but just changed jobs, and the new place is a Puppet
> shop and I've never touched Puppet in my life. I have not had time to
> acclimatize to it at all, but today my coworker asked me to make some
> changes to running servers. Gotta start somewhere. My being a newbie also
> means I'm not sure what information to give you but I'll try my best.
>
> In addition, we use Vagrant for local testing before pushing to servers,
> this is where the trouble occurs -- during Vagrant provisioning.
> We're using this box:
> http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box
> (CentOS 6.4)
> As far as I can tell, it ships with Puppet 3.1.1.
>

Ooo, old.


> The host computer -- my laptop -- is OS X 10.10.4, if it matters, and I'm
> using VirtualBox 5.0.
> Also using the following Vagrant plugins: vagrant-cachier 1.2.1,
> vagrant-librarian-puppet 0.7.1 and vagrant-share 1.1.3.
> Right now I can't use a newer version of the librarian plugin because it
> causes another, completely unrelated error. 0.7.1 is the version my
> coworker uses.
>
> During the Puppet run, I get the following error:
> ==> centos6: Error: undefined method `<' for :undef:Symbol at
> /tmp/vagrant-puppet/modules-0082ff7071bbf237d9411fcd54aae93c/profile/manifests/my_module.pp:29
> on node foo.bar.com
>
> This is the corresponding chunk of code:
>
> if $::operatingsystemmajrelease < 7 {
>

A minimal use case shows that if $::operatingsystemmajrelease is undef
(puppet's idea of nil) then this will happen, because you can't compare
undef with comparators. (I include --trace just to show it really is the
puppet manifest `<` and not a ruby method `<`)

[root@q2xuk1zrzaqpy3f ~]# puppet --version
3.1.1
[root@q2xuk1zrzaqpy3f ~]# puppet apply -e 'if $whatever < 5 {}' --trace
Error: undefined method `<' for :undef:Symbol at line 1 on node
q2xuk1zrzaqpy3f.delivery.puppetlabs.net
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/ast/comparison_operator.rb:28:in
`send'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/ast/comparison_operator.rb:28:in
`evaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/ast.rb:62:in
`safeevaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/ast/ifstatement.rb:20:in
`evaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/ast.rb:62:in
`safeevaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/ast/astarray.rb:25:in
`evaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/ast/astarray.rb:20:in
`each'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/ast/astarray.rb:20:in
`evaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/ast.rb:62:in
`safeevaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/resource/type.rb:136:in
`evaluate_code'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/resource.rb:81:in
`evaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/compiler.rb:282:in
`evaluate_main'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/compiler.rb:96:in
`compile'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/parser/compiler.rb:29:in
`compile'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/indirector/catalog/compiler.rb:83:in
`compile'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/util.rb:184:in
`benchmark'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/indirector/catalog/compiler.rb:81:in
`compile'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/indirector/catalog/compiler.rb:41:in
`find'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/indirector/indirection.rb:191:in
`find'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/application/apply.rb:204:in
`main'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/application/apply.rb:146:in
`run_command'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/application.rb:364:in
`run'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/application.rb:456:in
`plugin_hook'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/application.rb:364:in
`run'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/util.rb:504:in
`exit_on_fail'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/application.rb:364:in
`run'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/util/command_line.rb:132:in
`run'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/lib/puppet/util/command_line.rb:86:in
`execute'
/usr/lib/ruby/gems/1.8/gems/puppet-3.1.1/bin/puppet:4

Simple workaround is to check that the variable has a value before
comparing it:

[root@q2xuk1zrzaqpy3f ~]# puppet apply -e 'if $whatever and $whatever < 5
{}'
Notice: Finished catalog run in 0.20 seconds


But... $operatingsystemmajrelease is totally a valid fact on centos6 and
facter 1.7.6 that I get when gem installing puppet 3.1.1:

[root@q2xuk1zrzaqpy3f ~]# facter --version
1.7.6
[root@q2xuk1zrzaqpy3f ~]# facter operatingsystemmajrelease
6

So what version of facter does your vagrant box have? It looks like 1.6
does NOT have this fact, and thus the variable will be undef.

HTH


>   monit::foo { $webservice:
>     app_port    => hiera("${webservice}::http_port",undef,"foo/common"),
>     app_uri     =>
> hiera("${webservice}::app_uri",undef,"${webservice}/common"),
>   }
> } else {
>   include systemd_mon
>   systemd_mon::register { $webservice:
>     unit => $webservice,
>   }
> }
>
> Line 29 is the first one above. We have some CentOS 7 in the
> infrastructure so we need to handle it differently since CentOS 7 switched
> to systemd, as you probably know, hence the above chunk of code.
>
> It looks good to me, and my coworker, who is much more experienced with
> Puppet, also sees nothing wrong with it. Of course that works on his
> machine, so it sounds to me like nothing is indeed wrong with the code, but
> rather with something on my machine, but then again, the error occurs
> during the Puppet run inside the VM so I'm not sure how my machine would
> affect it. My coworker is stumped and obviously I don't know where to
> start.
>
> All I could find through Google was this:
> https://projects.puppetlabs.com/issues/8783
> But it's an ancient ticket and it doesn't look like the same problem, even
> though it's the same error, so I doubt this is helpful.
>
> Could anybody please suggest something to start troubleshooting this?
> Thanks!
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/105e47a4-cca3-42e7-876c-dcaee2685b77%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/105e47a4-cca3-42e7-876c-dcaee2685b77%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAJaQvGDcgCUZLEkZkoDMsrg8Vw0ZozhCzb7E-ZEmLj_MgtQG4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to