ed2*_*209 5 ruby virtualbox puppet vagrant
我刚刚开始使用Vagrant和Puppet.我能够运行Virtualbox但现在我想自动化安装在其上的软件.
在我的Vagrantfile中,我有:
Vagrant::Config.run do |config|
config.vm.box = "precise64"
config.vm.forward_port 80, 9090
config.vm.forward_port 27017, 27017
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "manifests"
puppet.manifest_file = "default.pp"
end
end
Run Code Online (Sandbox Code Playgroud)
在manifeststs/default.pp我有:
Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
class php5{
package { "php5":
ensure => present,
}
}
include php5
Run Code Online (Sandbox Code Playgroud)
但是,当我运行时,vagrant up我得到以下错误(片段).
[default] Running Puppet with /tmp/vagrant-puppet/manifests/default.pp...
stdin: is not a tty
No LSB modules are available.
warning: Could not retrieve fact fqdn
err: /Stage[main]/Php5/Package[php5]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install php5' returned 100: Reading package lists...
Run Code Online (Sandbox Code Playgroud)
我不确定错误在哪里,所以这里有一些可能有用的进一步信息
Ruby版本
$ ruby -v
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]
Run Code Online (Sandbox Code Playgroud)
宝石来源
$ gem sources
*** CURRENT SOURCES ***
http://rubygems.org/
Run Code Online (Sandbox Code Playgroud)
更新1:在这篇文章后我安装了facter和puppet现在运行正常,但主要问题仍在发生.
更新2:标记正确的答案,但我想分享我的整个清单文件http://pastebin.com/LGNhVPV7
发生“apt-get install”错误的原因可能是虚拟机在 Puppet 尝试执行“apt-get install”之前尚未完成“apt-get update”。当您请求安装软件包时,Puppet 不会自行处理“apt-get update”,但您可以在清单中清楚地说明它应该很容易发生。
尝试添加 Leach 先生在他的http://johnleach.co.uk/words/771/puppet-dependency-and-run-stages帖子中提到的 apt 类。这应该确保在安装任何软件包之前运行“apt-get update”。