Permalink
Browse files

Add ensure_ppa for installing Ubuntu PPAs.

  • Loading branch information...
1 parent aec601d commit 7af8cb95d35a4bf9dfa141ec3c94408c8e259b6a @cespare cespare committed Mar 24, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 lib/terraform/terraform_dsl.rb
@@ -68,6 +68,20 @@ def ensure_package(package)
end
end
+ # Ensure an Ubuntu PPA is installed. The argument is the ppa location, in the form ppa:[USER]/[NAME]
+ def ensure_ppa(ppa)
+ ppa_part, location = ppa.split(":", 2)
+ fail_and_exit("PPA location must be of the form ppa:[USER]/[NAME]") unless ppa_part && location
+ ensure_package("python-software-properties")
+ dep "ppa: #{location}" do
+ met? { !`apt-cache policy 2> /dev/null | grep ppa.launchpad.net/#{location}/`.empty? }
+ meet do
+ shell "sudo add-apt-repository #{ppa}"#, :silent => true
+ shell "sudo apt-get update"#, :silent => true
+ end
+ end
+ end
+
def gem_installed?(gem) `gem list '#{gem}'`.include?(gem) end
def ensure_gem(gem)

0 comments on commit 7af8cb9

Please sign in to comment.