diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-13 04:52:34 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-13 04:52:34 +0000 |
| commit | 5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6 (patch) | |
| tree | 7d6cadbf16f19cab8d3c89db3a4b95161241c88b /lib/puppet/parser | |
| parent | 0819e35be74bc997c3a953f05bab874b8d76429d (diff) | |
| download | puppet-5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6.tar.gz puppet-5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6.tar.xz puppet-5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6.zip | |
Adding initial rails support. One can now store host configurations using ActiveRecord into a database (I have only tested sqlite3). Tomorrow will be the grammars used to retrieve those records for object collection.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1187 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser')
| -rw-r--r-- | lib/puppet/parser/interpreter.rb | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index ee89433f3..a11e870ab 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -38,6 +38,12 @@ module Puppet branch under your main directory."] ) + Puppet.setdefaults(:puppetmaster, + :storeconfigs => [false, + "Whether to store each client's configuration. This + requires ActiveRecord from Ruby on Rails."] + ) + attr_accessor :ast, :filetimeout # just shorten the constant path a bit, using what amounts to an alias AST = Puppet::Parser::AST @@ -220,7 +226,7 @@ module Puppet end begin - return scope.evaluate(args) + objects = scope.evaluate(args) rescue Puppet::DevError, Puppet::Error, Puppet::ParseError => except raise rescue => except @@ -232,6 +238,24 @@ module Puppet #end raise error end + + if Puppet[:storeconfigs] + unless defined? ActiveRecord + require 'puppet/rails' + unless defined? ActiveRecord + raise LoadError, + "storeconfigs is enabled but rails is unavailable" + end + Puppet::Rails.init + end + Puppet::Rails::Host.store( + :objects => objects, + :host => client, + :facts => facts + ) + end + + return objects end def scope @@ -240,25 +264,6 @@ module Puppet private - # Evaluate the configuration. If there aren't any nodes defined, then - # this doesn't actually do anything, because we have to evaluate the - # entire configuration each time we get a connect. - def evaluate - # FIXME When this produces errors, it should specify which - # node caused those errors. - if @usenodes - @scope = Puppet::Parser::Scope.new() # no parent scope - @scope.name = "top" - @scope.type = "puppet" - @scope.interp = self - Puppet.debug "Nodes defined" - @ast.safeevaluate(:scope => @scope) - else - Puppet.debug "No nodes defined" - return - end - end - def parsefiles if @file if defined? @parser @@ -305,10 +310,6 @@ module Puppet # Mark when we parsed, so we can check freshness @parsedate = Time.now.to_i @lastchecked = Time.now - - # Reevaluate the config. This is what actually replaces the - # existing scope. - evaluate end end end |
