FAQ
So I'm trying to follow the example in the Pro Puppet book and I'm running
into the issue where "resource" variable is not defined. Looking at the
code for packages, I did something similar but it doesnt work either.

newparam(:type) do
desc "Deprecated form of `provider`."

munge do |value|
warning "'type' is deprecated; use 'provider' instead"
@resource[:provider] = value

@resource[:provider]
end
end

Here is the error I am getting.
*info: Retrieving plugin
notice: /File[/var/lib/puppet/lib/puppet/type/repo.rb]/content: content changed '{md5}ed4323af3135341a4c1510a2a1b06ba7' to '{md5}f383a20a73846a4f1d96002c628e4b17'
info: Loading downloaded plugin /var/lib/puppet/lib/puppet/type/repo.rb
err: Could not load downloaded file /var/lib/puppet/lib/puppet/type/repo.rb: undefined local variable or method `resource' for Puppet::Type::Repo::Provider:Class
info: Redefining repo in Puppet::Type
err: Could not retrieve catalog from remote server: Could not intern from pson: Could not autoload repo: undefined local variable or method `resource' for Puppet::Type::Repo::Provider:Class*
*
*
*Here is my code so far.*
*Puppet::Type.newtype(:repo) do
@doc = "Manage repositories"
ensurable
newparam(:name) do
desc "Name"
isnamevar
end
newproperty(:provider) do
resource[:provider] = :gem
end
newparam(:url) do
desc "Url for repo"
end
newparam(:enable) do
desc "Whether repo is enabled or not"
end
end
*
*
*

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Ek8Cg8uMqlwJ.
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.

Search Discussions

  • Matt at May 22, 2012 at 2:57 pm
    This is with puppet 2.6 and one minor difference was in my code I tried
    both newparam and newproperty to see if it was potentially just a simple
    mistake.
    On Tuesday, May 22, 2012 10:55:19 AM UTC-4, Matt wrote:

    So I'm trying to follow the example in the Pro Puppet book and I'm running
    into the issue where "resource" variable is not defined. Looking at the
    code for packages, I did something similar but it doesnt work either.

    newparam(:type) do
    desc "Deprecated form of `provider`."

    munge do |value|
    warning "'type' is deprecated; use 'provider' instead"
    @resource[:provider] = value

    @resource[:provider]
    end
    end

    Here is the error I am getting.
    *info: Retrieving plugin
    notice: /File[/var/lib/puppet/lib/puppet/type/repo.rb]/content: content changed '{md5}ed4323af3135341a4c1510a2a1b06ba7' to '{md5}f383a20a73846a4f1d96002c628e4b17'
    info: Loading downloaded plugin /var/lib/puppet/lib/puppet/type/repo.rb
    err: Could not load downloaded file /var/lib/puppet/lib/puppet/type/repo.rb: undefined local variable or method `resource' for Puppet::Type::Repo::Provider:Class
    info: Redefining repo in Puppet::Type
    err: Could not retrieve catalog from remote server: Could not intern from pson: Could not autoload repo: undefined local variable or method `resource' for Puppet::Type::Repo::Provider:Class*
    *
    *
    *Here is my code so far.*
    *Puppet::Type.newtype(:repo) do
    @doc = "Manage repositories"
    ensurable
    newparam(:name) do
    desc "Name"
    isnamevar
    end
    newproperty(:provider) do
    resource[:provider] = :gem
    end
    newparam(:url) do
    desc "Url for repo"
    end
    newparam(:enable) do
    desc "Whether repo is enabled or not"
    end
    end
    *
    *
    *
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/R_sF9KAfMUAJ.
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedMay 22, '12 at 2:55p
activeMay 22, '12 at 2:57p
posts2
users1
websitepuppetlabs.com

1 user in discussion

Matt: 2 posts

People

Translate

site design / logo © 2022 Grokbase