运行puppet puppet agent -t
时出现此错误:
Error: /Stage[main]/Environment/Environment::Createenv[shared2]/Volume[shared2]: Could not evaluate: No ability to determine if volume exists
Error: /Stage[main]/Environment/Environment::Createenv[shared1]/Volume[shared1]: Could not evaluate: No ability to determine if volume exists
这是environment / manifest / init.pp
的代码class environment(){
volume { "${title}":
ensure => present,
location => "/home",
mode => 0750,
owner => "${title}",
group => "env",
device_name => undef,
device_size => 10,
az => undef,
instance_id => undef,
}
}
提供者文件(lib / puppet / provider / ebs.rb):
require 'puppet/resource'
require 'puppet/resource/catalog'
require 'fileutils'
require 'rubygems'
require 'facter'
require 'aws-sdk'
require File.dirname(__FILE__) + '/aws-config'
include Puppet::Util::Volume
include AwsConfig
Puppet::Type.type(:volume).provide(:ebs) do
desc "Create, attach, format and mount EBS volumes"
defaultfor :kernel => "Linux"
def create
az = Facter.value('ec2_placement_availability_zone')
puts "Some code here ..."
end
def destroy
raise NotImplementedError
end
def exists?
return File.directory?(@resource[:name])
end
end
类型(lib / puppet / type / volume.rb):
require 'puppet/type'
Puppet::Type.newtype(:volume) do
@doc = "Create new volume. Limited to EBS volumes"
ensurable do
self.defaultvalues
defaultto :present
end
newparam(:name) do
desc "Name of resource"
isnamevar
end
newparam(:location) do
desc "path to directory where the volume will be mounted"
end
end
Puppet 3.0.1版(服务器和客户端)。任何想法的人?感谢
答案 0 :(得分:3)
发现它!
只需将提供程序文件移动到与类型同名的目录。在我的情况下/ etc / puppet / modules / environment / lib / puppet / provider / volume /ebs.rb
其中 environment 是我的自定义模块的名称, volume 是自定义类型。