Hi, I''m trying to create a host entry and want puppet to remove the alias if is exists for that host in the host file. If alias is not set aliases are left as they are for that host. If alias is set to undef aliases are left as they are. If alias is set to '''' is constantly changes the host file on each run. Is ther a way of achieving this? Thanks Peter -- 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.
ensure => absent On Thu, Jan 14, 2010 at 3:11 PM, Peter <peter@netremedies.ca> wrote:> Hi, > > I''m trying to create a host entry and want puppet to remove the alias > if is exists for that host in the host file. > > If alias is not set aliases are left as they are for that host. > > If alias is set to undef aliases are left as they are. > > If alias is set to '''' is constantly changes the host file on each run. > > Is ther a way of achieving this? > > Thanks > > Peter > > -- > 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<puppet-users%2Bunsubscribe@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.
I have host { "hosts buildserver" : ip => "192.168.1.1" name => "buildserver", ensure => present, } so how do I ensure aliases are absent host { "hosts buildserver" : ip => "192.168.1.1", name => "buildserver", ensure => present, alias => ensure => absent, } That doesn''t seem to make sense and I get Jan 14 01:22:04 buildserver puppetd[1212]: [ID 702911 daemon.error] Could not retrieve catalog from remote server: Error 400 on SERVER: Could not parse for environment production: Syntax error at ''=>''; expected ''}'' at /etc/puppet/manifests/nodes.pp:113 Perhaps I wasn''t clear with my question I meant the alias for the host (the host type). Or do I just have the syntax wrong. I have tried alias => undef, alias => '''', alias => [], alias => [undef], alias =>[undef], none of which seem to remove the alias if it is already in the host file and do this only once not every time puppetd runs. Thanks Peter On Jan 14, 12:15 am, Ohad Levy <ohadl...@gmail.com> wrote:> ensure => absent > > On Thu, Jan 14, 2010 at 3:11 PM, Peter <pe...@netremedies.ca> wrote: > > Hi, > > > I''m trying to create a host entry and want puppet to remove the alias > > if is exists for that host in the host file. > > > If alias is not set aliases are left as they are for that host. > > > If alias is set to undef aliases are left as they are. > > > If alias is set to '''' is constantly changes the host file on each run. > > > Is ther a way of achieving this? > > > Thanks > > > Peter > > > -- > > 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<puppet-users%2Bunsubscribe@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.
Silviu Paragina
2010-Jan-14 10:17 UTC
Re: [Puppet Users] Re: How to ensure a host has no aliases
So for your example you would want to remove all host entries that point to 192.168.1.1 except the buildserver host entry? Or you want the buildserver host entry to be removed? Or you want to replace whatever host entry buildserver has, with 192.168.1.1? Peter wrote:> I have > > host { "hosts buildserver" : > > ip => "192.168.1.1" > > name => "buildserver", > > ensure => present, > > } > > > so how do I ensure aliases are absent > > host { "hosts buildserver" : > > ip => "192.168.1.1", > > name => "buildserver", > > ensure => present, > > alias => ensure => absent, > } >I think Ohad meant: host { "hosts buildserver" : ip => "192.168.1.1", name => "buildserver", ensure => absent, } but I''m not sure that''s what you want..> > That doesn''t seem to make sense and I get > > Jan 14 01:22:04 buildserver puppetd[1212]: [ID 702911 daemon.error] > Could not retrieve catalog from remote server: Error 400 on SERVER: > Could not parse for environment production: Syntax error at ''=>''; > expected ''}'' at /etc/puppet/manifests/nodes.pp:113 > > > Perhaps I wasn''t clear with my question I meant the alias for the host > (the host type). > > Or do I just have the syntax wrong. > > I have tried > > alias => undef, > alias => '''', > alias => [], > alias => [undef], > alias =>[undef], > > none of which seem to remove the alias if it is already in the host > file and do this only once not every time puppetd runs. > > Thanks > > Peter > > >Silviu -- 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.
Trevor Vaughan
2010-Jan-14 10:50 UTC
Re: [Puppet Users] How to ensure a host has no aliases
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Instead of using '''', try adding a space in there, '' ''. I haven''t tried this, but it should work. Trevor On 01/14/2010 02:11 AM, Peter wrote:> Hi, > > I''m trying to create a host entry and want puppet to remove the alias > if is exists for that host in the host file. > > If alias is not set aliases are left as they are for that host. > > If alias is set to undef aliases are left as they are. > > If alias is set to '''' is constantly changes the host file on each run. > > Is ther a way of achieving this? > > Thanks > > Peter >- -- Trevor Vaughan Vice President, Onyx Point, Inc. email: tvaughan@onyxpoint.com phone: 410-541-ONYX (6699) - -- This account not approved for unencrypted sensitive information -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAktO9tgACgkQyWMIJmxwHpSYnQCffYt2b35K7C5/Ni6us0KgJjtX uNkAmgILcFm+4NtG8doT3JDk5+Wqj4A5 =/ecE -----END PGP SIGNATURE----- -- 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.
I guess I was wrong, looking at the code I dont think that you can remove an alias, just replace it to something else. funny, if you put the word absent as an alias, puppet think there is no alias. sounds like a bug to me as the absent key word is translated into absent alias value. On Thu, Jan 14, 2010 at 4:15 PM, Ohad Levy <ohadlevy@gmail.com> wrote:> ensure => absent > > On Thu, Jan 14, 2010 at 3:11 PM, Peter <peter@netremedies.ca> wrote: > >> Hi, >> >> I''m trying to create a host entry and want puppet to remove the alias >> if is exists for that host in the host file. >> >> If alias is not set aliases are left as they are for that host. >> >> If alias is set to undef aliases are left as they are. >> >> If alias is set to '''' is constantly changes the host file on each run. >> >> Is ther a way of achieving this? >> >> Thanks >> >> Peter >> >> -- >> 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<puppet-users%2Bunsubscribe@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.
Its all a bit weird. an empty string does what I want but it then changes the host file and spits out its changing absent to absent. a space gives Jan 14 03:48:04 buildsun4u puppetd[12213]: [ID 702911 daemon.error] Could not run Puppet configuration client: Parameter alias failed: Aliases cannot include whitespace looks like it bails after that Also if there are two nodes with the same canonical name puppet will make the ips the same but does not delete the second entry so you are left with 2 lines with the same IP address. When you update the alias it only changes one of the lines. I have purging enabled with resources { "hosts purge": name => host, purge => true, } What I''m trying to achieve is if I declare a host it is set exactly like that and any other entries are removed from the host file including any unspecified nodes, any aliases that are not specified (I can''t get this to work if there are no aliases to specify) and any duplicates (they are not removed or there aliases amended). So if I have the following resources resources { "hosts purge": name => host, purge => true, } host { "hosts localhost" : ip => "127.0.0.1", name => "localhost", ensure => present, } if $hostname == "buildserver" { host { "hosts buildserver" : ip => "192.168.1.1", name => "buildserver", ensure => present, alias => '''', } } if $hostname == "buildsun4u" { host { "hosts buildsun4u" : ip => "192.168.1.2", name => "buildsun4u", ensure => present, alias => '''', } } host { "hosts directory" : ip => "192.168.1.3", name => "directory.mydomain", ensure => present, } If the host file starts out # Internet host table # ::1 localhost 192.168.1.3 directory.mydomain 127.0.0.1 localhost 192.168.1.1 buildserver myalias 192.168.1.99 buildserver 192.168.1.100 splot I would like to get # Internet host table # ::1 localhost 192.168.1.3 directory.mydomain 127.0.0.1 localhost 192.168.1.1 buildserver instead of # Internet host table # ::1 localhost 192.168.1.3 directory.mydomain 127.0.0.1 localhost 192.168.1.1 buildserver myalias 192.168.1.1 buildserver Thanks Peter On Jan 14, 2:54 am, Ohad Levy <ohadl...@gmail.com> wrote:> I guess I was wrong, looking at the code I dont think that you can remove an > alias, just replace it to something else. > > funny, if you put the word absent as an alias, puppet think there is no > alias. > > sounds like a bug to me as the absent key word is translated into absent > alias value. > > On Thu, Jan 14, 2010 at 4:15 PM, Ohad Levy <ohadl...@gmail.com> wrote: > > ensure => absent > > > On Thu, Jan 14, 2010 at 3:11 PM, Peter <pe...@netremedies.ca> wrote: > > >> Hi, > > >> I''m trying to create a host entry and want puppet to remove the alias > >> if is exists for that host in the host file. > > >> If alias is not set aliases are left as they are for that host. > > >> If alias is set to undef aliases are left as they are. > > >> If alias is set to '''' is constantly changes the host file on each run. > > >> Is ther a way of achieving this? > > >> Thanks > > >> Peter > > >> -- > >> 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<puppet-users%2Bunsubscribe@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.
Ohad Levy
2010-Jan-14 12:17 UTC
Re: [Puppet Users] Re: How to ensure a host has no aliases
I guess your options are a template or augeas. Please fill in an issue in redmine. cheers, Ohad On Thu, Jan 14, 2010 at 8:11 PM, Peter <peter@netremedies.ca> wrote:> Its all a bit weird. > > an empty string does what I want but it then changes the host file and > spits out its changing absent to absent. > > a space gives > Jan 14 03:48:04 buildsun4u puppetd[12213]: [ID 702911 daemon.error] > Could not run Puppet configuration client: Parameter alias failed: > Aliases cannot include whitespace > looks like it bails after that > > Also if there are two nodes with the same canonical name puppet will > make the ips the same but does not delete the second entry so you are > left with 2 lines with the same IP address. > > When you update the alias it only changes one of the lines. > > I have purging enabled with > resources { "hosts purge": > > name => host, > > purge => true, > > } > > > What I''m trying to achieve is if I declare a host it is set exactly > like that and any other entries are removed from the host file > including any unspecified nodes, any aliases that are not specified (I > can''t get this to work if there are no aliases to specify) and any > duplicates (they are not removed or there aliases amended). > > So if I have the following resources > resources { "hosts purge": > > name => host, > > purge => true, > > } > > host { "hosts localhost" : > > ip => "127.0.0.1", > > name => "localhost", > > ensure => present, > > } > > if $hostname == "buildserver" { > > host { "hosts buildserver" : > > ip => "192.168.1.1", > > name => "buildserver", > > ensure => present, > > alias => '''', > > } > > } > > if $hostname == "buildsun4u" { > > host { "hosts buildsun4u" : > > ip => "192.168.1.2", > > name => "buildsun4u", > > ensure => present, > > alias => '''', > > } > > } > > host { "hosts directory" : > > ip => "192.168.1.3", > > name => "directory.mydomain", > > ensure => present, > > } > > > If the host file starts out > > # Internet host table > > # > > ::1 localhost > > 192.168.1.3 directory.mydomain > 127.0.0.1 localhost > > 192.168.1.1 buildserver myalias > > 192.168.1.99 buildserver > 192.168.1.100 splot > > > I would like to get > > # Internet host table > # > ::1 localhost > 192.168.1.3 directory.mydomain > 127.0.0.1 localhost > 192.168.1.1 buildserver > > instead of > > # Internet host table > # > ::1 localhost > 192.168.1.3 directory.mydomain > 127.0.0.1 localhost > 192.168.1.1 buildserver myalias > 192.168.1.1 buildserver > > Thanks > > Peter > > On Jan 14, 2:54 am, Ohad Levy <ohadl...@gmail.com> wrote: > > I guess I was wrong, looking at the code I dont think that you can remove > an > > alias, just replace it to something else. > > > > funny, if you put the word absent as an alias, puppet think there is no > > alias. > > > > sounds like a bug to me as the absent key word is translated into absent > > alias value. > > > > On Thu, Jan 14, 2010 at 4:15 PM, Ohad Levy <ohadl...@gmail.com> wrote: > > > ensure => absent > > > > > On Thu, Jan 14, 2010 at 3:11 PM, Peter <pe...@netremedies.ca> wrote: > > > > >> Hi, > > > > >> I''m trying to create a host entry and want puppet to remove the alias > > >> if is exists for that host in the host file. > > > > >> If alias is not set aliases are left as they are for that host. > > > > >> If alias is set to undef aliases are left as they are. > > > > >> If alias is set to '''' is constantly changes the host file on each run. > > > > >> Is ther a way of achieving this? > > > > >> Thanks > > > > >> Peter > > > > >> -- > > >> 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<puppet-users%2Bunsubscribe@googlegroups.com> > <puppet-users%2Bunsubscribe@googlegroups.com<puppet-users%252Bunsubscribe@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<puppet-users%2Bunsubscribe@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.