"provisioners" : [
{
"type": "file",
"source": "myawesomescript.sh",
"destination": "/root"
},
{
"type": "shell",
"execute_command": "sh '{{ .Path }}'",
"inline": [
"bash /root/myawesomescript.sh arg1"
]
}
],
Just make sure you are copying to a directory that does exist.
Do you see execute_command? is a powerful option.
Path B feels hacky, but 100% valid
"provisioners" : [
{
"type": "shell",
"execute_command": "echo 'vagrant'| {{ .Vars }} sudo -E -S bash '{{.Path}}' arg1",
"pause_before": "1s",
"scripts": [
"scripts/vagrant.sh"
]
}]
Path C
OR, you could use:
create a variable arguments
"variables": {
"arguments": "arg1"
}
And use
"execute_command": "echo 'vagrant'| {{ .Vars }} sudo -E -S bash '{{.Path}}' '{{user `arguments`}}' " ,
Advantage of this one, is you can override that at run time.
packer build -var "argument=the_new_argument" template.json
Hope this helps.
Alvaro.
--
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/0dc27455-8fba-41eb-af4c-8994e69e5ea7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.