从Vagrant上的Puppetlabs安装Apache

从Vagrant上的Puppetlabs安装Apache,apache,vagrant,puppet,puppetlabs-apache,Apache,Vagrant,Puppet,Puppetlabs Apache,我是新来的,我想我只是错过了一件事来理解问题的真正所在 我知道我可以创建自己的puppet模块,将某些包安装到一个vagrant实例。还有一些现成的,像这样的。我跑了 vagrant ssh并使用puppet模块安装puppetlabs/apache进行安装。它现在位于/etc/puppet/modules/apache下。但是,没有安装apache 那么,如何安装apache呢 在我的流浪者档案里我有 config.vm.provision :puppet do |puppet| pupp

我是新来的,我想我只是错过了一件事来理解问题的真正所在

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

那么,如何安装apache呢

在我的流浪者档案里我有

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
另外,在主vagrant目录下的
puppet/modules/apache/manifests/init.pp
下:

class apache2::install {
  package { 'apache2':
    ensure => present,
  }
}
然而,在
vagrant provision
vagrant reload
之后,没有安装apache,或者我猜,安装过程甚至没有开始。 从《流浪者条款》之后开始登录,我觉得它的信息非常神秘

[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 

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

就是这样

节点“hosts.fqdn”{

include apache2 
}


有关更多信息:

您已经告诉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模块)。

我使用了一个我并不完全喜欢的解决方案,因为它覆盖了puppet未提供的任何设置。但是,嘿,工作做得很顺利

我的流浪汉档案:

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':  }
}

感谢您为我指明了正确的方向。

在模块页面的开头告诉我如何
class{'apache':}
。但我到底把它放在哪里了?我不能在您的
/puppet/manifests/init.pp
文件中的主init.pp
类{'apache':}
中工作。确保您的
/puppet/modules/
目录中有stdlib和concat的副本(我只是从各自的Github repo中克隆了这些副本)。谢谢,这很有帮助。我现在正在从puppetforge安装,没问题。根据apache模块自述文件更新了使用基本apache类的答案,并包含了关于依赖性的说明。乐意接受吗?不需要在VM中运行shell命令/vagrant/puppet/modules/只是主机上目录的副本,该目录由vagrant文件中的
puppet.module\u路径设置指向。在
/puppet/modules/
中安装模块(我通常只是从他们的Github repo克隆它们的副本),它们将可供您的VM使用。好吧,这是标准操作过程。另外,在
节点default
节点中声明类不会起作用,但没有必要:)到目前为止,您的建议非常有用。谢谢你。在使用Library puppet时,我在掌握项目的正确组织(以及自编模块的使用)方面仍然有一个小问题。你能抽出几分钟时间回答几个理论问题吗?当然。只要把它们作为问题提交,贴在木偶下面,我会在它们出现时回答它们。