spec/integration/vm/cookbooks/apt-mirror/recipes/default.rb in infrataster-0.1.6 vs spec/integration/vm/cookbooks/apt-mirror/recipes/default.rb in infrataster-0.1.7

- old
+ new

@@ -1,8 +1,16 @@ -execute "sed -i -e 's| \\(http[^ ]\\+\\)| mirror://mirrors.ubuntu.com/mirrors.txt|g' /etc/apt/sources.list" +require 'net/http' +require 'uri' + +apt_servers = Net::HTTP.get(URI.parse('http://mirrors.ubuntu.com/mirrors.txt')).split("\n") +# ftp.riken.jp is unstable and slow? +apt_servers.delete('http://ftp.riken.jp/Linux/ubuntu/') +apt_server = apt_servers[rand(apt_servers.size)] + +execute "sed -i -e 's| \\(http[^ ]\\+\\)| #{apt_server}|g' /etc/apt/sources.list" include_recipe 'apt'