Commit f38ed0c6 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

post-processor: Can specify VF template for AWS

parent e5e00213
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
type AWSBoxConfig struct { type AWSBoxConfig struct {
OutputPath string `mapstructure:"output"` OutputPath string `mapstructure:"output"`
VagrantfileTemplate string `mapstructure:"vagrantfile_template"`
} }
type AWSVagrantfileTemplate struct { type AWSVagrantfileTemplate struct {
...@@ -61,7 +62,23 @@ func (p *AWSBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact ...@@ -61,7 +62,23 @@ func (p *AWSBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact
} }
defer vf.Close() defer vf.Close()
t := template.Must(template.New("vagrantfile").Parse(defaultVagrantfile)) vagrantfileContents := defaultAWSVagrantfile
if p.config.VagrantfileTemplate != "" {
f, err := os.Open(p.config.VagrantfileTemplate)
if err != nil {
return nil, err
}
defer f.Close()
contents, err := ioutil.ReadAll(f)
if err != nil {
return nil, err
}
vagrantfileContents = string(contents)
}
t := template.Must(template.New("vagrantfile").Parse(vagrantfileContents))
t.Execute(vf, tplData) t.Execute(vf, tplData)
vf.Close() vf.Close()
...@@ -79,7 +96,7 @@ func (p *AWSBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact ...@@ -79,7 +96,7 @@ func (p *AWSBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact
return NewArtifact("aws", p.config.OutputPath), nil return NewArtifact("aws", p.config.OutputPath), nil
} }
var defaultVagrantfile = ` var defaultAWSVagrantfile = `
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
config.vm.provider "aws" do |aws| config.vm.provider "aws" do |aws|
{{ range $region, $ami := .Images }} {{ range $region, $ami := .Images }}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment