puppetlabs / puppetlabs/puppetlabs-stdlib
stdlib::manage: "Illegal Resource Type expression, got String" when using file resource type
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 349
- Forks
- 573
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 1
Description
Describe the Bug
In manifests/manage.pp line 107, the file (and concat::fragment) branch declares resources using a String variable as the resource type:
$type { $title:
* => $attributes - 'erb' - 'epp' - 'content',
content => $content,
}
Puppet rejects this with:
Evaluation Error: Illegal Resource Type expression, expected result to be a type name, or untitled Resource, got String
The default branch already handles this correctly via create_resources(), but the file/concat::fragment branch does not.
Expected Behavior
Defining a file resource via stdlib::manage::create_resources in Hiera (e.g. stdlib::manage::create_resources: file: ...) should successfully create the resource without a catalog compilation error.
Steps to Reproduce
- Upgrade puppetlabs-stdlib to 10.0.0
- Add a stdlib::manage::create_resources entry with type file in node Hiera:
stdlib::manage::create_resources:
file:
'blocklist.acl':
content: |
1.2.3.4
5.6.7.8
mode: '0644'
- Run puppet agent on that node
Environment
- Version: 10.0.0
- Platform: Ubuntu 24.04
Additional Context
The default branch on line 113 uses create_resources($type, { $title => $attributes }) and works correctly. The file/concat::fragment branch should do the same, passing the computed $content merged into the attributes hash rather than using a dynamic resource type expression.
Claude provided me with this proposed diff. My environment doesn't have instances of stdlib::manage::create_resources using epp or erb files to test with so I'm not submitting a PR.
--- a/manifests/manage.pp
+++ b/manifests/manage.pp
@@ -104,9 +104,7 @@ class stdlib::manage (
} else {
$content = undef
}
- $type { $title:
- * => $attributes - 'erb' - 'epp' - 'content',
- content => $content,
- }
+ create_resources($type, { $title => $attributes - 'erb' - 'epp' - 'content' + { 'content' => $content } })
}
default: {
create_resources($type, { $title => $attributes })
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in manifests/manage.pp around line 107 and reproduce the issue with the provided stdlib::manage::create_resources Hiera entry for a file resource. Run Puppet on the Ubuntu example and confirm compilation succeeds for file and concat::fragment resources, including the computed content and attributes.
Written by the indexing model from the issue text.
Assessment
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100