在Vagrant上从Puppetlabs安装Apache

时间:2014-01-13 22:30:56

标签: apache vagrant puppet puppetlabs-apache

我是新手,我想我只是缺少一件事来掌握问题的真正含义。

我知道我可以创建自己的木偶模块,将某些包装安装到流浪者实例。还有一些现成的,如apache。我跑了 vagrant ssh并使用puppet module install puppetlabs/apache进行安装。它现在位于/etc/puppet/modules/apache下。但是,没有安装apache。

那么,如何安装apache

在我的Vagrantfile中我有

config.vm.provision :puppet do |puppet|
  puppet.manifests_path = "puppet/manifests"
  puppet.module_path = "puppet/modules"
  puppet.manifest_file  = "init.pp"
  puppet.options="--verbose --debug"
end

另外,在主要的流浪者目录中,puppet/modules/apache/manifests/init.pp下:

class apache2::install {
  package { 'apache2':
    ensure => present,
  }
}

然而,在vagrant provisionvagrant reload之后没有安装apache,或者我猜测,安装过程甚至都没有启动。 在vagrant provision之后登录,其消息对我来说看起来非常神秘。

[default] Running provisioner: puppet...
Running Puppet with init.pp...
debug: Creating default schedules
debug: Puppet::Type::User::ProviderDirectoryservice: file /usr/bin/dscl does not exist
debug: Puppet::Type::User::ProviderUser_role_add: file rolemod does not exist
debug: Puppet::Type::User::ProviderLdap: true value when expecting false
debug: Puppet::Type::User::ProviderPw: file pw does not exist
debug: Failed to load library 'ldap' for feature 'ldap'
debug: /File[/var/lib/puppet/ssl/certificate_requests]: Autorequiring File[/var/lib/puppet/ssl]
debug: /File[/var/lib/puppet/state/graphs]: Autorequiring File[/var/lib/puppet/state]
debug: /File[/var/lib/puppet/ssl/public_keys]: Autorequiring File[/var/lib/puppet/ssl]
debug: /File[/var/lib/puppet/facts]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/ssl/private_keys]: Autorequiring File[/var/lib/puppet/ssl]
debug: /File[/var/lib/puppet/client_yaml]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/state/last_run_report.yaml]: Autorequiring File[/var/lib/puppet/state]
debug: /File[/var/lib/puppet/client_data]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/state/state.yaml]: Autorequiring File[/var/lib/puppet/state]
debug: /File[/var/lib/puppet/ssl/certs]: Autorequiring File[/var/lib/puppet/ssl]
debug: /File[/var/lib/puppet/lib]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/ssl/private]: Autorequiring File[/var/lib/puppet/ssl]
debug: /File[/var/lib/puppet/state/last_run_summary.yaml]: Autorequiring File[/var/lib/puppet/state]
debug: /File[/var/lib/puppet/state]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/clientbucket]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/ssl]: Autorequiring File[/var/lib/puppet]
debug: Finishing transaction 70208664910260
debug: Loaded state in 0.00 seconds
debug: Loaded state in 0.00 seconds
info: Applying configuration version '1389652562'
debug: /Schedule[daily]: Skipping device resources because running on a host
debug: /Schedule[monthly]: Skipping device resources because running on a host
debug: /Schedule[hourly]: Skipping device resources because running on a host
debug: /Schedule[never]: Skipping device resources because running on a host
debug: /Schedule[weekly]: Skipping device resources because running on a host
debug: /Schedule[puppet]: Skipping device resources because running on a host
debug: Finishing transaction 70208665347780
debug: Storing state
debug: Stored state in 0.00 seconds
notice: Finished catalog run in 0.05 seconds
debug: Finishing transaction 70208665012580
debug: Received report to process from localhost.localdomain
debug: Processing report from localhost.localdomain with processor Puppet::Reports::Store 

3 个答案:

答案 0 :(得分:4)

你告诉Vagrant它应该在puppet/manifests(相对于你的Vagrant目录)中查找清单,并且它应该根据init.pp中的任何内容来配置机器,它会看起来适用于puppet/manifests(根据您的说明)。也就是说,Vagrant将安装puppet/manifests/init.pp中的任何内容。它不会看puppet/modules/apache/manifests/init.pp(至少,不是一开始)。

puppet/manifests/init.pp中添加以下内容,它应该正确安装。

class {'apache':}

除了apache模块之外,还要确保在puppet/modules目录中安装了所有依赖项(本例中为Puppetlabs的stdlib和concat模块)。

答案 1 :(得分:3)

我选择了一个我不太喜欢的解决方案,因为它会覆盖任何未由puppet配置的设置。但是,嘿,它可以顺利完成工作。

我的Vagrantfile:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box = "base"
  #config.vm.box_url = "http://domain.com/path/to/above.box"

  config.vm.network :forwarded_port, guest: 80, host: 5656, auto_correct: true

  config.vm.provision :shell do |shell|
    shell.inline = "mkdir -p /etc/puppet/modules;
                    puppet module install puppetlabs-concat --force --modulepath '/vagrant/puppet/modules'
                    puppet module install puppetlabs-stdlib --force --modulepath '/vagrant/puppet/modules'
                    puppet module install puppetlabs-apache --force --modulepath '/vagrant/puppet/modules'"
  end


  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.module_path = "puppet/modules"
    puppet.manifest_file  = "init.pp"
    puppet.options="--verbose --debug"
  end

end

注意:该脚本实际上也可以在没有--force --modulepath '/vagrant/puppet/modules

的情况下工作

我的puppet/manifests/init.pp

node default {
    class { 'apache':  }
}

感谢https://stackoverflow.com/a/21105703/2066118让我指向正确的方向。

答案 2 :(得分:1)

我不确定Vagrant,但在puppet中,您需要提及需要在“/etc/puppet/manifests/site.pp”文件的节点中安装的内容。

所以它会是这样的。

  

node'hosts.fqdn'{

include apache2 
     

}

有关详细信息:http://docs.puppetlabs.com/puppet/2.7/reference/lang_node_definitions.html