2013-08-06 33 views
2

vagrant up產生的虛擬機似乎工作正常。但我似乎無法在最簡單的配置中加入apache(網絡服務器)。我在使用Puppet。流浪者1.2.2未運行木偶清單

我確定要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 

木偶清單文件:

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 
;[email protected]:~$ apachectl 
The program 'apachectl' is currently not installed. You can install it by typing: 
sudo apt-get install apache2.2-common 
[email protected]:~$ httpd 
No command 'httpd' found, did you mean: 
Command 'xttpd' from package 'xtide' (universe) 
httpd: command not found 
[email protected]:~$ 

回答

2

嘗試刪除

流浪:: Config.run做|配置| 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 
+0

完美的作品。事實證明,我正在關注[過時的文檔](http://docs-v1.vagrantup.com/v1/docs/getting-started/provisioning.html)。 – christopherbalz