Hi,
How to use a shell script from packer server to run on provisioner also followed by the waagent deprovision inline command for Azure.
When I tried, I got an error saying packer allows either of one.
If I restrict to just script, the provisioner completes and the image gets created. But im unable to login to the deployed VMs from this image. It says invalid login method ( May be its with key or something ).
Am I missing something. Please help.
Thanks & Regards,
JD
Hi ,
Just to add up the lines for quick reference,
“provisioners”: [{
“type”: “shell”,
“script”: “/packer/templates/scripttest.sh”
}]
and my script that needs to run on the image provisioned my packer has
< tasks >
“/usr/sbin/waagent -force -deprovision && export HISTSIZE=0 && sync”
I tried even the above but it pops error saying the waagent is not found.
So I tried the provisioner like this
“provisioners”: [{
“type”: “shell”,
“script”: “/packer/templates/scripttest.sh”
“execute_command”: “chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh ‘{{ .Path }}’”,
“inline”: [
“/usr/sbin/waagent -force -deprovision && export HISTSIZE=0 && sync”
],
“inline_shebang”: “/bin/bash -x”
}]
And this was the one causing an error saying both cannot be defined at the same time.
Im sure im missing something here … How would I achieve both waagent deprovision and also my script to run on provisioning
Thanks & Regards,
JD
Hi,
No worries. I think I found the right way of using this. My bad.
For those who have similar struggles, probably this should help you out.
“provisioners”:
[
{
“type”: “shell”,
“script”: “/packer/templates/scripttest.sh”
},
{
“execute_command”: “chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh ‘{{ .Path }}’”,
“inline_shebang”: “/bin/bash -x”,
“type”: “shell”,
“inline”: [
“/usr/sbin/waagent -force -deprovision && export HISTSIZE=0 && sync”
]
}
]
Thanks & Regards,
JD