我尝试使用Puppet / Vagrant配置虚拟机:
Vagrantfile
包含使用Puppet配置框:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision "puppet" do |puppet|
puppet.module_path = "modules"
end
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "1024"
end
end
我的default.pp
目前看起来像这样:
include apt
apt::key { 'cran':
id => 'E084DAB9',
server => 'keyserver.ubuntu.com',
}
apt::source { 'R':
comment => 'This is the apt repository for R - the language for statistical computing',
location => 'http://cran.rstudio.com/bin/linux/ubuntu/',
release => 'trusty/',
repos => '',
}
exec { "apt-update":
command => "/usr/bin/apt-get update"
}
Exec["apt-update"] -> Package <| |>
package { "r-base":
ensure => latest,
}
这会成功将apt密钥和文件/etc/apt/sources.list.d/R.list
添加到包含以下内容的VM中:
# This file is managed by Puppet. DO NOT EDIT.
# This is the apt repository for R - the language for statistical computing
deb http://cran.rstudio.com/bin/linux/ubuntu/ trusty/
不幸的是,它安装的R版本是旧的(v3.0.2)。这是在sudo apt-get install r-base
没有添加存储库的情况下从Ubuntu存储库安装的版本。
如果我ssh
进入框中并手动运行sudo apt-get install r-base
,那么会安装最新版本的R,虽然它并没有解决我的问题(即从cran.rstudio.com完全自动安装R v3.2.0,它确实证明了存储库的工作原理。
你能看出我做错了什么吗?为了创建一个可重现的示例,我将项目置于当前状态的github:https://github.com/alexwoolford/vagrantR。
答案 0 :(得分:1)
看起来您需要在应用包之前设置源。我没有对ubuntu做过多少工作,但是从模块源来看,它似乎不会自动需要源代码。
Puppet不按清单中指定的顺序应用资源,而是可以按任何顺序应用它们。例外情况是指定两个资源之间的关系以对它们进行排序。
例如,一种方法:
exec { "apt-update":
command => "/usr/bin/apt-get update",
require => Apt::Source['R']
}