Mohamed Lrhazi
2012-Mar-01 17:28 UTC
[Puppet Users] How to use create_resources with a define
I have not used the create_resources function before, looks like
exactly what I need indeed.
How do I use it with a define.. my ENC outputs something like:
nfs_mounts:
- mount_point: "/data"
mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test"
- mount_point: "/data2"
mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test2"
Then in my manifests:
class gu_misc {
...
define mount_nfs_shares(
$mount_point,
$mount_device) {
file{ $mout_point: ensure => directory }
mount { $mount_point:
device => $mount_device,
name => $mount_point,
require => File[$mount_point],
}
}
create_resources(gu_misc::mount_nfs_shares, $nfs_mounts)
}
I get error: undefined method `[]'' for nil:NilClass
Thanks a lot,
Mohamed.
--
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.
Gary Larizza
2012-Mar-01 17:39 UTC
Re: [Puppet Users] How to use create_resources with a define
I would do something like this:
** In your YAML file
---
nfs_mounts
mount1:
mount_point : ''/data''
mount_device : "fas3319-518.example.com:/vol/onecrddb_data/test"
mount2:
mount_point : "/data2"
mount_device : "fas3319-518.example.com:/vol/onecrddb_data/test2"
** In site.pp
$nfs_mounts = hiera_hash(''nfs_mounts'')
create_resources(gu_misc::mount_nfs_shares, $nfs_mounts)
On Thu, Mar 1, 2012 at 9:28 AM, Mohamed Lrhazi <lrhazi@gmail.com> wrote:
> I have not used the create_resources function before, looks like
> exactly what I need indeed.
>
> How do I use it with a define.. my ENC outputs something like:
>
> nfs_mounts:
> - mount_point: "/data"
> mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test"
> - mount_point: "/data2"
> mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test2"
>
>
> Then in my manifests:
>
>
> class gu_misc {
> ...
>
> define mount_nfs_shares(
> $mount_point,
> $mount_device) {
>
> file{ $mout_point: ensure => directory }
> mount { $mount_point:
> device => $mount_device,
> name => $mount_point,
> require => File[$mount_point],
> }
> }
>
> create_resources(gu_misc::mount_nfs_shares, $nfs_mounts)
>
> }
>
> I get error: undefined method `[]'' for nil:NilClass
>
>
> Thanks a lot,
> Mohamed.
>
> --
> 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.
>
>
--
Gary Larizza
Professional Services Engineer
Puppet Labs
--
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.
Tim Mooney
2012-Mar-01 18:12 UTC
Re: [Puppet Users] How to use create_resources with a define
In regard to: [Puppet Users] How to use create_resources with a define,...:> I have not used the create_resources function before, looks like > exactly what I need indeed. > > How do I use it with a define.. my ENC outputs something like: > > nfs_mounts: > - mount_point: "/data" > mount_device: "fas3319-518.example.com:/vol/onecrddb_data/test" > - mount_point: "/data2" > mount_device: "fas3319-518.example.com:/vol/onecrddb_data/test2"I''m pretty new to puppet, but a (more experienced) coworker and I just ran into something nearly identical with hiera/YAML a couple days ago. I believe the issue is that your ENC is outputting an array, not a hash, and create_resources works on hashes. If you can get your ENC to output a hash, you''ll likely have better luck.> class gu_misc { > ... > > define mount_nfs_shares( > $mount_point, > $mount_device) { > > file{ $mout_point: ensure => directory } > mount { $mount_point: > device => $mount_device, > name => $mount_point, > require => File[$mount_point], > } > } > > create_resources(gu_misc::mount_nfs_shares, $nfs_mounts) > > } > > I get error: undefined method `[]'' for nil:NilClassTim -- Tim Mooney Tim.Mooney@ndsu.edu Enterprise Computing & Infrastructure 701-231-1076 (Voice) Room 242-J6, IACC Building 701-231-8541 (Fax) North Dakota State University, Fargo, ND 58105-5164 -- 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.
Mohamed Lrhazi
2012-Mar-01 18:41 UTC
Re: [Puppet Users] How to use create_resources with a define
Thanks guys. The hash thing sounds like my problem... but I still get
the same error!!
undefined method `[]'' for nil:NilClass at
/etc/puppet/environments/production_ml623/modules/gu_misc/manifests/init.pp:81
on node onecrddb-test-1
where line 81 is:
create_resources(mount_nfs_shares, $nfs_mounts)
I tried, with same error:
create_resources(gu_misc::mount_nfs_shares, $nfs_mounts)
What else am I missing ?
Thanks a lot,
Mohamed.
On Thu, Mar 1, 2012 at 1:12 PM, Tim Mooney <Tim.Mooney@ndsu.edu>
wrote:> In regard to: [Puppet Users] How to use create_resources with a define,...:
>
>
>> I have not used the create_resources function before, looks like
>> exactly what I need indeed.
>>
>> How do I use it with a define.. my ENC outputs something like:
>>
>> nfs_mounts:
>> - mount_point: "/data"
>> mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test"
>> - mount_point: "/data2"
>> mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test2"
>
>
> I''m pretty new to puppet, but a (more experienced) coworker and I
just
> ran into something nearly identical with hiera/YAML a couple days ago.
>
> I believe the issue is that your ENC is outputting an array, not a hash,
> and create_resources works on hashes.
>
> If you can get your ENC to output a hash, you''ll likely have
better luck.
>
>
>> class gu_misc {
>> ...
>>
>> define mount_nfs_shares(
>> $mount_point,
>> $mount_device) {
>>
>> file{ $mout_point: ensure => directory }
>> mount { $mount_point:
>> device => $mount_device,
>> name => $mount_point,
>> require => File[$mount_point],
>> }
>> }
>>
>> create_resources(gu_misc::mount_nfs_shares, $nfs_mounts)
>>
>> }
>>
>> I get error: undefined method `[]'' for nil:NilClass
>
>
> Tim
> --
> Tim Mooney Tim.Mooney@ndsu.edu
> Enterprise Computing & Infrastructure 701-231-1076
(Voice)
> Room 242-J6, IACC Building 701-231-8541 (Fax)
> North Dakota State University, Fargo, ND 58105-5164
>
>
> --
> 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.
>
--
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.
Mohamed Lrhazi
2012-Mar-01 20:38 UTC
Re: [Puppet Users] How to use create_resources with a define
Ooops... My yaml was wrong.. it said:
nfs_mounts:
- mount1:
mount_point: "/data"
mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test"
- mount2:
mount_point: "/data2"
mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test2"
Instead of:
nfs_mounts:
mount1:
mount_point: "/data"
mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test"
mount2:
mount_point: "/data2"
mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test2"
Thanks all,
Mohamed.
On Thu, Mar 1, 2012 at 1:41 PM, Mohamed Lrhazi <lrhazi@gmail.com>
wrote:> Thanks guys. The hash thing sounds like my problem... but I still get
> the same error!!
>
> undefined method `[]'' for nil:NilClass at
>
/etc/puppet/environments/production_ml623/modules/gu_misc/manifests/init.pp:81
> on node onecrddb-test-1
>
> where line 81 is:
>
> create_resources(mount_nfs_shares, $nfs_mounts)
>
> I tried, with same error:
>
> create_resources(gu_misc::mount_nfs_shares, $nfs_mounts)
>
>
> What else am I missing ?
>
> Thanks a lot,
> Mohamed.
> On Thu, Mar 1, 2012 at 1:12 PM, Tim Mooney <Tim.Mooney@ndsu.edu>
wrote:
>> In regard to: [Puppet Users] How to use create_resources with a
define,...:
>>
>>
>>> I have not used the create_resources function before, looks like
>>> exactly what I need indeed.
>>>
>>> How do I use it with a define.. my ENC outputs something like:
>>>
>>> nfs_mounts:
>>> - mount_point: "/data"
>>> mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test"
>>> - mount_point: "/data2"
>>> mount_device:
"fas3319-518.example.com:/vol/onecrddb_data/test2"
>>
>>
>> I''m pretty new to puppet, but a (more experienced) coworker
and I just
>> ran into something nearly identical with hiera/YAML a couple days ago.
>>
>> I believe the issue is that your ENC is outputting an array, not a
hash,
>> and create_resources works on hashes.
>>
>> If you can get your ENC to output a hash, you''ll likely have
better luck.
>>
>>
>>> class gu_misc {
>>> ...
>>>
>>> define mount_nfs_shares(
>>> $mount_point,
>>> $mount_device) {
>>>
>>> file{ $mout_point: ensure => directory }
>>> mount { $mount_point:
>>> device => $mount_device,
>>> name => $mount_point,
>>> require => File[$mount_point],
>>> }
>>> }
>>>
>>> create_resources(gu_misc::mount_nfs_shares, $nfs_mounts)
>>>
>>> }
>>>
>>> I get error: undefined method `[]'' for nil:NilClass
>>
>>
>> Tim
>> --
>> Tim Mooney
Tim.Mooney@ndsu.edu
>> Enterprise Computing & Infrastructure 701-231-1076
(Voice)
>> Room 242-J6, IACC Building 701-231-8541
(Fax)
>> North Dakota State University, Fargo, ND 58105-5164
>>
>>
>> --
>> 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.
>>
--
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.