# Access variable from other manifest

Hi, I'm trying to write my own module ...Right now it is only a experimental and consists from 2 manifests...

### init.pp

class ntp (
$var =$ntp::params::ip1,
)
{
file { '/tmp/module.conf':
path    => '/tmp/module.conf',
ensure  => file,
content => "$var", } }  ### params.pp class ntp::params {$ip1 = "8.8.8.8",
}


I just want to print the value stored in manifest params.pp in variable ip1 to the file /tmp/module.conf, but I always get no result in the file.. if I change variable $var to some string it appears in the file...Could you help me, what am I doing wrong? edit retag close merge delete ## 2 Answers Sort by » oldest newest most voted Change the ntp class definition to add an inherits ntp::params, this ensures that it loads the ntp::params class to fill in the default parameters. class ntp ($var = \$ntp::params::ip1,
) inherits ntp::params
{
...
}


Please note that you should prefer storing data in modules with Puppet 4 which has advantages over the "params" pattern. See Quick intro to module data for more information.

more

Thank you very much, finally it helped..I tried inherits thing as well but I had some mistakes with commas in variables.. Now it works fine.. I found out that in manifests between { } brackets there is no need for commas in variables declaration..

more