Sha256: 7f076497e502d1985a20551ddd099d1e24b7ff6c4eb23b6b68b5d7ebed38486b

Contents?: true

Size: 1.71 KB

Versions: 627

Compression:

Stored size: 1.71 KB

Contents

require 'puppet/confine_collection'

# The Confiner module contains methods for managing a Provider's confinement (suitability under given
# conditions). The intent is to include this module in an object where confinement management is wanted.
# It lazily adds an instance variable `@confine_collection` to the object where it is included.
#
module Puppet::Confiner
  # Confines a provider to be suitable only under the given conditions.
  # The hash describes a confine using mapping from symbols to values or predicate code.
  #
  # * _fact_name_ => value of fact (or array of facts)
  # * `:exists` => the path to an existing file
  # * `:true` => a predicate code block returning true
  # * `:false` => a predicate code block returning false
  # * `:feature` => name of system feature that must be present
  # * `:any` => an array of expressions that will be ORed together
  #
  # @example
  #   confine :operatingsystem => [:redhat, :fedora]
  #   confine :true { ... }
  #
  # @param hash [Hash<{Symbol => Object}>] hash of confines
  # @return [void]
  # @api public
  #
  def confine(hash)
    confine_collection.confine(hash)
  end

  # @return [Puppet::ConfineCollection] the collection of confines
  # @api private
  #
  def confine_collection
    @confine_collection ||= Puppet::ConfineCollection.new(self.to_s)
  end

  # Checks whether this implementation is suitable for the current platform (or returns a summary
  # of all confines if short == false).
  # @return [Boolean. Hash] Returns whether the confines are all valid (if short == true), or a hash of all confines
  #   if short == false.
  # @api public
  #
  def suitable?(short = true)
    return(short ? confine_collection.valid? : confine_collection.summary)
  end
end

Version data entries

627 entries across 627 versions & 3 rubygems

Version Path
puppet-6.29.0 lib/puppet/confiner.rb
puppet-6.29.0-x86-mingw32 lib/puppet/confiner.rb
puppet-6.29.0-x64-mingw32 lib/puppet/confiner.rb
puppet-6.29.0-universal-darwin lib/puppet/confiner.rb
puppet-6.28.0 lib/puppet/confiner.rb
puppet-6.28.0-x86-mingw32 lib/puppet/confiner.rb
puppet-6.28.0-x64-mingw32 lib/puppet/confiner.rb
puppet-6.28.0-universal-darwin lib/puppet/confiner.rb
puppet-6.27.0 lib/puppet/confiner.rb
puppet-6.27.0-x86-mingw32 lib/puppet/confiner.rb
puppet-6.27.0-x64-mingw32 lib/puppet/confiner.rb
puppet-6.27.0-universal-darwin lib/puppet/confiner.rb
puppet-6.26.0 lib/puppet/confiner.rb
puppet-6.26.0-x86-mingw32 lib/puppet/confiner.rb
puppet-6.26.0-x64-mingw32 lib/puppet/confiner.rb
puppet-6.26.0-universal-darwin lib/puppet/confiner.rb
puppet-6.25.1 lib/puppet/confiner.rb
puppet-6.25.1-x86-mingw32 lib/puppet/confiner.rb
puppet-6.25.1-x64-mingw32 lib/puppet/confiner.rb
puppet-6.25.1-universal-darwin lib/puppet/confiner.rb