Hey all, I''m running puppet 2.7.3 on CentOS, and am trying to use the new create_resources function. I have a class that looks like this: scp_account($userid, $unixid, $password) { ..... } and I''m trying to call it with a hash of parameters like so: # Create a hash of the scp accounts $scp_accounts = { ''joe'' => {userid => ''joe'', unixid => ''700'', password => ''$1$sdfasdfasdfasdfsdaf''}, ''bob'' => {userid => ''bob'', unixid => ''701'', password => ''$1$asdfsdfsadfasdfsadf''} } create_resources(''scp_account'', $scp_accounts) However - when I try to run it, I''m getting an error like so: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Must pass userid to Class[Production_scp_accounts::Scp_account] at /etc/puppet/modules/production_scp_accounts/manifests/scp_account.pp:1 I''m sure it''s user error, but I''m having a hard time figuring out exactly what I''m doing wrong. Thanks! -- 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/-/PiHuiZtUZQQJ. 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.
Scott Rankin
2011-Aug-30 15:55 UTC
[Puppet Users] Re: Having trouble with create_resources
Update - the above error was happening because I had left in an "include ''scp_account''" statement at the top. I took that out, but now I''m running into this issue: err: Could not retrieve catalog from remote server: Error 400 on SERVER: could not create resource of unknown type production_scp_accounts::scp_account My directory structure looks like this: modules production_scp_accounts init.pp scp_account.pp The create_resources call is in init.pp, in a class called "production_scp_accounts". scp_account.pp has a class called "production_scp_accounts::scp_account", which I thought would be automatically picked up because I''m following the namespacing rules. Any thoughts? -- 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/-/_tWn21wMHTgJ. 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.
On Tue, Aug 30, 2011 at 11:55 AM, Scott Rankin <sdwr98@gmail.com> wrote:> Update - the above error was happening because I had left in an "include > ''scp_account''" statement at the top. I took that out, but now I''m running > into this issue: > err: Could not retrieve catalog from remote server: Error 400 on SERVER: > could not create resource of unknown type > production_scp_accounts::scp_account > > My directory structure looks like this: > modules > production_scp_accounts > init.pp > scp_account.pp > The create_resources call is in init.pp, in a class called > "production_scp_accounts". scp_account.pp has a class called > "production_scp_accounts::scp_account", which I thought would be > automatically picked up because I''m following the namespacing rules. > Any thoughts?create_resource is for resources, not classes. Also if you change it from a class to a define, the resource name in your example would be: production_scp_acounts:scp_accounts. If you want a custom resource called scp::account, your module layout should be: modules - scp - manifests - account.pp define scp::account { ... } 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.
Scott Rankin
2011-Aug-30 16:17 UTC
Re: [Puppet Users] Re: Having trouble with create_resources
I just figured that out. If I change it to a defined resource, it works. What led me in the wrong direction, though, was this sentence in the function documentation: " This is currently tested for defined resources, classes, as well as native types" I guess that''s not really the case? On Tuesday, August 30, 2011 12:08:58 PM UTC-4, Nan Liu wrote:> > create_resource is for resources, not classes. Also if you change it > from a class to a define, the resource name in your example would be: > production_scp_acounts:scp_accounts. If you want a custom resource > called scp::account, your module layout should be: > > modules > - scp > - manifests > - account.pp > > define scp::account { > ... > } > > Thanks, > > Nan > >-- 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/-/Y2Mqs6v58IMJ. 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.
On Tue, Aug 30, 2011 at 12:17 PM, Scott Rankin <sdwr98@gmail.com> wrote:> I just figured that out. If I change it to a defined resource, it works. > What led me in the wrong direction, though, was this sentence in the > function documentation: > " This is currently tested for defined resources, classes, as well as native > types" > > I guess that''s not really the case?I need to be more precise about what I write, it will work for a class: class hello_world { notify { "hi": } } create_resource("class", {hello_world}) I should of wrote "in your case, create_resource is intended for resources, not classes." 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.