John Lyman
2010-Feb-02 15:27 UTC
[Puppet Users] qualified variables inside of a node definition?
I''m trying to figure out the best way to achieve the following...
Inside of each node definition, I have variables for ip address,
default router, dns server, etc. I have a jumpstart module that has
several different file resources that use templates. In each
template, I would like to be able to use the values of the variables
in all nodes.
For example:
node foo { ipaddress => 1.2.3.4 }
node bar { ipaddress => 5.6.7.8 }
class jumpstart {
jumpstart_client = [ "foo", "bar" ]
file { "sysidcfg":
content => template("sysidcfg.erb")
}
}
sysidcfg.erb:
<% jumpstart_client.each do |client| -%>
hostname=<%= client %> ip_address=<%= client::ipaddress %>
<% end -%>
I don''t think the above is possible. What is the best way to
accomplish this (if any)? I think this is where exported resources
would come in to play, but in this case they will not work because I
want the info on the jumpstart server before puppet is even installed/
run on the node. In other words, I want to define the node in puppet,
do a catalog run on the jumpstart server to update it''s config files
based on the new node definition, and then jumpstart the node (which
also installs puppet).
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.
Carl Caum
2010-Feb-03 17:29 UTC
Re: [Puppet Users] qualified variables inside of a node definition?
You could use stored configs and collect all the values for all the hosts on all
the hosts. So something like this:
node foo { ipaddress = 1.2.3.4 }
node bar { ipaddress = 5.6.7.8 }
class jumpstart {
@@file{ "/etc/sysidcfg.d/$hostname":
content => template("sysidcfg.erb"),
tag => sysidcfg,
notify => Exec["rebuild sysidcfg"];
}
File<<| tag == "sysidcfg" |>>
file {"/etc/sysidcfg.d":
ensure => directory;
}
exec {"rebuild sysidcfg":
command => "cat /etc/sysidcfg.d/* > /etc/sysidcfg.erb",
unless => "test \"`cat /etc/sysidcfg.d/* | md5sum |
awk ''{print \$1}''`\" == \"`cat /etc/sysidcfg |
md5sum | awk ''{print \$1}''`\"";
}
}
sysidcfg.erb:
hostname=<%= hostname %> ip_address=<%= ipaddress %>
I think you could also use extlookup, but I don''t have any experience
with that. And I pulled the above manifest out of my back side, so you might
have to tinker with it.
On Feb 2, 2010, at 9:27 AM, John Lyman wrote:
> I''m trying to figure out the best way to achieve the following...
>
> Inside of each node definition, I have variables for ip address,
> default router, dns server, etc. I have a jumpstart module that has
> several different file resources that use templates. In each
> template, I would like to be able to use the values of the variables
> in all nodes.
>
> For example:
> node foo { ipaddress => 1.2.3.4 }
> node bar { ipaddress => 5.6.7.8 }
>
> class jumpstart {
> jumpstart_client = [ "foo", "bar" ]
> file { "sysidcfg":
> content => template("sysidcfg.erb")
> }
> }
>
> sysidcfg.erb:
> <% jumpstart_client.each do |client| -%>
> hostname=<%= client %> ip_address=<%= client::ipaddress %>
> <% end -%>
>
> I don''t think the above is possible. What is the best way to
> accomplish this (if any)? I think this is where exported resources
> would come in to play, but in this case they will not work because I
> want the info on the jumpstart server before puppet is even installed/
> run on the node. In other words, I want to define the node in puppet,
> do a catalog run on the jumpstart server to update it''s config
files
> based on the new node definition, and then jumpstart the node (which
> also installs puppet).
>
> 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.
>
--
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.
John Lyman
2010-Feb-03 20:33 UTC
[Puppet Users] Re: qualified variables inside of a node definition?
> You could use stored configs and collect all the values for all the hosts on all the hosts.This won''t work in my case because I need the value from a host *before* the host actually has puppet installed and running. -- 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.
Carl Caum
2010-Feb-03 20:57 UTC
Re: [Puppet Users] Re: qualified variables inside of a node definition?
Oh, I apologize. After re-reading your original post I see you clearly stated that. You''ll have to use extlookup: http://blog.klavsen.info/content/extlookup-puppet-extension-you-cant-live-without You can make two calls to get the ipaddress, once in the classes and once in your node definition. Like I said, I''ve never used it but it others swear by it. On Feb 3, 2010, at 2:33 PM, John Lyman wrote:>> You could use stored configs and collect all the values for all the hosts on all the hosts. > > This won''t work in my case because I need the value from a host > *before* the host actually has puppet installed and running. > > -- > 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. >-- 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.
John Lyman
2010-Feb-04 02:38 UTC
[Puppet Users] Re: qualified variables inside of a node definition?
No need to apologize; thanks for the help. I''ll look into extlookup. -- 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.
Ohad Levy
2010-Feb-04 05:14 UTC
Re: [Puppet Users] qualified variables inside of a node definition?
Hi, After reading the thread, to me it sounds like a problem foreman can solve. Cheers, Ohad On 2/2/10, John Lyman <jlyman2@gmail.com> wrote:> I''m trying to figure out the best way to achieve the following... > > Inside of each node definition, I have variables for ip address, > default router, dns server, etc. I have a jumpstart module that has > several different file resources that use templates. In each > template, I would like to be able to use the values of the variables > in all nodes. > > For example: > node foo { ipaddress => 1.2.3.4 } > node bar { ipaddress => 5.6.7.8 } > > class jumpstart { > jumpstart_client = [ "foo", "bar" ] > file { "sysidcfg": > content => template("sysidcfg.erb") > } > } > > sysidcfg.erb: > <% jumpstart_client.each do |client| -%> > hostname=<%= client %> ip_address=<%= client::ipaddress %> > <% end -%> > > I don''t think the above is possible. What is the best way to > accomplish this (if any)? I think this is where exported resources > would come in to play, but in this case they will not work because I > want the info on the jumpstart server before puppet is even installed/ > run on the node. In other words, I want to define the node in puppet, > do a catalog run on the jumpstart server to update it''s config files > based on the new node definition, and then jumpstart the node (which > also installs puppet). > > 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. > >-- 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.