我有一个木偶配置,可以在一个Windows VM(Windows 2008 R2)上使用puppet apply。我将代码复制到第二个VM(相同操作系统)上的同一目录中,但是puppet apply失败并出现此错误:
Error: Could not autoload puppet/provider/mirrored_directory/zip: cannot load such file -- zip
Error: Could not autoload puppet/type/mirrored_directory: Could not autoload puppet/provider/mirrored_directory/zip: cannot load such file -- zip
Error: Could not autoload puppet/type/mirrored_directory: Could not autoload puppet/provider/mirrored_directory/zip: cannot load such file -- zip on node usb-tg
2008r2t2.xxxx.com
Error: Could not autoload puppet/type/mirrored_directory: Could not autoload puppet/provider/mirrored_directory/zip: cannot load such file -- zip on node usb-tg
2008r2t2.xxxx.com
这是我的源代码树:
C:\PHX_DEPLOYER
└───puppet
├───manifests
└───modules
├───dotnet
│ ├───files
│ ├───lib
│ │ └───puppet
│ │ └───parser
│ │ └───functions
│ └───manifests
├───mirrored_directory
│ └───lib
│ └───puppet
│ ├───provider
│ │ └───mirrored_directory
│ │ └───zip
│ └───type
├───tfview
│ ├───files
│ │ └───tf
│ └───manifests
└───tf_package
└───manifests
我启动了以管理员身份运行的puppet cmd控制台。我手动设置HOMEDRIVE = C:来解决一个问题(我们的启动脚本将其设置为H:驱动器)。 我设置modulepath和hiera_config以匹配我在另一台机器上的内容:
puppet config set modulepath c:/phx_deployer/puppet/modules
puppet config set hiera_config c:/phx_deployer/puppet/hiera.yaml
我还跑了" puppet config print"并从两台机器上捕获输出并在其上使用diff程序。唯一不同的设置与安全证书,IP地址和计算机名称相关。
从消息中可以清楚地看到" puppet应用site.pp"正在查找我的mirrored_directory定义类型的错误位置。它正在寻找标准的木偶位置,而不是我的目录树。我缺少什么设置?
注:
c:\>puppet --version
3.4.3 (Puppet Enterprise 3.2.3)
c:\>ruby --version
ruby 1.9.3p484 (2013-11-22) [i386-mingw32]
更新:
原因是:我的mirrored_directory类型的自定义类型提供程序代码需要rubyzip。我声明了对rubyzip包的依赖,但它永远不会超过编译阶段。
在nodes.pp中:
package { 'rubyzip':
ensure => 'latest',
provider => 'gem',
}
在tf_package的init.pp中:
...
mirrored_directory { $package_dir:
source => "${staging_dir}/${specific_version_label}/${zip_filename}",
ensure => 'present',
do_deletes => $do_deletes,
exclude => $exclude,
include => $include,
require => [Package['rubyzip'],File[$package_dir]],
prefix_depth => $prefix_depth
}
...
我对包有依赖性,但这还不够。如何构建一个木偶解决方案,以便您可以制作木偶安装宝石,而不是由您的应用程序而是由木偶类型本身所需?
更新:这是木偶申请的输出:
c:\phx_deployer\puppet\manifests>puppet apply site.pp --debug
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/concat_basedir.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/custom_auth_conf.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/facter_dot_d.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/ip6tables_version.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/iptables_persistent_version.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/iptables_version.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/pe_build.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/pe_postgres_default_version.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/pe_puppetdb_server_status.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/pe_version.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/postgres_default_version.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/puppet_vardir.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/root_home.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/staging_http_get.rb
Info: Loading facts in C:/ProgramData/PuppetLabs/puppet/var/lib/facter/windows.rb
Debug: importing 'c:/phx_deployer/puppet/manifests/nodes.pp' in environment production
Debug: importing 'c:/phx_deployer/puppet/modules/dotnet/manifests/init.pp' in environment production
Debug: importing 'c:/phx_deployer/puppet/modules/dotnet/manifests/v4_5_1.pp' in environment production
Debug: Automatically imported dotnet::v4_5_1 from dotnet/v4_5_1 into production
Debug: hiera(): Hiera YAML backend starting
Debug: hiera(): Looking up dotnet::v4_5_1::version in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found dotnet::v4_5_1::version in deployer_windows
Debug: hiera(): Looking up dotnet::v4_5_1::installer in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found dotnet::v4_5_1::installer in deployer_windows
Debug: hiera(): Looking up dotnet::v4_5_1::temp_dir in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found dotnet::v4_5_1::temp_dir in deployer_windows
Debug: hiera(): Looking up phoenix::packages in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found phoenix::packages in deployer_windows
Debug: hiera(): Looking up phoenix::repository_dir in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found phoenix::repository_dir in deployer_windows
Debug: hiera(): Looking up phoenix::staging_dir in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found phoenix::staging_dir in deployer_windows
Debug: hiera(): Looking up phoenix::deployment_dir in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found phoenix::deployment_dir in deployer_windows
Debug: hiera(): Looking up phoenix::collection_name in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found phoenix::collection_name in deployer_windows
Debug: hiera(): Looking up phoenix::version_type in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found phoenix::version_type in deployer_windows
Debug: hiera(): Looking up phoenix::version_label in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found phoenix::version_label in deployer_windows
Debug: importing 'c:/phx_deployer/puppet/modules/tf_package/manifests/init.pp' in environment production
Debug: Automatically imported tf_package from tf_package into production
Debug: Failed to load library 'selinux' for feature 'selinux'
Debug: hiera(): Looking up tf_server in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found tf_server in deployer_windows
Debug: hiera(): Looking up tf_port in YAML backend
Debug: hiera(): Looking for data source deployer_USB-TG2008R2T1.ef.com
Debug: hiera(): Cannot find datafile c:/phx_deployer/puppet/deployer_USB-TG2008R2T1.ef.com.yaml, skipping
Debug: hiera(): Looking for data source deployer_windows
Debug: hiera(): Found tf_port in deployer_windows
Debug: importing 'c:/phx_deployer/puppet/modules/tfview/manifests/init.pp' in environment production
Debug: Automatically imported tfview from tfview into production
Error: Could not autoload puppet/provider/mirrored_directory/zip: cannot load such file -- zip
Error: Could not autoload puppet/type/mirrored_directory: Could not autoload puppet/provider/mirrored_directory/zip: cannot load such file -- zip
Error: Could not autoload puppet/type/mirrored_directory: Could not autoload puppet/provider/mirrored_directory/zip: cannot load such file -- zip on node usb-tg
2008r2t1.ef.com
Error: Could not autoload puppet/type/mirrored_directory: Could not autoload puppet/provider/mirrored_directory/zip: cannot load such file -- zip on node usb-tg
2008r2t1.ef.com
我的ruby模块zipinstall.rb的第一行。要求' zip'需要宝石rubyzip:
require 'rubygems'
require 'zip'
此代码又包含在我的提供者代码zip.rb中:
# Resource Type: mirrored_directory
# Provider: zip
#
# Provides the interface between the Puppet custom resource type 'mirrored_directory'
# and the ruby class 'ZipInstall::Unzipper'.
# This permits missing or changed files to be extracted from a Zip archive on a Windows system,
# while unchanged files are left alone.
require 'puppet/provider/mirrored_directory/zip/zipinstall'
Puppet::Type.type(:mirrored_directory).provide :zip do
desc "Uses rubyzip to extract new or modified files from a zip archive on a Windows system."
confine :osfamily => :windows
defaultfor :osfamily => :windows
include Puppet::Util::Warnings
# The mirrored_directory resource exists iff the target directory exists.
def exists?
Puppet::FileSystem::File.exist?(@resource[:name])
end
# Assuming that the target directory is empty (or only contains excluded files),
# extract all included files from the source archive and deposit them in the target directory
# (or corresponding subdirectory).
# Do not delete any files.
def create
Puppet::Util::Log.new(:level => :debug, :message => "create: About to unzip #{@resource[:source]}")
change_count = unzipper.extract(false)
@property_hash[:ensure] = exists? ? :present : :absent
end
# Delete the contents of the target directory and subdirectories
# (other than those that are excluded).
def destroy
change_count = unzipper.delete
@property_hash.clear
end
# Check if the files in the target directory match those in the source zip archive or not.
def is_current
Puppet::Util::Log.new(:level => :debug, :message => "is_current: About to examine #{@resource[:source]}")
!unzipper.has_differences?(false)
end
# Extract each file from the source archive that differs from the corresponding file
# in the target directory.
# Optionally delete files found in the target directory but not in the source archive,
# according to the parameter :do_deletes.
def is_current=(value)
unzipper_to_use = unzipper
changes = unzipper_to_use.differences(false, false)
count = unzipper_to_use.apply_changes(changes, @resource[:do_deletes])
@property_hash[:is_current] = value
0
end
# TODO: Search computer for all installed directories so that the installed
# mirrored_directory resource instances can be queried by puppet.
def self.instances
[]
end
# Construct a new Unzipper, using these parameters supplied to the resource type:
# :source, :name, :exclude, :include
# Supplies a logger that delegate to puppet's own logging.
def unzipper
# Puppet has numerous loggin levels, including:
# :crit, :err, :warning, :notice, :info, :debug
logger = ->(level,message) {
Puppet::Util::Log.new(:level => level, :message => message)
}
ZipInstall::Unzipper.new(@resource[:source], @resource[:name], :prefix_depth => @resource[:prefix_depth], :exclude_files => @resource[:exclude], :include_files => @resource[:include], :logger => logger)
end
end
答案 0 :(得分:1)
输出
错误:无法自动加载puppet / provider / mirrored_directory / zip:无法加载此类文件 - zip
似乎表明系统中缺少zip
实用程序,或者Puppet无法找到它。