# Packer Vagrant builder - confused about Vagrant template option

**URL:** <https://discuss.hashicorp.com/t/packer-vagrant-builder-confused-about-vagrant-template-option/22238>\
**Category:** Packer\
**Created:** [March 19, 2021, 4:49am UTC](https://discuss.hashicorp.com/t/packer-vagrant-builder-confused-about-vagrant-template-option/22238 "2021-03-19T04:49:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aleksf](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/aleksf/32/13975_2.png) [@aleksf](https://discuss.hashicorp.com/u/aleksf)\
**Post date:** [March 19, 2021, 4:49am UTC](https://discuss.hashicorp.com/t/packer-vagrant-builder-confused-about-vagrant-template-option/22238/1 "2021-03-19T04:49:07Z")

</div>

Versions I am using:

- Vagrant 2.2.14
- Packer v1.7.0

I could be misreading the documentation, but packer vagrant builder options I tried so far did not end up in producing desired result. All I am after is to have my custom Vagrantfile embedded into produced box.

I need it for obvious reasons to control some of the networking options. I could mandate for users to manually copy Vagrantfile before doing vagrant up, but the issue is I can’t rely on users following the process, so I’d like to enforce it at the box init by default.

I tried to use vagrant builder’s options below:  
[Vagrant - Builders | Packer by HashiCorp](https://www.packer.io/docs/builders/vagrant#output_vagrantfile) and [Vagrant - Builders | Packer by HashiCorp](https://www.packer.io/docs/builders/vagrant#template) but none of them achieved desired result. At vagrant init default Vagrantfile is still populated.

---

<div class="post-metadata">

**Author:** ![aleksf](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/aleksf/32/13975_2.png) [@aleksf](https://discuss.hashicorp.com/u/aleksf)\
**Post date:** [March 19, 2021, 5:08am UTC](https://discuss.hashicorp.com/t/packer-vagrant-builder-confused-about-vagrant-template-option/22238/2 "2021-03-19T05:08:49Z")

</div>

I came across this post - [virtualbox - Packaging a base box with a custom Vagrantfile - Stack Overflow](https://stackoverflow.com/questions/14861604/packaging-a-base-box-with-a-custom-vagrantfile) referencing config load order.

Packer template I am using:

```auto
{
    "builders": [{
        "communicator": "ssh",
        "source_path": "analysis",
        "provider": "vmware_desktop",
        "skip_add": true,
        "add_force": true,
        "type": "vagrant",
        "output_vagrantfile": "Vagrantfile.template"
    }],
    "provisioners": [
      {
        "type": "shell",
          "scripts": [
            "./scripts/homebrew-install.sh"
          ]
      },
      {
        "type": "ansible",
          "playbook_file": "./osx-analysis-playbook/main.yml",
          "user": "vagrant",
          "extra_arguments": [
            "--extra-vars",
            "ansible_python_interpreter=/usr/bin/python"
          ]
      },
        {
            "type": "shell",
            "execute_command": "echo 'vagrant' | {{.Vars}} sudo -ES {{.Path}}",
            "scripts": [
                "scripts/post-cleanup.sh"
            ]
        }
    ]
}

```

I noticed after adding produced box there’s a file **~/.vagrant.d/boxes/analysis/0/vmware\_desktop/include/\_Vagrantfile** that contains my custom config, but when I do `vagrant init analysis && vagrant up` I don’t see anything being merged and environment is initialized with default Vagrantfile resulting in undesired networking config.

---

<div class="post-metadata">

**Author:** ![safenetwork-CMTY](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/safenetwork-cmty/32/16286_2.png) [@safenetwork-CMTY](https://discuss.hashicorp.com/u/safenetwork-CMTY)\
**Post date:** [September 27, 2021, 3:28pm UTC](https://discuss.hashicorp.com/t/packer-vagrant-builder-confused-about-vagrant-template-option/22238/3 "2021-09-27T15:28:14Z")

</div>

Did you resolve it?  
I have the same issue right now.

[update]

I solved it.  
My `vagrant up` was giving me an error.
