Ask Your Question
0

accessing the ip address of the puppet master in a variable in a template

asked 2015-06-03 06:15:23 -0500

abhishek gravatar image

updated 2015-06-03 09:57:23 -0500

I'm a relative noob on puppet and I've this seemingly very obvious question that I tried to search around but couldn't make any headway.

I'd like to fillin the ip address of the puppet master automatically in a template using a 'fact' var. Is that possible?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-06-03 12:25:03 -0500

cbarbour gravatar image

You can use the $server_facts variables for this purpose.

https://docs.puppetlabs.com/puppet/la...factsandbuiltinvars.html#serverfacts-variable

However, I strongly advise against embedding the server IP in your templates; if you ever decide to go multi-master, either for redundancy or load balancing, doing so will cause your templates to flap. This can make your run non-idempotent, and can cause temporary service disruption.

A better solution would be to store the IP as hieradata, separate from your sever. Unless your intent is to configure the server parameter in your puppet.conf file, you may be tying a service to your puppetmaster that might not always live on the puppetmaster.

edit flag offensive delete link more

Comments

thanks, hiera seems a better solution.

abhishek gravatar imageabhishek ( 2015-06-04 08:12:04 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-06-03 06:15:23 -0500

Seen: 349 times

Last updated: Jun 03 '15