Last active
December 23, 2015 16:49
-
-
Save trashhalo/6664262 to your computer and use it in GitHub Desktop.
Adds a new apt source to the sources.list.d. Runs apt-get update for only that source and installs a package from the new source.
This file contains 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
define apt-update-single($repofile=$title,$source){ | |
file{"/etc/apt/sources.list.d/${repofile}.list": | |
ensure=>'present', | |
content=>$source, | |
} | |
exec{"apt-get-update-$repofile": | |
command=>"/usr/bin/apt-get update -o Dir::Etc::sourcelist=\"sources.list.d/${repofile}.list\" -o Dir::Etc::sourceparts=\"-\" -o APT::Get::List-Cleanup=\"0\"", | |
require=>File["/etc/apt/sources.list.d/${repofile}.list"], | |
unless=>"/bin/ls /var/lib/apt/lists/|grep $repofile 2>/dev/null" | |
} | |
} | |
apt-update-single{'sublime': | |
source=>'deb http://ppa.launchpad.net/webupd8team/sublime-text-2/ubuntu raring main' | |
} | |
package{'sublime-text': | |
ensure => 'present', | |
require => Apt-update-single['sublime'] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
unless=>"/bin/ls /var/lib/apt/lists/|grep $repofile 2>/dev/null"
I still feel iffy about that line. Its works in the two cases I am using it for but I am sure it wont for all cases. It looks in the place that ubuntu dumps its package databases to try and guess if this repository had previously been apt-get updated. If it sees the file with the matching name it skips it. This lets me keep reprovisioning down to 0.38 seconds.