Andr? Lu?s Lopes
2011-Jan-08 22:12 UTC
[Puppet Users] Passing node hostname to the Puppet managed node
Hi, First of all, this is my very first message to this list, so please bear with me while I''m getting used to it. Sorry for any non-standard way to ask a question here which I can be using without prior knowledgment. I would like to be able to set up some config parameters on a given node which is going to be config-managed by Puppet and, for various reasons, I would like to be able to set it''s hostname on some node''s config files. Is there any way I could make Puppet pass the node hostname via a manifest/class/whatever ? I know thatone can use Facter''s variables into Puppet''s manifests (at least I recall reading about it somewhere) but I was unable to actually get it working and I know that Facter does have hostname as one of the available variables. Any ideas ? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Ben Beuchler
2011-Jan-08 23:42 UTC
Re: [Puppet Users] Passing node hostname to the Puppet managed node
I believe you''re looking for templates. http://docs.puppetlabs.com/guides/templating.html As an example: file { "/etc/hosts": content => template("hosts.erb") } And the template would contain this: 127.0.0.1 localhost 192.168.99.99 <%= hostname %> <%= fqdn %> -Ben -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Daniel Pittman
2011-Jan-09 03:46 UTC
Re: [Puppet Users] Passing node hostname to the Puppet managed node
On Sat, Jan 8, 2011 at 14:12, Andr? Lu?s Lopes <andrelop@andrelop.org> wrote:> First of all, this is my very first message to this list, so please bear > with me while I''m getting used to it. > Sorry for any non-standard way to ask a question here which I can be using > without prior knowledgment.Hey, thanks for joining us. We love to have new folks come in and start using puppet. :)> Is there any way I could make Puppet pass the node hostname via a > manifest/class/whatever ? I know > thatone can use Facter''s variables into Puppet''s manifests (at least I > recall reading about it somewhere) > but I was unable to actually get it working and I know that Facter does have > hostname as one of the > available variables. > Any ideas ?Ben gave the syntax needed to use this in a template, but you should be able to use either of the ''hostname'' or ''fqdn'' facts anywhere in puppet when you run it. If that isn''t working, it can help to post the snippet of puppet code that is broken. (Ideally, work out a half-dozen lines that don''t work rather than your entire manifest, that makes it easier to help you, but either way is fine.) The reason for doing that is once, say, I have a copy of the manifest I can test it on my machine and see if it works for me - or fix it, if it doesn''t. :) Anyway, welcome to the list, Daniel -- ✉ Daniel Pittman <daniel@rimspace.net> ⌨ daniel@rimspace.net (XMPP) ☎ +1 503 893 2285 ♻ made with 100 percent post-consumer electrons -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
André Luís Lopes
2011-Jan-09 12:01 UTC
Re: [Puppet Users] Passing node hostname to the Puppet managed node
Hello, 2011/1/9 Daniel Pittman <daniel@rimspace.net>:> > Hey, thanks for joining us. We love to have new folks come in and > start using puppet. :)That''s nice to hear. Thank you :-)> Ben gave the syntax needed to use this in a template, but you should > be able to use either of the ''hostname'' or ''fqdn'' facts anywhere in > puppet when you run it. If that isn''t working, it can help to post > the snippet of puppet code that is broken. (Ideally, work out a > half-dozen lines that don''t work rather than your entire manifest, > that makes it easier to help you, but either way is fine.) > > The reason for doing that is once, say, I have a copy of the manifest > I can test it on my machine and see if it works for me - or fix it, if > it doesn''t. :)I''ll give Ben''s suggestion a try once I get to my testing environment again. Thanks for the warm welcome. You guys rock :-) -- André Luís Lopes andrelop@andrelop.org http://andrelop.wordpress.com/ Public GPG KeyID : 9D1B82F6 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Seemingly Similar Threads
- Puppet updating from relative directories or chroot
- variables created with generate() function have a newline when used in a template
- Accessing Facter in other languages than Ruby?
- /etc/passwd, shadow, group, hosts
- Best practices for building a file from distributed data.