# vardir translation problem

Hello,

Just wondering if it's possible to reference the puppet agent's vardir in a puppet class instead of it defaulting to the master's value? We have a puppet class that creates a directory defined as follows:

"${settings::vardir}/dummy-dir" However, when we include this class on our agents, it translates vardir to the puppet server's value of /opt/puppetlabs/server/data/puppetserver which obviously doesn't exist on our agents. The agent's vardir is /opt/puppetlabs/puppet/cache, but I'd prefer not to hardcode that value in the puppet class if there's a way around it. Any ideas? Thanks edit retag close merge delete ## Comments is vardir set on the agents puppet config? ( 2017-06-12 03:47:10 -0500 )edit I've tried setting it on the client side (/etc/puppetlabs/puppet/puppet.conf), and that successfully pulls down all the libraries to whatever directory I set it to. However, it still tries to translate the directory I have defined in my class to the master's vardir. We use that dir for copying files ( 2017-06-12 16:29:41 -0500 )edit ## 1 Answer Sort by » oldest newest most voted K my apologies on my comment i should have checked first but anyways I simulated your problem. And indeed when using:${::settings::vardir} the vairable would use the master settings. This is expected apparantly because when you call the ::settings facts you're calling on the master server settings. about server facts

so anyways for the solution: you have to use the puppet_vardir fact to get the vardir for your agent.

I also set the vardir in agent section on my node if it does not work.

[agent]

vardir = /some/dir/name

\$facts['puppet_vardir']

more

That did the trick! I didn't realize that fact existed so it was an easy fix at least. Thanks a lot for the help!

( 2017-06-13 14:04:19 -0500 )edit