3

我对此很陌生,我想我只是错过了一件事来掌握问题的真正含义。

我知道我可以创建自己的 puppet 模块,将某些包页面安装到 vagrant 实例。还有一些现成的,比如这个apache。我已经运行 vagrant ssh并使用puppet module install 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 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 
4

3 回答 3

4

您告诉 Vagrant 它应该在puppet/manifests(相对于您的 Vagrant 目录)中查找清单,并且它应该根据 in 中的任何内容配置机器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 模块)。

于 2014-01-14T02:04:19.017 回答
3

我选择了一个我不太喜欢的解决方案,因为它覆盖了 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':  }
}

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

于 2014-01-14T15:38:49.270 回答
1

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

所以它会是这样的。

节点'hosts.fqdn'{

include apache2 

}

欲了解更多信息:http ://docs.puppetlabs.com/puppet/2.7/reference/lang_node_definitions.html

于 2014-01-14T01:50:05.353 回答