On Jun 6, 7:34 am, Jiří Červenka <jiricerven...@gmail.com> wrote: > > The problem in this case is this declaration inside your "preseed" > > definition: > > > file { "/etc/dhcp/dhcpd.conf-$name": > > ... > > path => "/etc/dhcp/dhcpd.conf", > > ... > > } #file > > > Note that you are giving a literal path to a resource declared within > > a defined type. That would work if you only declared one instance of > > the defined type, but it creates a conflict if you declare more than > > one. > > > The solution looks easy in this case, because the problematic > > declaration doesn't really depend on its context (that should have > > been your first clue that it didn't belong there). Pull it out and > > make it a sibling of the preseed { ... } declaration block: > > > preseed { > > "node1": > > ... > > > } # preseed > > > file { "/etc/dhcp/dhcpd.conf": > > ... > > > } #file > > > John > > Hi, > unfortunately this doesnt work. In preseed {...} i declare variables > for each node, which are then used in file {"/etc/dhcp/dhcpd.conf":} > in template content => template("preseed/dhcpd.conf.erb"). > > If I make file {"/etc/dhcp/dhcpd.conf":} sibling of preseed {...}, > then variables from preseed are not available in template. > > I want to perform this. For each node I want to add one line into /etc/ > dhcp/dhcpd.conf : > ... > host n1 { hardware ethernet 78:e7:d1:24:5c:10; fixed-address > 192.168.1.1; } > host n2 { hardware ethernet 78:e7:d1:24:5c:11; fixed-address > 192.168.1.2; } > host nx { hardware ethernet 78:e7:d1:24:5c:1@; fixed-address > 192.168.1.x; }
That does not change the fact that you are declaring multiple instances of your 'preseed' defined type, but you want only one /etc/ dhcp/dhcpd.conf. You therefore cannot manage dhcpd.conf from the 'preseed' defintion. Even if you could obscure the multiple- management (as you tried to do by using different resource titles), the result would not be what you are looking for: some one of the declarations would end up winning, instead of all of them cooperating as you hoped they would do. You need to give your dhcpd.conf template all the data it needs at once (which means pulling it out of 'preseed', as I said), or else you need to use it differently. The former option probably requires you to load your node data into a more complex data structure, such as a hash (or array) of hashes, which the template would then process. The latter option probably involves using something like the Puppet::Concat module to build your dhcpd.conf file from multiple pieces, with each piece being a separate resource. John -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.