I have set up a puppetmaster test server where I can test new releases
of puppet before upgrading our puppetmaster production server.
It works, but there is one issue I'd like to solve:
The puppet.conf for all nodes (except the puppetmasters) is managed by
puppet (in modules/puppet/files/puppet.conf) because it needs to contain
the fqdn of our puppetmaster server: puppetmaster.ourdomain.com.
But every time I export our puppet code repository from subversion to
the test server, I have to manually modify the server name in that file
to puppetmaster-test.ourdomain.com. If I don't, then a test-node connecting
to the test server, will receive a puppet.conf with the production server
name, and subsequent puppet runs will connect to that server instead of
my test server.
As a solution I tried templating puppet.conf but cannot figure out what
variable to use to fill in the current puppet server name.
I could solve that by making a custom fact, but besides the huge overhead
of "puppetd --configprint server" running every 30 minutes on every node,
it is just weird for a server to have to ask the client for its own name.
So I'd really like to fix this in puppet code on the masters only.
Is there a way to access the local configuration parameter 'server'
within puppet? Or is there another, better solution I am missing?
Regards,
Robert Scheer
Sounds to me as though you had finally found a use for the generate
function, e.g. $master_host = generate("dnsdomainname -f").
http://docs.puppetlabs.com/references/stable/function.html#generate
;-) Just kidding, it's a useful feature alright. Maybe it will help you.
Regards,
Felix
See issue 2807 <http://projects.puppetlabs.com/issues/2807>.
In puppet-2.6, you can say
$server = $settings::server
In version 0.25, you can say
$server = inline_template("<%= Puppet.settings[:server] %>").
--apb (Alan Barrett)
> This isn't a very good answer, but the variable "$servername" contains the name of the server the client think's it's connecting to. That may do what you want.
This is a very good answer! Thank you. Where in the documentation did you
find this? It doesn't seem to be a standard fact from facter: it doesn't
show up in $vardir/yaml/facts/*.yaml on the master.
Robert Scheer
XS4ALL Systeembeheer
> Sounds to me as though you had finally found a use for the generate
> function, e.g. $master_host = generate("dnsdomainname -f").
>
> http://docs.puppetlabs.com/references/stable/function.html#generate
>
> ;-) Just kidding, it's a useful feature alright. Maybe it will help you.
Thanks, I now remember seeing that function a long time ago in the puppet
documentation, but couldn't imagine in what situation that would be useful.
This is one :-)
Robert Scheer
XS4ALL Systeembeheer
Actually, I seem to have it backwards. Looks like $servername is the server-side config variable which is why you can't find it. Alan Barrett seems to have a solution for getting the client side config. On the other hand, if your DNS is configured right, $servername should work too.
> Actually, I seem to have it backwards. Looks like $servername is the server-side config variable which is why you can't find it. Alan Barrett seems to have a solution for getting the client side config. On the other hand, if your DNS is configured right, $servername should work too.
Ah, now I know the variable name, I found out where this information
comes from:
http://projects.puppetlabs.com/projects/puppet/wiki/Frequently_Asked_Questions#Are+there+variables+available+other+than+those+provided+by+Facter?
My bad for not checking the FAQ. I expected to find this kind of
information in the official documentation (docs.puppetlabs.com)
Thanks again!
Robert Scheer
XS4ALL Systeembeheer
> In version 0.25, you can say
>
> $server = inline_template("<%= Puppet.settings[:server] %>").
Thanks! Puppet.settings[:server] is exactly what I was looking for. I had
tried variations of server, puppet.server and search(), but failed. Do you
know where in the documentation or in the wiki could I have found this?
Robert Scheer
XS4ALL Systeembeheer
As always, if you find bugs in the documentation, please feel free to
either supply patches or simply report the bugs.
http://projects.puppetlabs.com/projects/puppet-docs
https://github.com/puppetlabs/puppet-docs
>
> Robert Scheer
> XS4ALL Systeembeheer
>
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>
>
--
Nigel Kersten - Puppet Labs - http://www.puppetlabs.com
No, sorry. I think I picked it up from reading the source code.
--apb (Alan Barrett)