Module: Awsome::Debian
- Defined in:
- lib/awsome/debian.rb
Class Method Summary collapse
- .autoremove_debian_packages(hostname) ⇒ Object
- .describe_debian_packages(hostname) ⇒ Object
- .install_debian_packages(hostname, *packages) ⇒ Object
- .remove_debian_packages(hostname, *packages) ⇒ Object
Class Method Details
.autoremove_debian_packages(hostname) ⇒ Object
40 41 42 |
# File 'lib/awsome/debian.rb', line 40 def self.autoremove_debian_packages(hostname) Awsome::Ssh.ssh hostname, "sudo apt-get autoremove -y --force-yes" end |
.describe_debian_packages(hostname) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/awsome/debian.rb', line 3 def self.describe_debian_packages(hostname) if Awsome::Ssh.scp("#{hostname}:/home/ubuntu/packages.csv", './packages.csv') File.open('./packages.csv', 'r').read.strip.split(',') else [] end end |
.install_debian_packages(hostname, *packages) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/awsome/debian.rb', line 26 def self.install_debian_packages(hostname, *packages) installed = describe_debian_packages(hostname) remaining = installed.to_set + packages.to_set return if remaining.empty? remaining.each do |p| Awsome::Ssh.ssh hostname, "sudo apt-get update" Awsome::Ssh.ssh hostname, "sudo apt-get install -y --force-yes #{p}" end Awsome::Ssh.ssh hostname, "echo #{remaining.to_a.join(',')} > ~/packages.csv" end |
.remove_debian_packages(hostname, *packages) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/awsome/debian.rb', line 11 def self.remove_debian_packages(hostname, *packages) installed = describe_debian_packages(hostname) remaining = installed.to_set - packages.to_set return if packages.empty? Awsome::Ssh.ssh hostname, "sudo apt-get update" packages.each do |p| Awsome::Ssh.ssh hostname, "sudo apt-get remove -y --force-yes #{p}" end Awsome::Ssh.ssh hostname, "echo #{remaining.to_a.join(',')} > ~/packages.csv" end |