defined resource type not working in 2.7.5

94 views
Skip to first unread message

CraftyTech

unread,
Oct 14, 2011, 1:07:14 AM10/14/11
to puppet...@googlegroups.com
Hello All,

     I'm having problems getting a simple defined resource type work.  Here's an example of what I'm trying to run:

class app_deployer2 {
 define fil($ensure) { file {$name:
   content => "this is a test"
   }
 }

 fil { "File1" :ensure => "/tmp/file1" }

 }

#
But when I run it, I keep on geting error:

"err: Failed to apply catalog: Parameter path failed: File paths must be fully qualified, not 'File1' at /etc/puppet/modules/app_deployer2/manifests/init.pp:5"

As far as I can tell, this should work, but is not.  Can anyone see what I'm missing?

Thanks,

CraftyTech

unread,
Oct 14, 2011, 1:19:46 AM10/14/11
to puppet...@googlegroups.com
This is the whole file:
class app_deployer2 {

define fil($ensure= "present", $path) { file {$name:
   content => "this is a test"
   }
 }

fil { "File1": path => "/tmp/file1" }
}

#
and this is the error message I keep on getting:
"err: Failed to apply catalog: Parameter path failed: File paths must be fully qualified, not 'File1' at /etc/puppet/modules/app_deployer2/manifests/init.pp:5"

Thanks,

Rob Sweet

unread,
Oct 14, 2011, 8:20:27 AM10/14/11
to Puppet Users
It looks like you're passing in the path parameter but not using it
within your file declaration inside the define. Without a path, Puppet
needs the name parameter to have a full path. Add 'path => $path' to
your file resource and see if that gets you working.

Rob

Nan Liu

unread,
Oct 14, 2011, 2:59:03 PM10/14/11
to puppet...@googlegroups.com
On Fri, Oct 14, 2011 at 5:20 AM, Rob Sweet <rhs...@gmail.com> wrote:
> It looks like you're passing in the path parameter but not using it
> within your file declaration inside the define. Without a path, Puppet
> needs the name parameter to have a full path. Add 'path => $path' to
> your file resource and see if that gets you working.
>
> Rob
>
> On Oct 14, 12:19 am, CraftyTech <hmmed...@gmail.com> wrote:
>> This is the whole file:
>> class app_deployer2 {
>>
>> define fil($ensure= "present", $path) { file {$name:
>>    content => "this is a test"
>>    }
>>  }

In addition to what Rob mentioned, $name gets translate to the title
of the resource, which is "File1". So if you meant to do support
something similar to puppet resource where you have a namevar and it
defaults to the title, unless you specify namevar (example below is
path) write it this way:

define my_file ($path = $name, $content) {
file { $name:
path => $path,
content => $content,
}
}

This is supported starting 2.6.5+ with the fix of #5061.

Thanks,

Nan

CraftyTech

unread,
Oct 15, 2011, 8:01:44 AM10/15/11
to puppet...@googlegroups.com
that worked.  Thanks,
Reply all
Reply to author
Forward
0 new messages