class R10K::Deployment

A deployment models the entire state of the configuration that a Puppet master can use. It contains a set of sources that can produce environments and manages the contents of directories where environments are deployed.

@api private

Attributes

config[R]

@!attribute [r] config

@return [R10K::Deployment::Config]

Public Class Methods

load_config(path, overrides={}) click to toggle source

Generate a deployment object based on a config

@deprecated

@param path [String] The path to the deployment config @return [R10K::Deployment] The deployment loaded with the given config

# File lib/r10k/deployment.rb, line 22
def self.load_config(path, overrides={})
  config = R10K::Deployment::Config.new(path, overrides)
  new(config)
end
new(config) click to toggle source
# File lib/r10k/deployment.rb, line 31
def initialize(config)
  @config = config
end

Public Instance Methods

accept(visitor) click to toggle source
# File lib/r10k/deployment.rb, line 101
def accept(visitor)
  visitor.visit(:deployment, self) do
    sources.each do |source|
      source.accept(visitor)
    end
  end
end
environments() click to toggle source

Lazily load all environments

This instantiates the @_environments instance variable, but should not be used directly as it could be legitimately unset if we're doing lazy loading.

@return [Array<R10K::Environment::Base>] All enviroments across

all sources
# File lib/r10k/deployment.rb, line 60
def environments
  load_environments if @_environments.nil?
  @_environments
end
paths() click to toggle source

@return [Array<String>] The paths used by all contained sources

# File lib/r10k/deployment.rb, line 66
def paths
  paths_and_sources.keys
end
paths_and_sources() click to toggle source

@return [Hash<String, Array<R10K::Source::Base>]

# File lib/r10k/deployment.rb, line 71
def paths_and_sources
  pathmap = Hash.new { |h, k| h[k] = [] }
  sources.each { |source| pathmap[source.basedir] << source }
  pathmap
end
preload!() click to toggle source
# File lib/r10k/deployment.rb, line 35
def preload!
  sources.each(&:preload!)
end
purge!() click to toggle source

Remove unmanaged content from all source paths

# File lib/r10k/deployment.rb, line 78
def purge!
  paths_and_sources.each_pair do |path, sources_at_path|
    R10K::Util::Basedir.new(path, sources_at_path).purge!
  end
end
sources() click to toggle source

Lazily load all sources

This instantiates the @_sources instance variable, but should not be used directly as it could be legitimately unset if we're doing lazy loading.

@return [Array<R10K::Source::Base>] All repository sources

specified in the config
# File lib/r10k/deployment.rb, line 47
def sources
  load_sources if @_sources.nil?
  @_sources
end
validate!() click to toggle source
# File lib/r10k/deployment.rb, line 84
def validate!
  hash = {}
  sources.each do |source|
    source.environments.each do |environment|
      if hash.key?(environment.path)
        osource, oenvironment = hash[environment.path]
        msg = ""
        msg << "Environment collision at #{environment.path} between "
        msg << "#{source.name}:#{environment.name} and #{osource.name}:#{oenvironment.name}"
        raise R10K::Error, msg
      else
        hash[environment.path] = [source, environment]
      end
    end
  end
end

Private Instance Methods

load_environments() click to toggle source
# File lib/r10k/deployment.rb, line 121
def load_environments
  @_environments = []
  sources.each do |source|
    @_environments += source.environments
  end
end
load_sources() click to toggle source
# File lib/r10k/deployment.rb, line 111
def load_sources
  sources = @config[:sources]
  if sources.nil? || sources.empty?
    raise R10K::Error, "Unable to load sources; the supplied configuration does not define the 'sources' key"
  end
  @_sources = sources.map do |(name, hash)|
    R10K::Source.from_hash(name, hash)
  end
end