access variable inside module which was declared at inside profile

15 views
Skip to first unread message

java.f...@gmail.com

unread,
Jan 23, 2017, 6:03:29 PM1/23/17
to Puppet Users
Hi Everyone,

         Am very new to puppet. Can any one please help me to fix this issue !!
        I need to access $var1 at inside module folder actually which declared at profile.
  
  
#########################################################################
 /etc/puppetlabs/puppet/environment/dev/site/profile/manifest/abc.pp

      class profile::abc($var1 = '5' ) 
{
     ------- // some code here // --------

}
###########################################################################
/etc/puppetlabs/puppet/environment/dev/module/abc/manifest/abc.pp
I need to access $var1 in this file :- /module/abc/manifest/abc.pp
class abc($var1 = undef)
{
  --------// I want to access $var1 in this class. How I can access ????   // ---------------------
}

Martin Alfke

unread,
Jan 24, 2017, 1:40:28 AM1/24/17
to puppet...@googlegroups.com
You can access other modules variables by using the namespace of the variable as long as the class with the referring variable is known to the catalog compilation (has been included or declared).

e.g.
# modules/abc/manifests/init.pp
class abc {
$var = ‘foo’
}

# site/profile/manifests/abc.pp
class profile::abc {
include abc
$var = $abc::var
notify { $var: }
}

puppet apply -e ‘include profile::abc’
will return notify ‘foo’
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/ac7cfed8-3526-4df5-97c0-107fb05b4231%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages