Vagrant 将自定义Puppet模块移动到单独的环境中,它现在无法加载任何依赖项 问题

Vagrant 将自定义Puppet模块移动到单独的环境中,它现在无法加载任何依赖项 问题,vagrant,puppet,packer,Vagrant,Puppet,Packer,我将一个傀儡清单拆分为两个清单,每个清单位于不同的环境中,第二个环境中的清单似乎无法引用任何模块。我很确定这是因为我做错了什么,但我不知道是什么 ubuntu@vagranttest:~$ puppet --version 4.9.2 总结 我正在学习使用木偶。我已经编写了三个自定义模块,它们都工作得很好。我想将我的流程分为两个步骤: 一个木偶清单,用于构建安装了所有依赖项的映像 第二个用于安装我的项目,使用以前构建的映像作为基础。此步骤取决于voxpupuli/nginx 这样,每当我添加要

我将一个傀儡清单拆分为两个清单,每个清单位于不同的环境中,第二个环境中的清单似乎无法引用任何模块。我很确定这是因为我做错了什么,但我不知道是什么

ubuntu@vagranttest:~$ puppet --version
4.9.2
总结 我正在学习使用木偶。我已经编写了三个自定义模块,它们都工作得很好。我想将我的流程分为两个步骤:

  • 一个木偶清单,用于构建安装了所有依赖项的映像
  • 第二个用于安装我的项目,使用以前构建的映像作为基础。此步骤取决于
    voxpupuli/nginx
  • 这样,每当我添加要在此框上运行的新项目时,我就不必再次安装所有依赖项

    我将引用
    voxpupuli/nginx
    的自定义模块移动到一个单独的Puppet环境中,现在它似乎已经完全不知道nginx模块是什么了

    重构前
    /puupet env/dev/manifests/site.pp

    $repoPath = "/var/repos"
    $sitePath = "/var/www"
    
    class { 'userconfig': }
    
    class {'dependencies':
      require => Class['userconfig'],
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    class { 'sitebuilder':
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    $repoPath = "/var/repos"
    $sitePath = "/var/www"
    
    class { 'userconfig': }
    
    class {'dependencies':
      require => Class['userconfig'],
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    $repoPath = "/var/repos"
    $sitePath = "/var/www"
    
    class { 'sitebuilder':
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    重构后
    /puupet env/base/manifests/site.pp

    $repoPath = "/var/repos"
    $sitePath = "/var/www"
    
    class { 'userconfig': }
    
    class {'dependencies':
      require => Class['userconfig'],
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    class { 'sitebuilder':
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    $repoPath = "/var/repos"
    $sitePath = "/var/www"
    
    class { 'userconfig': }
    
    class {'dependencies':
      require => Class['userconfig'],
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    $repoPath = "/var/repos"
    $sitePath = "/var/www"
    
    class { 'sitebuilder':
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    /puupet env/deploy/manifests/site.pp

    $repoPath = "/var/repos"
    $sitePath = "/var/www"
    
    class { 'userconfig': }
    
    class {'dependencies':
      require => Class['userconfig'],
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    class { 'sitebuilder':
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    $repoPath = "/var/repos"
    $sitePath = "/var/www"
    
    class { 'userconfig': }
    
    class {'dependencies':
      require => Class['userconfig'],
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    $repoPath = "/var/repos"
    $sitePath = "/var/www"
    
    class { 'sitebuilder':
      repoPath => $repoPath,
      sitePath => $sitePath,
    }
    
    运行傀儡舱单 使用Packer,我有一个Packer配置,它用
    /puupet env/base/manifests/site.pp
    构建一个新映像,还有一个配置,它用
    /puupet env/deploy/manifests/site.pp
    构建在该映像之上

    对于Vagrant,我只是在我的Vagrant文件中这样做:

    config.vm.define "dev", primary:true do |dev|
      config.vm.provision "shell", path: "provision.sh"
    
    config.vm.provision "puppet" do |puppet|
      puppet.environment_path = "puppet-env"
      puppet.environment = "base"
      puppet.module_path = "modules"
    end
    
    config.vm.provision "puppet" do |puppet|
      puppet.environment_path = "puppet-env"
      puppet.environment = "deploy"
      puppet.module_path = "modules"
    end
    
    错误消息 如果我在Vagrant或带有Packer的数字海洋盒子上运行此操作,我会收到相同的错误消息

    ==> dev: Warning: Unknown variable: '::nginx::config::spdy'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:219:35
    ==> dev: Warning: Unknown variable: '::nginx::config::http2'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:220:35
    ==> dev: Warning: Unknown variable: '::nginx::config::proxy_read_timeout'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:223:35
    ==> dev: Warning: Unknown variable: '::nginx::config::proxy_connect_timeout'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:224:35
    ==> dev: Warning: Unknown variable: '::nginx::config::proxy_set_header'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:225:35
    ==> dev: Warning: Unknown variable: '::nginx::config::proxy_hide_header'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:226:35
    ==> dev: Warning: Unknown variable: '::nginx::config::conf_dir'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:236:38
    ==> dev: Warning: Unknown variable: 'nginx::config::conf_dir'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:239:38
    ==> dev: Warning: Unknown variable: '::nginx::config::global_owner'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:283:35
    ==> dev: Warning: Unknown variable: '::nginx::config::global_group'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:284:35
    ==> dev: Warning: Unknown variable: '::nginx::config::global_mode'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:285:35
    ==> dev: Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, "" is not an Array.  
    It looks to be a String at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:387:3  at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/sitebuilder/manifests/builder.pp:18 on node vagranttest
    
    谁能告诉我我做错了什么?我觉得这是因为我不了解木偶

    builder.pp
    确保添加主nginx类的定义

    class { 'nginx': }
    

    在您可以评估
    nginx::resource::vhost

    之前,您可以在您的puppet文件中确认您正在使用的puppet版本,并添加builder.ppI正在使用的4.9.2的内容。将在我的帖子中添加builder.pp。我已经在我的问题中添加了builder.pp。啊,就是这样。我想,因为它已经被定义过一次了,它就会出现在系统上,然后被我的第二个清单找到。非常感谢你!不一定,在您的例子中,您确实将puppet作为两个不同的provisioners运行了两次,因此它无法从第一个清单中找到