Created
November 23, 2013 02:00
-
-
Save yrashk/7609851 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Package do | |
use Hypnotoad | |
@shortdoc "Manages operating system packages (install, uninstall)" | |
requires Apt.Source, attributes[:apt_source], only: attributes[:apt_source] != nil | |
def test(opts) do | |
lock {host, :apt} do | |
{status, _} = shell("dpkg -l #{opts[:name]} >/dev/null 1>/dev/null 2>/dev/null", status: true) | |
end | |
if status == 0 do | |
log "Package installed, nothing else to do" | |
else | |
log "Package is not installed" | |
end | |
status == 0 | |
end | |
def run(opts) do | |
lock {host, :apt} do | |
shell("DEBIAN_FRONTEND=noninteractive apt-get install -o Dpkg::Options::=\"--force-confold\" --force-yes -y #{opts[:name]}") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment