On Mon, May 23, 2011 at 4:01 PM, MolMorroco <vvitayau@gmail.com>
wrote:> # 1. able to see confirm pluginsync = true works
> $ find /var/lib/puppet/lib/puppet/ -type f
> /var/lib/puppet/lib/puppet/type/custominstall.rb
> /var/lib/puppet/lib/puppet/provider/custominstall/custominstall.rb
>
> # 2. but I still get the following messages
> $ sudo less /var/log/messags
> May 23 17:45:20 dashboard puppet-agent[29951]: (/Stage[main]//
> Node[dashboard.lab.xxx.net]/Custominstall[erlgrey]) Could not
> evaluate: No ability to determine if custominstall exists
puppet-dev is more appropriate for custom types/providers.
> # my site.pp for the node is simple
> $ cat /etc/puppet/manifests/site.pp
> node ''dashboard.lab.xxx.net'' {
> custominstall { "erlgrey":
> ensure => present,
> release => "1551",
> }
> }
>
> # here is the type
> $ cat /etc/puppet/modules/xxx/lib/puppet/type/custominstall.rb
>
> Puppet::Type.newtype(:custominstall) do
> @doc = "Manage custominstall"
>
> feature :installable, "The provider can install packages.",
> :methods => [:install]
> feature :uninstallable, "The provider can uninstall
packages.",
> :methods => [:uninstall]
>
> ensurable do
> desc "What state the package should be in
> [absent,present,installed]."
>
> newvalue(:present, :event => :package_installed) do
> provider.install
> end
>
> newvalue(:absent, :event => :package_removed) do
> provider.uninstall
> end
>
> # Alias the ''present'' value.
> aliasvalue(:installed, :present)
>
> defaultto :installed
> end
>
> newparam(:artifact, :namevar => true) do
> desc "The package name."
> end
>
> newparam(:revision) do
> desc "The package revision."
> end
> end
>
> # here is the provider
> $ cat /etc/puppet/modules/xxx/lib/puppet/provider/custominstall/
> custominstall.rb
> Puppet::Type.type(:custominstall).provide :custominstall do
> commands :curl => "/usr/bin/curl"
>
> def uninstall
> notice "going to uninstall #{@resource[:name]}"
> end
>
> def install
> artifact = @resource[:name]
> file = "/tmp/#{artifact}.xml"
> url = "http://xxx/#{@resource[:revision]}"
> Puppet::Util::SUIDManager.asuser("xxx", "xxx") do
> curl "-o", file, "-C", "-",
"-k", "-s", "--url", url
> end
> end
> end
You specified ensurable but didn''t implement a way for puppet to
detect whether this resource exists. You need to implement something
along the line of:
def self.instances
packages = []
# some way to determine what custominstall resource exists on the system.
end
If you think about how puppet performs changes to the system, it needs
to query the state of the resource current state on the system and it
only performs action when appropriate to change the resource to the
desire state described in your manifests. So implementing the
install/uninstall action is insufficient.
Thanks,
Nan
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.