2 Jul 2007 22:06
Re: [Puppet-dev] export/collect defined types OR collection based on tag matching OR ... ??
Thijs Oppermann <thijso+puppet <at> gmail.com>
2007-07-02 20:06:13 GMT
2007-07-02 20:06:13 GMT
On 02/07/07, Luke Kanies <luke <at> madstop.com> wrote:
On Jul 1, 2007, at 8:54 AM, Thijs Oppermann wrote:
>
> I started with looking at this, and I'm a bit confused why it
> hasn't been implemented yet. As far as I can see it's easily
> added with the following changes to the current svn code:
>
> --- a/lib/puppet/parser/ast/collexpr.rb
> +++ b/lib/puppet/parser/ast/collexpr.rb
> <at> <at> -54,17 +54,18 <at> <at> class CollExpr < AST::Branch
> if str1 == "title"
> str = "title #{oper} '#{str2}'"
> else
> - unless self.form == :virtual or str1 == "title"
> - parsefail "Collection from the database only
> supports " +
> - "title matching currently"
> - end
> str = "rails_parameters.name = '#{str1}' and " +
> "rails_parameters.value #{oper} '#{str2}'"
> end
> else
> str = [str1, oper, str2].join(" ")
> end
This was written when the db schema was completely different. There
isn't even a rails_parameters table any more, so I can't imagine this
is actually working.
That being said, it should not be much more complicated than you make
out.
> and:
> --- a/lib/puppet/parser/collector.rb
> +++ b/lib/puppet/parser/collector.rb
> <at> <at> -36,9 +36,23 <at> <at> class Puppet::Parser::Collector
>
> Puppet::Rails::Resource.find_all_by_restype_and_exported( <at> type, true,
> args
> ).each do |obj|
> if resource = export_resource(obj)
> - count += 1
> - resources << resource
> + if match?(resource)
> + count += 1
> + resources << resource
> + end
> end
> end
> end
>
>
> Or am I missing something obvious here? I tested this and it seems
> to work.
Are you sure it's not collecting everything?
Yup. With the following configs:
on node tiga:
path => "/tmp/test-exported-file-tiga",
ensure => file,
}
<at> <at> file { "iptfw-apache2scriptlet-kidstardust":
path => "/etc/network/firewall.d/Sfw85kidstardust",
ensure => file,
...
tag => "iptablesfw-scriptlet",
}
if I then use the following on node sandbox:
File <<| tag == "iptablesfw-scriptlet" |>>
I get:
notice: //systembase/serverbase/sandbox/File[iptfw-apache2scriptlet-kidstardust]/content: created file with contents ...
and the file /tmp/test-exported-file-tiga doesn't exist after the puppet run.
If I do:
File <<||>>
I also get:
notice: //systembase/serverbase/sandbox/File[test-exported-file-tiga]/ensure: created
and the file does exist.
So, yeah, it is doing what I want and expect it to do with the the changes to the code as detailed above...
gr,
Thijs
We're probably also going to want to change our query so that it only
returns resources that match our query. That is, it should be
possible to do the query in a single SELECT statement, rather than
using matching.
>
> Duh! Completely missed the param_values and param_names tables in
> the db...
Guess I should have reread the thread before responding...
--
In theory, there is no difference between theory and practice; In
practice, there is. -- Chuck Reid
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com
_______________________________________________
Puppet-dev mailing list
Puppet-dev <at> madstop.com
https://mail.madstop.com/mailman/listinfo/puppet-dev
_______________________________________________ Puppet-dev mailing list Puppet-dev <at> madstop.com https://mail.madstop.com/mailman/listinfo/puppet-dev
RSS Feed