【问题标题】:Node.js module won't reinstall using puppet / vagrantNode.js 模块不会使用 puppet / vagrant 重新安装
【发布时间】:2016-04-25 05:51:28
【问题描述】:

以前我有一个与此工作类似的配置,但是一旦我将 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

local/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 模块?

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

非常感谢任何帮助 - 几天来我一直在用头撞砖墙!

【问题讨论】:

  • 您似乎在使用图书管理员,所以您能否确认您已安装插件vagrant-librarian-puppet
  • 嗨,Frédéric - 请问您能扩展一下吗?
  • 我是第一次使用 puppet。我一直在研究 John Arundel 的 Puppet 3 书籍介绍,但大部分工作都是从网络上的粗略示例和我发现的其他 GitHub 示例中拼凑而成的,所以我完全有可能让我的电线交叉跨度>

标签: vagrant puppet librarian-puppet


【解决方案1】:

Puppetfile 被 vagrant-librarian-puppet 用来安装你的 puppet 模块,所以它应该安装。

确保插件已安装

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

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

$ vagrant plugin install vagrant-librarian-puppet

【讨论】:

  • 谢谢,我相信我已经做到了,但我会在我回家时仔细检查。出于兴趣,我是否还需要手动安装 puppet 模块,例如'木偶模块安装 willdurand/nodejs' ?或者流浪的傀儡图书管理员会为我做这些吗?
  • 没有图书馆员的想法是它会为您完成 - 您设置所有必要的模块,它会在任何配置完成之前为您运行安装木偶模块。更进一步,我个人仍然更喜欢有一个运行安装木偶模块的 shell 脚本,因为它不依赖于我团队成员工作站上的另一个插件,但它是一个品味问题以及你如何使用它
  • 好的 - 我想我的问题是我手动安装了库,它不会安装它,因为它认为它存在。我会尝试卸载它并重新运行 vagrant provision 步骤以确认 - 谢谢
  • 这确实可能是问题所在。您可以尝试从头开始并重新配置新的虚拟机。我不确定是否应该有一些错误日志或不告诉你模块无法安装,因为它已经存在或类似的东西
猜你喜欢
  • 1970-01-01
  • 2014-03-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-27
  • 1970-01-01
  • 2015-11-20
相关资源
最近更新 更多