FAQ
How do I retrieve the name of the module where a define is used ?

Consider the following

file java/manifests/setup.pp

define java::setup (
$source = undef,){
file { $cachedir:
ensure => 'directory',
owner => 'root',
group => 'root',
mode => '644'
}

file { "${cachedir}/${source}":
source => "puppet:///modules/${module_name}/${source}",
require => File[$cachedir],
}
# stripped out for readability
}

file mywebapp/manifests/init.pp

# stripped out for readability
java::setup { 'mywebapp-java':
source => 'jdk-7u7-linux-x64.gz',
}
# stripped out for readability

I want the source to be constructed
as puppet:///modules/mywebapp/jdk-7u7-linux-x64.gz instead of
puppet:///modules/java/jdk-7u7-linux-x64.gz



~Francis

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Nikola Petrov at Feb 21, 2013 at 3:19 pm
    Try using the variable *caller_module_name* instead
    file { "${cachedir}/${source}":
    source => "puppet:///modules/${caller_module_name}/${source}",
    ^^^^^^^^^^^^^^^^^^^^
    require => File[$cachedir],
    }
    --
    Nikola

    On Thu, Feb 21, 2013 at 07:33:00PM +0530, Francis Pereira wrote:
    How do I retrieve the name of the module where a define is used ?

    Consider the following

    file java/manifests/setup.pp

    define java::setup (
    $source = undef,){
    file { $cachedir:
    ensure => 'directory',
    owner => 'root',
    group => 'root',
    mode => '644'
    }

    file { "${cachedir}/${source}":
    source => "puppet:///modules/${module_name}/${source}",
    require => File[$cachedir],
    }
    # stripped out for readability
    }

    file mywebapp/manifests/init.pp

    # stripped out for readability
    java::setup { 'mywebapp-java':
    source => 'jdk-7u7-linux-x64.gz',
    }
    # stripped out for readability

    I want the source to be constructed
    as puppet:///modules/mywebapp/jdk-7u7-linux-x64.gz instead of
    puppet:///modules/java/jdk-7u7-linux-x64.gz



    ~Francis
    --
    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Francis Pereira at Feb 21, 2013 at 3:56 pm
    Thanks Nikola. I didn't know that variable exists. Is there a list of
    all available variables somewhere ?

    ~Francis
    On Feb 21, 2013, at 8:49 PM, Nikola Petrov wrote:

    Nikola
    --
    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Nikola Petrov at Feb 25, 2013 at 2:17 pm
    Well you can use calling_module and also all the variables defined in http://docs.puppetlabs.com/puppet/latest/reference/lang_variables.html#facts-and-built-in-variables

    Not sure why calling_module is not there at the moment. There might
    be two reasons for this:
    * it is more experimental
    * it is older and $caller_module_name should be used instead(look at the
    link)

    Maybe someone can step in and make this more clear to both of us ;)

    --
    Nikola
    On Thu, Feb 21, 2013 at 09:20:57PM +0530, Francis Pereira wrote:
    Thanks Nikola. I didn't know that variable exists. Is there a list of
    all available variables somewhere ?

    ~Francis
    On Feb 21, 2013, at 8:49 PM, Nikola Petrov wrote:

    Nikola
    --
    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?hl=en.
    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Nick Fagerlund at Feb 25, 2013 at 10:58 pm
    calling_module isn't a puppet variable. It's something special from the
    Puppet backend to Hiera, and I'm not entirely sure how it works or even
    whether it currently works. $caller_module_name is a legit puppet variable,
    though.
    On Monday, February 25, 2013 6:10:37 AM UTC-8, nikolavp wrote:

    Well you can use calling_module and also all the variables defined in
    http://docs.puppetlabs.com/puppet/latest/reference/lang_variables.html#facts-and-built-in-variables

    Not sure why calling_module is not there at the moment. There might
    be two reasons for this:
    * it is more experimental
    * it is older and $caller_module_name should be used instead(look at the
    link)

    Maybe someone can step in and make this more clear to both of us ;)

    --
    Nikola
    On Thu, Feb 21, 2013 at 09:20:57PM +0530, Francis Pereira wrote:
    Thanks Nikola. I didn't know that variable exists. Is there a list of
    all available variables somewhere ?

    ~Francis
    On Feb 21, 2013, at 8:49 PM, Nikola Petrov wrote:

    Nikola
    --
    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 <javascript:>.
    To post to this group, send email to puppet...@googlegroups.com<javascript:>.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Nikola Petrov at Feb 26, 2013 at 8:37 am
    Hmm I can swear this was discussed here as a recommendation but maybe I
    am wrong. Will change my defines to use *caller_module_name*. Thanks for
    clarifying this!

    --
    Nikola
    On Mon, Feb 25, 2013 at 02:30:39PM -0800, Nick Fagerlund wrote:
    calling_module isn't a puppet variable. It's something special from the
    Puppet backend to Hiera, and I'm not entirely sure how it works or even
    whether it currently works. $caller_module_name is a legit puppet variable,
    though.
    On Monday, February 25, 2013 6:10:37 AM UTC-8, nikolavp wrote:

    Well you can use calling_module and also all the variables defined in
    http://docs.puppetlabs.com/puppet/latest/reference/lang_variables.html#facts-and-built-in-variables

    Not sure why calling_module is not there at the moment. There might
    be two reasons for this:
    * it is more experimental
    * it is older and $caller_module_name should be used instead(look at the
    link)

    Maybe someone can step in and make this more clear to both of us ;)

    --
    Nikola
    On Thu, Feb 21, 2013 at 09:20:57PM +0530, Francis Pereira wrote:
    Thanks Nikola. I didn't know that variable exists. Is there a list of
    all available variables somewhere ?

    ~Francis

    On Feb 21, 2013, at 8:49 PM, Nikola Petrov <niko...@gmail.com<javascript:>>
    wrote:
    Nikola
    --
    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 <javascript:>.
    To post to this group, send email to puppet...@googlegroups.com<javascript:>.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    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?hl=en.
    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedFeb 21, '13 at 2:59p
activeFeb 26, '13 at 8:37a
posts6
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase