3

运行 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(服务器和客户端)。有人知道吗?谢谢

4

1 回答 1

4

找到了!

只需将提供程序文件移动到与 type 同名的目录即可。在我的情况下 /etc/puppet/modules/environment/lib/puppet/provider/ volume /ebs.rb

其中environment是我的自定义模块的名称,volume是自定义类型。

于 2012-10-24T10:40:15.573 回答