module Capistrano::Cluster::Packages::DSL

Public Instance Methods

file(source, locals={}) click to toggle source
# File lib/capistrano/cluster/packages.rb, line 26
def file(source, locals={})

  if file = file_path(source)
    content = if file =~ /\.erb$/
      ERB.new(File.read(file)).result(TemplateContext.new(self, locals).instance_eval { binding })
    else
      File.read(file)
    end
    StringIO.new(content)
  else
    raise "File #{source} not found"
  end

end
file_path(source) click to toggle source
# File lib/capistrano/cluster/packages.rb, line 41
def file_path(source)
  lookup_paths = [fetch(:files_path), fetch(:default_templates_path)].compact
  lookup_paths.map do |path|
    [File.join(path, "#{source}"), File.join(path, "#{source}.erb")]
  end.flatten.select do |file|
    File.exists? file
  end.first
end
install(*packages) click to toggle source
# File lib/capistrano/cluster/packages.rb, line 10
def install(*packages)
  update_apt_source_list
  sudo "apt-get", "-q", "-y", "--force-yes","install", *packages.flatten
end
update_apt_source_list(forced: false) click to toggle source
# File lib/capistrano/cluster/packages.rb, line 50
def update_apt_source_list(forced: false)
  sudo "apt-get", "-q", "-y", "update" if forced or test "[ ! -z $(find /var/lib/apt/periodic/update-success-stamp -mmin +120) ]"
end