Hi,

I'm trying to use variables stored in hiera files in module templates. I 
read it's better to avoid to use hiera function in templates so i tried to 
get the hiera value in the config.pp manifest with a local variable.
Then to use the local variable in the template, but it doesn't work.

*common.yaml*

---
apache_packages_list:
 - apr-1.4.8
 - apr-devel-1.4.8
 - apr-util-1.5.2
 - apr-util-devel-1.5.2
 - distcache-1.4.5
 - distcache-devel-1.4.5
 - httpd-2.4.6
 - httpd-tools-2.4.6 
 - mod_ssl-2.4.6
 
accounts_conf_filename: accounts.victorbuckservices.com.conf
accounts_conf_balancer_filename: 
accounts.victorbuckservices.com.balancer.conf
certificate_filename: all.dev.victorbuckservices.com.crt
key_filename: all.dev.victorbuckservices.com.key


*ServerName: accounts.dev.victorbuckservices.comServerAdmin: 
[email protected]*
SSLCertificateFile: /etc/pki/tls/certs/all.dev.victorbuckservices.com.crt
SSLCertificateKeyFile: 
/etc/pki/tls/private/all.dev.victorbuckservices.com.key
  

*config.pp*

class apache::config { 
    $accounts_conf_filename                = hiera('accounts_conf_filename')
    $accounts_conf_balancer_filename  = 
hiera('accounts_conf_balancer_filename')
    $crt_filename                                 = 
hiera('certificate_filename')
    $key_filename                                = hiera('key_filename')
    
   
* $servername = hiera('ServerName')    $serveradmin = hiera('ServerAdmin')*
    
    file {"/etc/httpd/conf.d/$accounts_conf_filename":
        ensure   => file,
        content  => 
template("/etc/puppet/hieradata/$accounts_conf_filename.erb"),
    }
  
    file {"/etc/httpd/conf.d/$accounts_conf_balancer_filename":
        ensure   => file,
        content  => 
template("/etc/puppet/hieradata/$accounts_conf_balancer_filename"),
    }
    
    file {'/etc/pki/tls/certs/$crt_filename':
        ensure   => file,
        content  => template("/etc/puppet/hieradata/$crt_filename"),
    }

    file {'/etc/pki/tls/private/$key_filename':
        ensure   => file,
        content  => template("/etc/puppet/hieradata/$key_filename"),
    }

}

*accounts.victorbuckservices.com.conf.erb*

<VirtualHost accounts.dev.victorbuckservices.com:80>
   ServerName <% ServerName =  
scope.lookupvar('apache::config::servername') %> 
    ServerAdmin <% ServerAdmin = 
scope.lookupvar('apache::config::serveradmin') %> 

I also tried syntax as follow:
ServerName <%= scope.function_hiera('ServerName') %>
ServerName <%= @servername %> 

But i doesn't works neither.


Any idea or suggestion to make this right?

Cheers,
Christian

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/505d7ccb-20f2-4af6-a2f9-66a03535e495%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to