Skip to content

Instantly share code, notes, and snippets.

@yrashk
Created November 23, 2013 02:00
Show Gist options
  • Save yrashk/7609851 to your computer and use it in GitHub Desktop.
Save yrashk/7609851 to your computer and use it in GitHub Desktop.
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