Dear Puppet users,
I''m quite new to Puppet, and I know less about ruby. That''s
probably
why I have this question, hopefully you could answer it. I have
google''d quite a lot about it, without success:
I install nodes on a private subnet, and they get their FQDN from a
local DHCP server, so the $hostname variable is correct. But then I
want to make puppet configure the machine''s interface with the public
IP address, and that''s known by the production DNS server (not
accessible from the client on the private subnet).
Puppet Master has access to the production DNS, so I thought I could
run a template (they run in the master, right?) to get the right IP,
and pass it on to the puppet client. So I specify this inside the node
{}:
$new_ip=inline_template("<%= system(\"host $hostname|awk
''{print \
$4}''\") -%>")
notify { "New IP: $new_ip": }
But I get:
notice: New IP: true
The weird thing is that the command is actually running well. If I run
puppetmasterd by hand, with --no-daemonize, I can see the IP being
written to stdout on the masterd. So, it seems the problem is that the
template is not capturing the output of the system command.
Do you know what am I doing wrong? How do I capture the system()
output?
Thanks!
Pablo
--
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.
"pablo.fernandez@cscs.ch" <pablo.fernandez@cscs.ch> writes:> Do you know what am I doing wrong? How do I capture the system() > output?Try using %x{} instead of system. The system() function returns the return code of the process, not the output. Oh, and "chomp" the extra whitespace off the output. If you''re new to ruby, you can test ruby code in "irb", interactive ruby. irb> %x{hostname --fqdn}.chomp => "dagon.fnord.no" -- Stig Sandbeck Mathisen Any sufficiently advanced incompetence is indistinguishable from malice -- 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.
Hi,> Try using %x{} instead of system. The system() function returns the > return code of the process, not the output.> irb> %x{hostname --fqdn}.chomp > => "dagon.fnord.no"That worked, thanks! For the record, this is how it looks like: $new_ip=inline_template("<%= %x{host $hostname|awk ''{print \$4}''}.chomp %>") notify { "New IP: $new_ip": } Kind regards, Pablo -- 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.