FAQ
Hallo,
I'm developing a custom function that is exhibiting some odd behavior, so I
would like to debug it.
How do I load it in the ruby shell in a way that lets me execute it?
I have tried the steps on the documentation:

irb(main):001:0> require 'puppet'
=> true

irb(main):002:0> require 'phash2text.rb'

=> true

irb(main):003:0> Puppet::Parser::Functions.function(:hash2text)

=> "function_hash2text"

irb(main):004:0> function_hash2text

NameError: undefined local variable or method `function_hash2text' for
main:Object
from (irb):4

from :0
But how can I actually execute the function?


Thanks,
Andrea

--
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.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Henrik Lindberg at Sep 18, 2013 at 12:04 pm
    Here is how to invoke the function 'fqdn_rand(30)' in irb

    irb > require 'puppet'
    irb > scope => Puppet::Parser::Scope.new_for_test_harness('localhost')
    irb>> scope.function_fqnrand([30])

    => "1"

    That may not work if your function requires a fully configured system.
    If you need that set the breakpoint inside your function, and then
    invoke with
    puppet apply - i.e. puppet apply -e 'notice fqdn_rand(30)'

    A good approach is to start with an rspec test for your function, then
    you can invoke that when you want to debug. Look at
    spec/unit/parser/functions/fqdn_rand_spec.rb for an example how to test
    a function.

    Hope that helps
    - henrik
    On 2013-17-09 14:19, Andrea Ieri wrote:
    Hallo,
    I'm developing a custom function that is exhibiting some odd behavior,
    so I would like to debug it.
    How do I load it in the ruby shell in a way that lets me execute it?
    I have tried the steps on the documentation:

    irb(main):001:0> require 'puppet'

    => true

    irb(main):002:0> require 'phash2text.rb'

    => true

    irb(main):003:0> Puppet::Parser::Functions.function(:hash2text)

    => "function_hash2text"

    irb(main):004:0> function_hash2text

    NameError: undefined local variable or method
    `function_hash2text' for main:Object

    from (irb):4

    from :0


    But how can I actually execute the function?


    Thanks,
    Andrea

    --
    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.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    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.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedSep 17, '13 at 12:21p
activeSep 18, '13 at 12:04p
posts2
users2
websitepuppetlabs.com

2 users in discussion

Henrik Lindberg: 1 post Andrea Ieri: 1 post

People

Translate

site design / logo © 2021 Grokbase