[PUP-4411] Allow create_resources() to declare parameterized classes Created: 2015/04/14  Updated: 2016/01/22  Resolved: 2015/04/28

Status: Closed
Project: Puppet
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Normal
Reporter: Lee Lowder Assignee: Lee Lowder
Resolution: Cannot Reproduce Votes: 0
Labels: customer, support
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
Template:
QA Contact: Kurt Wall

 Description   

You should be able to declare parameterized classes via crete_resources().

If you use a hash like:

---
classes:
  testfoo::class2: {}
  testfoo::class1:
    require: Class['testfoo::class2']

and code like:

  $classes = hiera_hash('classes')
  create_resources('class', $classes)

you wind up with an error like:

Invalid relationship: Class[testfoo::class1] { require => Class[testfoo::class2] }, because Class[testfoo::class2] doesn't seem to be in the catalog.

However, specifying the hash in the manifest and using puppet apply works:

# cat ~/test.pp
class test1 { notify { 'test1': } }
class test2 { notify { 'test2': } }
 
$classhash = {
  'test1' => { 'require' => "Class[test2]" },
  'test2' => { }
}
 
create_resources('class', $classhash)
# puppet apply test.pp
Notice: Compiled catalog for pe-372-master.puppetdebug.vlan in environment production in 0.06 seconds
Notice: test2
Notice: /Stage[main]/Test2/Notify[test2]/message: defined 'message' as 'test2'
Notice: test1
Notice: /Stage[main]/Test1/Notify[test1]/message: defined 'message' as 'test1'
Notice: Finished catalog run in 0.23 seconds

QA Risk Analysis

N/A for unreproducible bugs



 Comments   
Comment by Henrik Lindberg [ 2015/04/15 ]

There must be something that makes the hash produced by hiera_hash different from the manually created hash. What happens if the yaml file has this:

    require: "Class[testfoo::class2]"

instead of this:

    require: Class['testfoo::class2']

It should also be easy to assert if a lookup via hiera_hash has the exact same content as the manually created hash.

Comment by Henrik Lindberg [ 2015/04/28 ]

It looks like it works if hiera data is given the correct way. please reopen if that is not the case.

Generated at Sun Aug 09 23:29:24 PDT 2020 using Jira 8.5.2#805002-sha1:a66f9354b9e12ac788984e5d84669c903a370049.