Module: Capitate::Plugins::Yum
- Defined in:
- lib/capitate/plugins/yum.rb
Instance Method Summary collapse
-
#clean ⇒ Object
Clean yum.
-
#install(packages, update_existing = true) ⇒ Object
Install via yum.
-
#remove(packages) ⇒ Object
Remove via yum.
-
#update(packages = []) ⇒ Object
Update all installed packages.
Instance Method Details
#clean ⇒ Object
Clean yum.
Examples
yum.clean
70 71 72 |
# File 'lib/capitate/plugins/yum.rb', line 70 def clean run_via "yum -y clean all" end |
#install(packages, update_existing = true) ⇒ Object
Install via yum.
Options
packages-
Packages to install, either String (for single package) or Array
update_existing-
If package exists, where to yum update it, defaults to true
Examples
yum.install
yum.install([ "aspell" ])
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/capitate/plugins/yum.rb', line 39 def install(packages, update_existing = true) # If a single object, wrap in array packages = [ packages ] unless packages.is_a?(Array) if update_existing installed_packages = [] run_via "yum -d 0 list installed #{packages.join(" ")}" do |channel, stream, data| lines = data.split("\n")[1..-1] if lines.blank? logger.info "Invalid yum output: #{data}" else installed_packages += lines.collect { |line| line.split(".").first } end end packages -= installed_packages run_via "yum -y update #{installed_packages.join(" ")}" unless installed_packages.blank? end run_via "yum -y install #{packages.join(" ")}" unless packages.blank? end |
#remove(packages) ⇒ Object
Remove via yum.
Options
packages-
Packages to remove
Examples
yum.remove
yum.remove([ "aspell" ])
25 26 27 |
# File 'lib/capitate/plugins/yum.rb', line 25 def remove(packages) run_via "yum -y remove #{packages.join(" ")}" end |
#update(packages = []) ⇒ Object
Update all installed packages.
Options
packages-
Packages to update, or empty to update all
Examples
yum.update
yum.update([ "aspell" ])
12 13 14 |
# File 'lib/capitate/plugins/yum.rb', line 12 def update(packages = []) run_via "yum -y update #{packages.join(" ")}" end |