I'm trying to use Puppet/Vagrant to provision a VM with:
The Vagrantfile
contains uses Puppet to provision the box:
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
My default.pp
currently looks like this:
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,
}
This successfully adds the apt key and a file, /etc/apt/sources.list.d/R.list
, to the VM containing:
# 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/
Unfortunately, the R version it installs is old (v3.0.2). That's the version that installs from the Ubuntu repositories when you sudo apt-get install r-base
without adding the repository.
If I ssh
into the box and manually run sudo apt-get install r-base
it does install the latest version of R which, although it doesn't solve my problem (ie fully automated install of R v3.2.0 from cran.rstudio.com), it does prove that the repository works.
Can you see what I'm doing wrong? In the interest of creating a reproducible example I put the the project, in its current state, on github: https://github.com/alexwoolford/vagrantR .
It looks like you need to require the source is setup before the package is applied. I've not done much with ubuntu, but from the module source it does not appear to automatically require sources.
Puppet doesn't apply resources in the order specified in the manifest, instead it can apply them in any order. The exception is when you specify a relationship between two resource to order them.
For example, one way to do this:
exec { "apt-update":
command => "/usr/bin/apt-get update",
require => Apt::Source['R']
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.