FAQ
Hi.

I want to run script which is distributed with my module, but the
problem is I have to then hardcode the path to the script in the
generate function call, for example:

generate("/etc/puppet/environments/${environment}/modules/mymodule/scripts/myscript")

But what If some other site uses other path to their modules, or doesn't
use environments at all? Is it possible somehow to detect the dir in
which the module is installed, so that I can use something like:


generate("$modulepath/scripts/myscript")



--
Jakov Sosic
www.srce.unizg.hr

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Nan Liu at Dec 27, 2012 at 6:57 pm

    On Thu, Dec 27, 2012 at 10:29 AM, Jakov Sosic wrote:

    I want to run script which is distributed with my module, but the problem
    is I have to then hardcode the path to the script in the generate function
    call, for example:

    generate("/etc/puppet/**environments/${environment}/**
    modules/mymodule/scripts/**myscript")

    But what If some other site uses other path to their modules, or doesn't
    use environments at all? Is it possible somehow to detect the dir in which
    the module is installed, so that I can use something like:


    generate("$modulepath/scripts/**myscript")

    See stdlib:
    https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/parser/functions/get_module_path.rb


    HTH,

    Nan

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Jakov Sosic at Dec 27, 2012 at 11:37 pm

    On 12/27/2012 07:57 PM, Nan Liu wrote:
    On Thu, Dec 27, 2012 at 10:29 AM, Jakov Sosic wrote:

    I want to run script which is distributed with my module, but the
    problem is I have to then hardcode the path to the script in the
    generate function call, for example:

    generate("/etc/puppet/__environments/${environment}/__modules/mymodule/scripts/__myscript")

    But what If some other site uses other path to their modules, or
    doesn't use environments at all? Is it possible somehow to detect
    the dir in which the module is installed, so that I can use
    something like:


    generate("$modulepath/scripts/__myscript")


    See stdlib:
    https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/parser/functions/get_module_path.rb
    I've found that already. But I've decided to write my own function which
    returns path to current module directory. If that doesn't succeed then
    I'll use get_module_path.


    --
    Jakov Sosic
    www.srce.unizg.hr

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Jakov Sosic at Dec 28, 2012 at 3:16 pm

    On 12/28/2012 12:37 AM, Jakov Sosic wrote:

    I've found that already. But I've decided to write my own function which
    returns path to current module directory. If that doesn't succeed then
    I'll use get_module_path.
    Hm, I'm having problems with writing custom functions...

    One question first - is it possible for custom function to generate some
    files on a given path on puppet master? I've tried the following:

    module Puppet::Parser::Functions
    newfunction(:generate_host_keys, :type =>:rvalue) do |args|

    Dir.mkdir("/tmp/something", 755)

    end
    end


    But dir isn't created on puppet master on agent run...




    --
    Jakov Sosic
    www.srce.unizg.hr

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    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
postedDec 27, '12 at 6:29p
activeDec 28, '12 at 3:16p
posts4
users2
websitepuppetlabs.com

2 users in discussion

Jakov Sosic: 3 posts Nan Liu: 1 post

People

Translate

site design / logo © 2022 Grokbase