lib/octofacts/backends/index.rb
# If a select/reject/prefer is called and the fact is not in the index, this will
# load the fact files for all currently eligible nodes and then add the fact to the
# in-memory index. This can be memory-intensive and time-intensive depending on the
# number of fact fixtures, so it is possible to disable this by passing
# `:strict_index => true` to the backend constructor, or by setting
# ENV["OCTOFACTS_STRICT_INDEX"] = "true" in the environment.
If a select/reject/prefer is called and the fact is not in the index, this will
load the fact files for all currently eligible nodes and then add the fact to the
in-memory index. This can be memory-intensive and time-intensive depending on the
number of fact fixtures, so it is possible to disable this by passing
`:strict_index => true` to the backend constructor, or by setting
ENV["OCTOFACTS_STRICT_INDEX"] = "true" in the environment.
If a select / reject / prefer is called and the fact is not in the index this will load the fact files for all currently eligible nodes and then add the fact to the in - memory index . This can be memory - intensive and time - intensive depending on the number of fact fixtures so it is possible to disable this by passing ` : strict_index = > true ` to the backend constructor or by setting ENV [ " OCTOFACTS_STRICT_INDEX " ] = " true " in the environment .
def add_fact_to_index(fact)
        if @strict_index || ENV["OCTOFACTS_STRICT_INDEX"] == "true"
          raise Octofacts::Errors::FactNotIndexed, "Fact #{fact} is not indexed and strict indexing is enabled."
        end
        index[fact] ||= {}
        nodes.each do |node|
          v = node_facts(node)[fact]
          if v.nil?
          else
            index[fact][v.to_s] ||= []
            index[fact][v.to_s] << node
          end
        end
      end
def add_fact_to_index ( fact ) if @strict_index || ENV [ "OCTOFACTS_STRICT_INDEX" ] == "true" raise Octofacts :: Errors :: FactNotIndexed , "Fact #{fact} is not indexed and strict indexing is enabled." end index [ fact ] ||= { } nodes . each do | node | v = node_facts ( node ) [ fact ] if v . nil? else index [ fact ] [ v . to_s ] ||= [ ] index [ fact ] [ v . to_s ] << node end end end
If a select/reject/prefer is called and the fact is not in the index, this will
load the fact files for all currently eligible nodes and then add the fact to the
in-memory index.
If a select / reject / prefer is called and the fact is not in the index this will load the fact files for all currently eligible nodes and then add the fact to the in - memory index .
# TODO: Index this somehow
fact
<not_specific>