diff --git a/apt/manifests/init.pp b/apt/manifests/init.pp index 6b2e4f7..0f01a3b 100644 --- a/apt/manifests/init.pp +++ b/apt/manifests/init.pp @@ -16,6 +16,62 @@ class apt { } +# Install common packages for using PPA's. +# +class apt::ppa::helper { + + package { "python-software-properties": + ensure => installed, + } + +} + + +# Add PPA archive to system. +# +# === Parameters +# +# $name: +# PPA name. Needs to be in format "ppa:user/ppa-name". +# +# $ensure: +# Ensure archive is absent or present. Defaults to present. +# +# === Sample usage +# +# apt::ppa { "ppa:igraph/ppa": } +# +define apt::ppa($ensure = "present") { + + tag("bootstrap") + + include apt::ppa::helper + $fname = gsub($name, "^ppa:([^\/]+)\/(.+)", "\\1-\\2-${lsbdistcodename}.list") + + case $ensure { + "present": { + exec { "add-apt-repository ${name}": + path => "/bin:/usr/bin:/sbin:/usr/sbin", + user => "root", + creates => $fname, + require => Package["python-software-properties"], + notify => Exec["apt-get-update"], + } + } + "absent": { + file { $fname: + ensure => absent, + notify => Exec["apt-get-update"], + } + } + default: { + fail("test") + } + } + +} + + # Configure /etc/apt/sources.list # # === Global variables