Module: AethernalAgent::Apt

Included in:
App, Loader
Defined in:
lib/aethernal_agent/apt.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



5
6
7
8
9
# File 'lib/aethernal_agent/apt.rb', line 5

def self.included klass
  klass.class_eval do
    include Utils
  end
end

Instance Method Details

#add_apt_ppa(name) ⇒ Object



15
16
17
# File 'lib/aethernal_agent/apt.rb', line 15

def add_apt_ppa(name)
  print_system("add-apt-repository #{name} -y")
end

#apt_package(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/aethernal_agent/apt.rb', line 19

def apt_package(options = {})
  AethernalAgent.logger.info "Installing apt package(s) with options: #{options}"
  action = options[:action]
  action = :install if action.nil?

  packages = options[:packages]
  packages = packages.join(" ") if packages.is_a?(Array)

  unless wait_on_apt(180)
    self.add_errors("APT could not be started because lock was in use for more than 180 seconds")
  end

  case action
  when :install
    # Do this with popen so we can catch error output as well as normal output for add_errors
    print_system("DEBIAN_FRONTEND=noninteractive apt -o DPkg::Options::=--force-confdef install -qy #{packages}")
  when :remove
    print_system("DEBIAN_FRONTEND=noninteractive apt remove -qy #{packages}")
  when :autoremove
    print_system("DEBIAN_FRONTEND=noninteractive apt autoremove -qy")
  end
end

#apt_updateObject



11
12
13
# File 'lib/aethernal_agent/apt.rb', line 11

def apt_update
  print_system("apt update")
end