vagrant up
产生的vm似乎工作正常。但是,在最简单的配置中,我似乎无法让流氓添加apache(网络服务器)。我正在使用Puppet。
我确保vagrant destroy
然后vagrant up
。在vagrant ssh
时,apache不存在(没有apachectl,没有httpd)。
以下详细信息:
环境:
bash-3.2$ vagrant --version
Vagrant version 1.2.2
bash-3.2$ uname -a
Darwin foo.com 12.3.0 Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64
bash-3.2$
bash-3.2$ pwd
/Users/bar/cbalz
bash-3.2$ ls -ail
total 24
1500058 drwxr-xr-x 7 bar staff 238 Aug 6 16:27 .
379691 drwxr-xr-x+ 37 bar staff 1258 Aug 6 11:29 ..
1500065 drwxr-xr-x 3 bar staff 102 Aug 6 11:23 .vagrant
1500631 -rw-r--r-- 1 bar staff 4948 Aug 6 16:25 Vagrantfile
1500619 -rw-r--r-- 1 bar staff 33 Aug 6 13:34 index.html
1500107 drwxr-xr-x 3 bar staff 102 Aug 6 16:28 manifests
1500704 drwxr-xr-x 2 bar staff 68 Aug 6 14:24 www
bash-3.2$
foo:cbalz bar$ ls -ail manifests
total 8
1500107 drwxr-xr-x 3 bar staff 102 Aug 6 16:28 .
1500058 drwxr-xr-x 7 bar staff 238 Aug 6 16:27 ..
1500806 -rw-r--r-- 1 bar staff 405 Aug 6 16:28 precise64.pp
foo:cbalz bar$
Vagrantfile:
foo:cbalz bar$ more Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# ...
config.vm.box = "precise64"
# ...
# Customization:
Vagrant::Config.run do |config|
config.vm.box = "precise64"
# Enable the Puppet provisioner
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "/Users/bar/cbalz/manifests"
puppet.manifest_file = "precise64.pp"
puppet.options = "--verbose --debug"
end
end
# ...
end
Puppet Manifest文件:
foo:cbalz bar$ cat manifests/precise64.app
# Basic Puppet Apache manifest
class apache {
exec { 'apt-get update':
command => '/usr/bin/apt-get update'
}
package { "apache2":
ensure => present,
}
service { "apache2":
ensure => running,
require => Package["apache2"],
}
# ...
}
设置:
$ vagrant destroy; vagrant up
Are you sure you want to destroy the 'default' VM? [y/N] y
[default] Forcing shutdown of VM...
[default] Destroying VM and associated drives...
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Fixed port collision for 22 => 2222. Now on port 2203.
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2203 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
执行命令
$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)
* Documentation: https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:23:18 2012 from 10.0.2.2
;vagrant@precise64:~$ apachectl
The program 'apachectl' is currently not installed. You can install it by typing:
sudo apt-get install apache2.2-common
vagrant@precise64:~$ httpd
No command 'httpd' found, did you mean:
Command 'xttpd' from package 'xtide' (universe)
httpd: command not found
vagrant@precise64:~$
答案 0 :(得分:2)
尝试删除
Vagrant :: Config.run do | config | config.vm.box =“precise64”
来自Vagrantfile的,以便配置如下所示:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# ...
config.vm.box = "precise64"
# Enable the Puppet provisioner
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "/Users/bar/cbalz/manifests"
puppet.manifest_file = "precise64.pp"
puppet.options = "--verbose --debug"
end
# ...
end