Details
-
Improvement
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
-
None
-
1
Description
The puppetlabs/powershell module's README makes the excellent recommendation of putting long Powershell scripts into other files rather than having them be long inline commands in the Puppet code.
However, the template() function is shown as the recommended way of evaluating these external files to pass them into an exec resource. I think that we should switch those examples and the recommendations to use the file() function.
It's a bit confusing to use the template() function on something that doesn't have any ERB code in it (as is the case in all of the README's examples). The file() function ends up with the exact same result, and is arguably clearer as it's just "shipping" a file's contents from one place to another. Also, there may be some slight overheard in using the template() function due to its use of the ERB library.
Recommendation
Replace examples like this:
exec { 'rename-guest':
|
command => template('guest/rename-guest.ps1'),
|
onlyif => template('guest/guest-exists.ps1'),
|
provider => powershell,
|
logoutput => true,
|
}
|
... with this:
exec { 'rename-guest':
|
command => file('guest/rename-guest.ps1'),
|
onlyif => file('guest/guest-exists.ps1'),
|
provider => powershell,
|
logoutput => true,
|
}
|
The file() works here because it is able to use the short-hand notation for finding files (e.g. <module_name>/<file_name>), just like the template() function.
Attachments
Issue Links
- links to