I trying to get puppet to add an entry to /etc/hosts, but I can''t get it to work. I have a class file host.pp with the following content: class host { host { "${fqdn}": ensure => present, ip => $ipaddress, alias => ["$fqdn", "$hostname"] } } Is this the correct usage? Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
swygue wrote:> I trying to get puppet to add an entry to /etc/hosts, but I can''t get > it to work. I have a class file host.pp with the following content: > > class host { > host { "${fqdn}": > ensure => present, > ip => $ipaddress, > alias => ["$fqdn", "$hostname"] > } > } > > Is this the correct usage?yes, but you have to "include host" somewhere in the node. Regards, DavidS --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 02/09/2009, at 5:43 PM, David Schmitt wrote:>> alias => ["$fqdn", "$hostname"] >> yes, but you have to "include host" somewhere in the node.Also, don''t put the $fqdn into the alias field. It is automatically added by the host provider. You just need the $hostname. cYa, Avi --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
A question: I want to make a class to delete all lines (if any) in /etc/hosts and add this two new lines: class hosts { host { "$hostname": ensure => present, ip => "$ipaddress", alias => ["$hostname"], name => ["$fqdn"], } host { "localhost": ensure => present, ip => "127.0.0.1", name => ["localhost"], alias => ["localhost.localdomain"], } } What do I need to add my class to delete all lines of every server and add ONLY this two hosts above? regards, Israel. On Sep 2, 2:48 am, Avi Miller <avi.mil...@gmail.com> wrote:> On 02/09/2009, at 5:43 PM, David Schmitt wrote: > > >> alias => ["$fqdn", "$hostname"] > > > yes, but you have to "include host" somewhere in the node. > > Also, don''t put the $fqdn into the alias field. It is automatically > added by the host provider. You just need the $hostname. > > cYa, > Avi--~--~---------~--~----~------------~-------~--~----~ 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'd want to change your idea into a file resource with the content parameter set to a template. In the template you can access the variables to set up that line properly. Of course if you need to add more hosts to a system it will be sort of a pita. Sent from my Verizon Wireless BlackBerry -----Original Message----- From: ELTigre <igalvarez@gmail.com> Date: Wed, 2 Sep 2009 18:42:37 To: Puppet Users<puppet-users@googlegroups.com> Subject: [Puppet Users] Re: Host type usage A question: I want to make a class to delete all lines (if any) in /etc/hosts and add this two new lines: class hosts { host { "$hostname": ensure => present, ip => "$ipaddress", alias => ["$hostname"], name => ["$fqdn"], } host { "localhost": ensure => present, ip => "127.0.0.1", name => ["localhost"], alias => ["localhost.localdomain"], } } What do I need to add my class to delete all lines of every server and add ONLY this two hosts above? regards, Israel. On Sep 2, 2:48 am, Avi Miller <avi.mil...@gmail.com> wrote:> On 02/09/2009, at 5:43 PM, David Schmitt wrote: > > >> alias => ["$fqdn", "$hostname"] > > > yes, but you have to "include host" somewhere in the node. > > Also, don't put the $fqdn into the alias field. It is automatically > added by the host provider. You just need the $hostname. > > cYa, > Avi--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Umm...thanks joseph, but I see things begins to complicate because I don''t know how to make this template :-( I though I''d resolve my problem with some resources. regards, Israel. On Sep 2, 8:50 pm, joseph.e.mcdon...@gmail.com wrote:> You''d want to change your idea into a file resource with the content parameter set to a template. In the template you can access the variables to set up that line properly. Of course if you need to add more hosts to a system it will be sort of a pita. > Sent from my Verizon Wireless BlackBerry > > -----Original Message----- > From: ELTigre <igalva...@gmail.com> > > Date: Wed, 2 Sep 2009 18:42:37 > To: Puppet Users<puppet-users@googlegroups.com> > Subject: [Puppet Users] Re: Host type usage > > A question: > > I want to make a class to delete all lines (if any) in /etc/hosts and > add this two new lines: > > class hosts { > > host { "$hostname": > ensure => present, > ip => "$ipaddress", > alias => ["$hostname"], > name => ["$fqdn"], > } > host { "localhost": > ensure => present, > ip => "127.0.0.1", > name => ["localhost"], > alias => ["localhost.localdomain"], > } > } > > What do I need to add my class to delete all lines of every server and > add ONLY this two hosts above? > > regards, > Israel. > On Sep 2, 2:48 am, Avi Miller <avi.mil...@gmail.com> wrote: > > On 02/09/2009, at 5:43 PM, David Schmitt wrote: > > > >> alias => ["$fqdn", "$hostname"] > > > > yes, but you have to "include host" somewhere in the node. > > > Also, don''t put the $fqdn into the alias field. It is automatically > > added by the host provider. You just need the $hostname. > > > cYa, > > Avi--~--~---------~--~----~------------~-------~--~----~ 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 can use: resources{host: purge => true} HOWEVER! this will delete any non manged resource in your /etc/hosts! handle with care. Ohad On Thu, Sep 3, 2009 at 10:07 AM, ELTigre <igalvarez@gmail.com> wrote:> > Umm...thanks joseph, but I see things begins to complicate because I > don''t know how to make this template :-( > I though I''d resolve my problem with some resources. > > regards, > Israel. > > On Sep 2, 8:50 pm, joseph.e.mcdon...@gmail.com wrote: > > You''d want to change your idea into a file resource with the content > parameter set to a template. In the template you can access the variables to > set up that line properly. Of course if you need to add more hosts to a > system it will be sort of a pita. > > Sent from my Verizon Wireless BlackBerry > > > > -----Original Message----- > > From: ELTigre <igalva...@gmail.com> > > > > Date: Wed, 2 Sep 2009 18:42:37 > > To: Puppet Users<puppet-users@googlegroups.com> > > Subject: [Puppet Users] Re: Host type usage > > > > A question: > > > > I want to make a class to delete all lines (if any) in /etc/hosts and > > add this two new lines: > > > > class hosts { > > > > host { "$hostname": > > ensure => present, > > ip => "$ipaddress", > > alias => ["$hostname"], > > name => ["$fqdn"], > > } > > host { "localhost": > > ensure => present, > > ip => "127.0.0.1", > > name => ["localhost"], > > alias => ["localhost.localdomain"], > > } > > } > > > > What do I need to add my class to delete all lines of every server and > > add ONLY this two hosts above? > > > > regards, > > Israel. > > On Sep 2, 2:48 am, Avi Miller <avi.mil...@gmail.com> wrote: > > > On 02/09/2009, at 5:43 PM, David Schmitt wrote: > > > > > >> alias => ["$fqdn", "$hostname"] > > > > > > yes, but you have to "include host" somewhere in the node. > > > > > Also, don''t put the $fqdn into the alias field. It is automatically > > > added by the host provider. You just need the $hostname. > > > > > cYa, > > > Avi > > >--~--~---------~--~----~------------~-------~--~----~ 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 Ohad, and thanks for your soon answer.. Umm, I did''nt know purge can be used in hosts resource... is purge a global parameter others resources can use? So, in my configuration do I have to put 3 purge => true in my 2 entries? class hosts { host { "$hostname": ensure => present, purge => true, ip => "$ipaddress", alias => ["$hostname"], name => ["$fqdn"], } host { "localhost": ensure => present, purge => true, ip => "127.0.0.1", name => ["localhost"], alias => ["localhost.localdomain"], } } Or should I have to set a Host: { purge => true} at top level default.pp file? regards, Israel On Sep 2, 9:26 pm, Ohad Levy <ohadl...@gmail.com> wrote:> You can use: > resources{host: purge => true} > > HOWEVER! this will delete any non manged resource in your /etc/hosts! handle > with care. > > Ohad > > On Thu, Sep 3, 2009 at 10:07 AM, ELTigre <igalva...@gmail.com> wrote: > > > Umm...thanks joseph, but I see things begins to complicate because I > > don''t know how to make this template :-( > > I though I''d resolve my problem with some resources. > > > regards, > > Israel. > > > On Sep 2, 8:50 pm, joseph.e.mcdon...@gmail.com wrote: > > > You''d want to change your idea into a file resource with the content > > parameter set to a template. In the template you can access the variables to > > set up that line properly. Of course if you need to add more hosts to a > > system it will be sort of a pita. > > > Sent from my Verizon Wireless BlackBerry > > > > -----Original Message----- > > > From: ELTigre <igalva...@gmail.com> > > > > Date: Wed, 2 Sep 2009 18:42:37 > > > To: Puppet Users<puppet-users@googlegroups.com> > > > Subject: [Puppet Users] Re: Host type usage > > > > A question: > > > > I want to make a class to delete all lines (if any) in /etc/hosts and > > > add this two new lines: > > > > class hosts { > > > > host { "$hostname": > > > ensure => present, > > > ip => "$ipaddress", > > > alias => ["$hostname"], > > > name => ["$fqdn"], > > > } > > > host { "localhost": > > > ensure => present, > > > ip => "127.0.0.1", > > > name => ["localhost"], > > > alias => ["localhost.localdomain"], > > > } > > > } > > > > What do I need to add my class to delete all lines of every server and > > > add ONLY this two hosts above? > > > > regards, > > > Israel. > > > On Sep 2, 2:48 am, Avi Miller <avi.mil...@gmail.com> wrote: > > > > On 02/09/2009, at 5:43 PM, David Schmitt wrote: > > > > > >> alias => ["$fqdn", "$hostname"] > > > > > > yes, but you have to "include host" somewhere in the node. > > > > > Also, don''t put the $fqdn into the alias field. It is automatically > > > > added by the host provider. You just need the $hostname. > > > > > cYa, > > > > Avi--~--~---------~--~----~------------~-------~--~----~ 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 cant use purge in the host type it self (its not support) you can tell puppet to purge all non managed host(or cron or any other supported resource) entries, by the line I provided before. in general you need to put it somewhere in your manifest, I would put it in the same place I define my hosts,but YMMV. Ohad On Thu, Sep 3, 2009 at 10:55 AM, ELTigre <igalvarez@gmail.com> wrote:> > :-) Hi Ohad, and thanks for your soon answer.. > > Umm, I did''nt know purge can be used in hosts resource... is purge a > global parameter others resources can use? > > So, in my configuration do I have to put 3 purge => true in my 2 > entries? > > class hosts { > > host { "$hostname": > ensure => present, > purge => true, > ip => "$ipaddress", > alias => ["$hostname"], > name => ["$fqdn"], > } > host { "localhost": > ensure => present, > purge => true, > ip => "127.0.0.1", > name => ["localhost"], > alias => ["localhost.localdomain"], > } > > } > > Or should I have to set a Host: { purge => true} at top level > default.pp file? > > regards, > Israel > > On Sep 2, 9:26 pm, Ohad Levy <ohadl...@gmail.com> wrote: > > You can use: > > resources{host: purge => true} > > > > HOWEVER! this will delete any non manged resource in your /etc/hosts! > handle > > with care. > > > > Ohad > > > > On Thu, Sep 3, 2009 at 10:07 AM, ELTigre <igalva...@gmail.com> wrote: > > > > > Umm...thanks joseph, but I see things begins to complicate because I > > > don''t know how to make this template :-( > > > I though I''d resolve my problem with some resources. > > > > > regards, > > > Israel. > > > > > On Sep 2, 8:50 pm, joseph.e.mcdon...@gmail.com wrote: > > > > You''d want to change your idea into a file resource with the content > > > parameter set to a template. In the template you can access the > variables to > > > set up that line properly. Of course if you need to add more hosts to a > > > system it will be sort of a pita. > > > > Sent from my Verizon Wireless BlackBerry > > > > > > -----Original Message----- > > > > From: ELTigre <igalva...@gmail.com> > > > > > > Date: Wed, 2 Sep 2009 18:42:37 > > > > To: Puppet Users<puppet-users@googlegroups.com> > > > > Subject: [Puppet Users] Re: Host type usage > > > > > > A question: > > > > > > I want to make a class to delete all lines (if any) in /etc/hosts and > > > > add this two new lines: > > > > > > class hosts { > > > > > > host { "$hostname": > > > > ensure => present, > > > > ip => "$ipaddress", > > > > alias => ["$hostname"], > > > > name => ["$fqdn"], > > > > } > > > > host { "localhost": > > > > ensure => present, > > > > ip => "127.0.0.1", > > > > name => ["localhost"], > > > > alias => ["localhost.localdomain"], > > > > } > > > > } > > > > > > What do I need to add my class to delete all lines of every server > and > > > > add ONLY this two hosts above? > > > > > > regards, > > > > Israel. > > > > On Sep 2, 2:48 am, Avi Miller <avi.mil...@gmail.com> wrote: > > > > > On 02/09/2009, at 5:43 PM, David Schmitt wrote: > > > > > > > >> alias => ["$fqdn", "$hostname"] > > > > > > > > yes, but you have to "include host" somewhere in the node. > > > > > > > Also, don''t put the $fqdn into the alias field. It is automatically > > > > > added by the host provider. You just need the $hostname. > > > > > > > cYa, > > > > > Avi > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---