Module: Prepper::Tools::Apt

Included in:
Package
Defined in:
lib/prepper/tools/apt.rb

Overview

Helper methods to interact with Apt

Instance Method Summary collapse

Instance Method Details

#apt_install(packages) ⇒ Object

Installs packages

Parameters:

  • packages (Array)

    array of package names



12
13
14
15
16
# File 'lib/prepper/tools/apt.rb', line 12

def apt_install(packages)
  packages.each do |package|
    @commands << Command.new("apt install --force-yes -qyu #{package}", sudo: true, verify: has_apt_package?(package))
  end
end

#apt_updateObject

Updates apt repositories



6
7
8
# File 'lib/prepper/tools/apt.rb', line 6

def apt_update
  @commands << Command.new("apt update", sudo: true)
end

#has_apt_package?(package) ⇒ Boolean

Verifier command to checks if an apt package is installed

Parameters:

  • package (String)

    name of the package

Returns:

  • (Boolean)


20
21
22
# File 'lib/prepper/tools/apt.rb', line 20

def has_apt_package?(package)
  Command.new("dpkg --status #{package} | grep 'ok installed'", sudo: true)
end