Tim Connors
2011-Feb-19 07:52 UTC
[Puppet Users] a rule being run every invocation despite no change
Hi all, I''m just a beginner with puppet (and perhaps foolishly, am implementing it a week before I leave this job - it''s only been on my TODO list for 2 years now). My puppetmaster is debian version 2.6.2-4. I''ve got a definition that has got me stumped as to its behaviour. #ensure hostname properly qualified in /etc/hosts (fqdn first, then #shortname second, then subsequent aliases). define hostentry($ip, $hostaliases = [], $ensure = present) { host { $name: ensure => absent, } host { "$name.aao.gov.au": ensure => $ensure, ip => $ip, host_aliases => [$name, $hostaliases], } } hostentry { "puppet": ip => "192.231.166.36", hostaliases => ["aatlxha.aao.gov.au", "aatlxha"], } If I expand that out so it reads host { "puppet": ensure => absent, } host { "puppet.aao.gov.au": ensure => present, ip => "192.231.166.36", host_aliases => ["puppet", "aatlxha.aao.gov.au", "aatlxha"], } then the hosts file only gets updated the once. But if I use the hostentry definition, then it gets every run. A clue perhaps is those hosts without a hostaliases: notice: /Stage[main]/Hosts/Hosts::Hostentry[aatlxc]/Host[aatlxc.aao.gov.au]/host_aliases: host_aliases changed ''aatlxc'' to ''aatlxc '' I''m creating a list from an item and a list, and a list with an empty item will just make for an excess space (which the hosts definition appears to later remove, or at least, there''s not an excess space in my file /etc/hosts file). The problem could be stemming from the fact that there are lists of lists there that get interpolated out, but I couldn''t work out a way to just concatenate the two lists together given the way variable scoping works. How would you tackle this? Is the output file atomically renamed into place? If it does needless updates every half an hour, but atomically renames it into place, we can live with that because it''s not a large network. But if it just writes it into place, then occasionally we''re going to try to read from a half-written file. -- Tim Connors -- 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.
Patrick
2011-Feb-19 09:23 UTC
Re: [Puppet Users] a rule being run every invocation despite no change
On Feb 18, 2011, at 11:52 PM, Tim Connors wrote:> If I expand that out so it reads > > host { "puppet": > ensure => absent, > } > host { "puppet.aao.gov.au": > ensure => present, > ip => "192.231.166.36", > host_aliases => ["puppet", "aatlxha.aao.gov.au", "aatlxha"], > } > > then the hosts file only gets updated the once. But if I use the > hostentry definition, then it gets every run.My understanding is that it would be expanded to this: host { "puppet": ensure => absent, } host { "puppet.aao.gov.au": ensure => present, ip => "192.231.166.36", host_aliases => ["puppet", ["aatlxha.aao.gov.au", "aatlxha"] ], } Try putting that in a test manifest and see what happens. If that doesn''t compile, try this instead $hostaliases = ["aatlxha.aao.gov.au", "aatlxha"] host { "puppet": ensure => absent, } host { "puppet.aao.gov.au": ensure => present, ip => "192.231.166.36", host_aliases => ["puppet", $hostaliases ], } If so, you probably need to change the syntax in your define. I''m hoping there''s a syntax that tells puppet to join 2 arrays.> A clue perhaps is those hosts without a hostaliases: > > notice: > /Stage[main]/Hosts/Hosts::Hostentry[aatlxc]/Host[aatlxc.aao.gov.au]/host_aliases: > host_aliases changed ''aatlxc'' to ''aatlxc ''Sounds like a minor bug to me. I''d try to see if putting a space at the end of an alias is allowed, but reproduces this. If so, I''d file a bug so it at least gives a warning. -- 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.
Felix Frank
2011-Feb-21 13:55 UTC
Re: [Puppet Users] a rule being run every invocation despite no change
On 02/19/2011 10:23 AM, Patrick wrote:> > On Feb 18, 2011, at 11:52 PM, Tim Connors wrote: >> If I expand that out so it reads >> >> host { "puppet": >> ensure => absent, >> } >> host { "puppet.aao.gov.au": >> ensure => present, >> ip => "192.231.166.36", >> host_aliases => ["puppet", "aatlxha.aao.gov.au", "aatlxha"], >> } >> >> then the hosts file only gets updated the once. But if I use the >> hostentry definition, then it gets every run. > > My understanding is that it would be expanded to this: > > host { "puppet": > ensure => absent, > } > host { "puppet.aao.gov.au": > ensure => present, > ip => "192.231.166.36", > host_aliases => ["puppet", ["aatlxha.aao.gov.au", "aatlxha"] ], > } > > Try putting that in a test manifest and see what happens. If that doesn''t compile, try this instead > $hostaliases = ["aatlxha.aao.gov.au", "aatlxha"] > host { "puppet": > ensure => absent, > } > host { "puppet.aao.gov.au": > ensure => present, > ip => "192.231.166.36", > host_aliases => ["puppet", $hostaliases ], > } > > > If so, you probably need to change the syntax in your define. I''m hoping there''s a syntax that tells puppet to join 2 arrays.If the provider in question fails to flatten the array properly, you''re in trouble (this is true for the groups parameter of the user provider, for 0.25.5 at least). This is interesting and helpful: http://weblog.etherized.com/posts/175 Cheers, Felix -- 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.
Tim Connors
2011-Feb-22 11:56 UTC
Re: [Puppet Users] a rule being run every invocation despite no change
On Mon, 21 Feb 2011, Felix Frank wrote:> > > On 02/19/2011 10:23 AM, Patrick wrote: > > If so, you probably need to change the syntax in your define. I''m hoping there''s a syntax that tells puppet to join 2 arrays. > > If the provider in question fails to flatten the array properly, you''re > in trouble (this is true for the groups parameter of the user provider, > for 0.25.5 at least). > > This is interesting and helpful: > http://weblog.etherized.com/posts/175Yeah, was trying originally to work out how to apply that. I don''t know whether this is the prettiest, but it works: define append_aliases($other_aliases) { $host_aliases += $other_aliases host { "$name.aao.gov.au": ensure => $ensure, ip => $ip, host_aliases => $host_aliases, } } define hostentry($ip, $hostaliases = [], $ensure = present) { host { $name: ensure => absent, } $host_aliases = [ $name ] append_aliases { $name: other_aliases => $hostaliases, } } My original struggle was in working out how to initialise $host_aliases in the caller to just $name, then appending the rest of the aliases. Doing it the other way around was easy - I was just struggling with the syntax and scoping. I would have liked to be able to reuse the parameter name $host_aliases, but far too much juggling to get it around in the right order to have host_aliases appended back onto something that ends up being called host_aliases again. -- Tim Connors -- 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.