I am using Packer version 1.4.1
What is the best practice to manage generic templates.
We have a few packer template files for different windows versions. The template's builders section is common and we use var files to pass in any user variables.
The reason we are having to keep multiple json template files is due to the Provisioner sections being different for different types of templates.
Question:
Is there a way we can use the same template file with just the builders section.
For provisioners, we can either put them in a separate file and then somehow inject it into the main tempalte OR
if we can pass in the Provisioners in the form of a json array through a user variable from a variables file?
Some of my provisioners are powershell scripts, ansible and windows restart. Is it possible to pass in provisioners from a variable file like this?
"host_provisioners": [
{
"type": "powershell",
"inline": [
"cmd.exe /c powershell.exe Set-ExecutionPolicy Unrestricted -force",
"a:\\scripts\\Configure-MinorSettings.ps1",
"a:\\scripts\\win2019-setup-ssh.ps1",
"a:\\scripts\\Setup-Docker.ps1"
]
},
{
"type": "windows-restart",
"restart_check_command": "powershell -command \"& {Write-Output 'Guest Restarted Successfully.'}\""
}
]
}Then in the main template file where my builders are, I do this:
"provisioners": "{{user host_provisioners }}"
It seems like you have to put provisioners and builders in the same file. It would be good if we can do on one of the following and if it is already possible:
What is the best practice on structuring and managing multiple templates or making your templates generic? As things stand, it seems impossible to apply DRY principles to Packer.
I'll really appreciate any guidance on this please as our packer scripts and templates are becoming a bit hard to scale and maintain.
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/ea90623a-2da1-453e-969c-0e7c39a04969%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to packe...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/317528bb-11d0-42f8-ad75-e6fcfa9411e0%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CALz9Rt8sZk%2BEQGpFqmaWk_4Tc97n%2BBwwY_EvZ9Yu4LdXBaGvnw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAGzi4%3D66Tn-KO6P3Tdj6qnV0JNj6Q-e4VDwcH583q8MKQL%3Dksg%40mail.gmail.com.