1

以前我有与此工作类似的配置,但是一旦我将 hiera 添加到我的 puppet 构建中,我就开始遇到问题。我目前运行后的错误vagrant provision如下:

==> default: [vagrant-hostsupdater] Checking for host entries
==> default: [vagrant-hostsupdater]   found entry for: 192.168.33.10 local.mysite
==> default: Configuring cache buckets...
==> default: Running provisioner: puppet...
==> default: Running Puppet with app.pp...
==> default: stdin: is not a tty
==> default: Error: Could not find class nodejs for local.mysite on node local.mysite
==> default: Error: Could not find class nodejs for local.mysite on node local.mysite
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

我的流浪配置是:

# -*- mode: ruby -*-
# vi: set ft=ruby :
require "yaml"

# Load yaml configuration
config_file = "#{File.dirname(__FILE__)}/config/vm_config.yml"
default_config_file = "#{File.dirname(__FILE__)}/config/.vm_config_default.yml"

vm_external_config = YAML.load_file(config_file)

# Configure Vagrant
Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"

  config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"

  config.vm.network :private_network, ip: vm_external_config["ip"]
  config.vm.hostname = vm_external_config["hostname"]
  config.vm.network "forwarded_port", guest: vm_external_config["port"], host: 2368

  config.vm.synced_folder vm_external_config["ghost_path"], "/var/www/mysite.com", :nfs => true

  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", vm_external_config["memory"]]
  end

  config.cache.scope = :box

  config.librarian_puppet.placeholder_filename = ".gitkeep"

  config.vm.provision :puppet do |puppet|
    puppet.hiera_config_path = "puppet/hiera/hiera.yaml"
    puppet.manifests_path = "puppet/manifests"
    puppet.manifest_file = "app.pp"
    puppet.module_path = "puppet/modules"
    puppet.facter = {
        "environment" => ENV['ENV'] ? ENV['ENV'] : 'local'
    }
  end
end

我的源代码树看起来像这样(除了自定义博客模块和 hiera 配置的文件夹结构之外,其中大部分都不相关):

├── Vagrantfile
├── config
│   └── vm_config.yml
└── puppet
    ├── Puppetfile
    ├── hiera
    │   ├── common.yaml
    │   ├── hiera.yaml
    │   ├── local
    │   │   └── site.yaml
    │   └── production
    │       └── site.yaml
    ├── manifests
    │   └── app.pp
    └── modules
        ├── blog
        │   └── manifests
        │       └── app.pp
        ├── ghost
        │   └── manifests
        │       └── app.pp
        ├── init.d
        │   └── files
        │       ├── WebhookServer
        │       └── ghost
        ├── mailgunner
        ├── nginx
        │   ├── files
        │   │   ├── local
        │   │   │   ├── mysite.com
        │   │   │   └── mail.mysite.com
        │   │   └── production
        │   │       ├── mysite.com
        │   │       └── mail.mysite.com
        │   └── manifests
        │       └── server.pp
        ├── tools
        │   ├── files
        │   │   ├── local
        │   │   │   ├── backup.sh
        │   │   │   ├── ghostsitemap.sh
        │   │   │   └── init-mysite.sh
        │   │   └── production
        │   │       ├── backup.sh
        │   │       ├── ghostsitemap.sh
        │   │       └── init-mysite.sh
        │   └── manifests
        │       └── install.pp
        └── webhooks
            ├── files
            │   ├── local
            │   │   └── init-webhook.sh
            │   ├── production
            │   │   └── init-webhook.sh
            │   ├── webhook.sh
            │   └── webhooks.rb
            └── manifests
                └── install.pp

hiera.yaml:

---
:backends:
  - yaml

:yaml:
  :datadir: /vagrant/hieradata

:hierarchy:
  - "%{::environment}/site
  - common

common.yaml

--
classes:
  - site

本地/site.yaml

--
:site:
  environment: local
  name: local.mysite
  mailserver: local.mail.mysite

博客/清单/app.pp

class blog::app {

  class { 'nodejs':
    version => 'v0.10.25',
  } ->
  package { 'pm2':
    ensure => present,
    provider => 'npm',
    require => Class['nodejs'],
  }
}

木偶文件

forge 'https://forgeapi.puppetlabs.com'

mod 'willdurand/nodejs', '1.9.4'

基本上,我的问题是我的 puppet 安装没有重新安装 nodejs (我之前使用删除了它rm -rf puppet/modules/nodejs

有谁知道 puppet 现在如何或为什么拒绝在 puppet/modules 目录中安装 nodejs puppet 模块?

仅供参考 - 我已经安装了 willdurand/nodejs 模块使用puppet module install willdurand/nodejs

任何帮助都非常感谢 - 我已经把头撞在砖墙上几天了!

4

1 回答 1

1

vagrant-librarian-puppet使用Puppetfile它来安装您的 puppet 模块,因此它应该安装。

确保插件已安装

$ vagrant plugin list
vagrant-librarian-puppet (0.9.2)
....

如果您没有看到该插件,请确保安装它

$ vagrant plugin install vagrant-librarian-puppet
于 2016-04-25T07:12:19.337 回答