FAQ
I have a utils module that contains common utilities. Most are defined
types.

However, I've just added the first custom function in
utils/lib/puppet/parser/functions/basename.rb .

It seems this cannot be referenced in the intuitive fashion from another
module, namely:

utils::basename(args)

Is it possible to call a custom function from another module? If so, what
is the syntax? If not, is there a workaround besides copying the custom
function to the referencing module?

Sincere thanks,

David

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/4TtDJEfErnIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • KomodoDave at Nov 29, 2012 at 11:58 am
    Ah, I've got it: simply include the module then call the function
    unqualified:

    include utils
    # ...
    basename(args)


    David

    On Thursday, November 29, 2012 11:37:01 AM UTC, KomodoDave wrote:

    I have a utils module that contains common utilities. Most are defined
    types.

    However, I've just added the first custom function in
    utils/lib/puppet/parser/functions/basename.rb .

    It seems this cannot be referenced in the intuitive fashion from another
    module, namely:

    utils::basename(args)

    Is it possible to call a custom function from another module? If so, what
    is the syntax? If not, is there a workaround besides copying the custom
    function to the referencing module?

    Sincere thanks,

    David
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/I9hNbEbGI9EJ.
    To post to this group, send email to [email protected].
    To unsubscribe from this group, send email to [email protected].
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • KomodoDave at Nov 29, 2012 at 12:04 pm
    Hmm.. actually there's still something amiss.

    Doing the include as described above changed the error from:

    Error 400 on SERVER: Unknown function utils::basename


    to:

    Error 400 on SERVER: Function 'basename' does not return a value


    ..which made me think it was now being found.

    I then fixed the bug by adding to basename definition the required :type =>
    :rvalue .

    However, instead of solving the issue I now see the message:

    Error 400 on SERVER: undefined method `basename'


    Any suggestions would be most welcome at this point!

    Thank you.

    David

    On Thursday, November 29, 2012 11:58:09 AM UTC, KomodoDave wrote:

    Ah, I've got it: simply include the module then call the function
    unqualified:

    include utils
    # ...
    basename(args)


    David

    On Thursday, November 29, 2012 11:37:01 AM UTC, KomodoDave wrote:

    I have a utils module that contains common utilities. Most are defined
    types.

    However, I've just added the first custom function in
    utils/lib/puppet/parser/functions/basename.rb .

    It seems this cannot be referenced in the intuitive fashion from another
    module, namely:

    utils::basename(args)

    Is it possible to call a custom function from another module? If so, what
    is the syntax? If not, is there a workaround besides copying the custom
    function to the referencing module?

    Sincere thanks,

    David
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/mtSEv-FNUkkJ.
    To post to this group, send email to [email protected].
    To unsubscribe from this group, send email to [email protected].
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • KomodoDave at Nov 29, 2012 at 12:37 pm
    I fixed the problem by prefixing the one-line definition of basename with a
    return.

    Should I infer Puppet doesn't support the standard Ruby mechanism of
    returning the last evaluated result within a function?

    I did have:

    module Puppet::Parser::Functions
    newfunction(:basename, :type => :rvalue) do |args|
    File.basename(*args)
    end
    end

    ..which resulted in:

    err: Could not retrieve catalog from remote server: Error 400 on SERVER:
    undefined method `basename'

    I now have:

    module Puppet::Parser::Functions
    newfunction(:basename, :type => :rvalue) do |args|
    return File.basename(*args)
    end
    end

    ..which works like a charm.

    Cheers,

    David

    On Thursday, November 29, 2012 12:04:53 PM UTC, KomodoDave wrote:

    Hmm.. actually there's still something amiss.

    Doing the include as described above changed the error from:

    Error 400 on SERVER: Unknown function utils::basename


    to:

    Error 400 on SERVER: Function 'basename' does not return a value


    ..which made me think it was now being found.

    I then fixed the bug by adding to basename definition the required :type
    => :rvalue .

    However, instead of solving the issue I now see the message:

    Error 400 on SERVER: undefined method `basename'


    Any suggestions would be most welcome at this point!

    Thank you.

    David

    On Thursday, November 29, 2012 11:58:09 AM UTC, KomodoDave wrote:

    Ah, I've got it: simply include the module then call the function
    unqualified:

    include utils
    # ...
    basename(args)


    David

    On Thursday, November 29, 2012 11:37:01 AM UTC, KomodoDave wrote:

    I have a utils module that contains common utilities. Most are defined
    types.

    However, I've just added the first custom function in
    utils/lib/puppet/parser/functions/basename.rb .

    It seems this cannot be referenced in the intuitive fashion from another
    module, namely:

    utils::basename(args)

    Is it possible to call a custom function from another module? If so,
    what is the syntax? If not, is there a workaround besides copying the
    custom function to the referencing module?

    Sincere thanks,

    David
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/MYBHiQWXeNIJ.
    To post to this group, send email to [email protected].
    To unsubscribe from this group, send email to [email protected].
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedNov 29, '12 at 11:37a
activeNov 29, '12 at 12:37p
posts4
users1
websitepuppetlabs.com

1 user in discussion

KomodoDave: 4 posts

People

Translate

site design / logo © 2023 Grokbase