{"id":15099731,"url":"https://github.com/bmatcuk/terraform-provider-vagrant","last_synced_at":"2025-10-18T02:31:43.230Z","repository":{"id":39716900,"uuid":"144865903","full_name":"bmatcuk/terraform-provider-vagrant","owner":"bmatcuk","description":"A Vagrant provider for terraform.","archived":false,"fork":false,"pushed_at":"2023-01-31T02:01:11.000Z","size":81,"stargazers_count":50,"open_issues_count":7,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T23:09:06.113Z","etag":null,"topics":["terraform","terraform-provider","vagrant"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmatcuk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-15T14:47:59.000Z","updated_at":"2024-08-22T19:23:50.000Z","dependencies_parsed_at":"2023-02-05T02:16:35.248Z","dependency_job_id":null,"html_url":"https://github.com/bmatcuk/terraform-provider-vagrant","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmatcuk%2Fterraform-provider-vagrant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmatcuk%2Fterraform-provider-vagrant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmatcuk%2Fterraform-provider-vagrant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmatcuk%2Fterraform-provider-vagrant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmatcuk","download_url":"https://codeload.github.com/bmatcuk/terraform-provider-vagrant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975315,"owners_count":21192210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["terraform","terraform-provider","vagrant"],"created_at":"2024-09-25T17:26:46.885Z","updated_at":"2025-10-18T02:31:43.113Z","avatar_url":"https://github.com/bmatcuk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Release](https://img.shields.io/github/release/bmatcuk/terraform-provider-vagrant.svg?branch=master)\n[![Build Status](https://github.com/bmatcuk/terraform-provider-vagrant/actions/workflows/release.yml/badge.svg)](https://github.com/bmatcuk/terraform-provider-vagrant/actions/workflows/release.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bmatcuk/terraform-provider-vagrant)](https://goreportcard.com/report/github.com/bmatcuk/terraform-provider-vagrant)\n\n# terraform-provider-vagrant\nA Vagrant provider for terraform 0.12+.\n\nA note about lippertmarkus/vagrant in the registry: when I originally wrote\nthis provider, the terraform registry didn't exist. My terraform needs waned\nand I didn't hear about the registry until some time later. lippertmarkus\nforked my provider and published to the registry as a convenience. Thanks! But,\nit's just an older version of this exact same codebase. So, I recommend you use\nbmatcuk/vagrant to get the latest updates instead.\n\n## Installation\nAdd bmatcuk/vagrant to [required_providers]:\n\n```hcl\nterraform {\n  required_providers {\n    vagrant = {\n      source  = \"bmatcuk/vagrant\"\n      version = \"~\u003e 4.0.0\"\n    }\n  }\n}\n```\n\n## Usage\n```hcl\nresource \"vagrant_vm\" \"my_vagrant_vm\" {\n  name = \"vagrantbox\"\n  vagrantfile_dir = \"path/to/dir\"\n  env = {\n    KEY = \"value\",\n  }\n  get_ports = true\n}\n```\n\n**name** (optional) if the name changes, it will force the resource to destroy\nand recreate. Defaults to \"vagrantbox\".\n\n**vagrantfile_dir** is the path to a directory where a Vagrantfile lives. The\nVagrantfile must exist when terraform runs or else it will throw an error. This\noption defaults to `.`, ie, the current directory and you may set this value to\nabsolute or relative paths.\n\n**env** (optional) is a map of additional environment variables to pass to the\nVagrantfile. The environment variables set by the calling process are always\npassed.\n\n**get_ports** (optional) if `true`, information about forwarded ports will be\nfilled in (see `ports` below). This is `false` by default because it may take\nsome time to run.\n\nIf you have multiple Vagrantfiles, provide an `alias` in the `provider` block\nand use the `provider` meta-argument in the resource/data-source\nconfigurations.\n\n### Outputs\n* `machine_names.#` - a list of machine names as defined in the Vagrantfile.\n* `ssh_config.#` - SSH connection info. Since a Vagrantfile may create multiple\n  machines, this is a list with the following variables:\n\n  * `ssh_config.*.type` - always \"ssh\" for now\n  * `ssh_config.*.user` - the user for the connection\n  * `ssh_config.*.host` - the address to connect to\n  * `ssh_config.*.port` - the port to connect to\n  * `ssh_config.*.private_key` - private ssh key for the connection\n  * `ssh_config.*.agent` - whether or not to use the agent for authentication\n    (always \"false\" for now).\n\n  If there is only one machine built by the Vagrantfile, the connection info\n  will be set in the `resource` block so you can include provisioners without\n  any additional configuration. However, if there is more than one machine, the\n  connection info will not be set; you'll need to create some `null_resources`\n  to do your provisioning.\n* `ports.#` - information about forwarded ports if `get_ports` is `true`. This\n  is a list of lists: for each machine in the Vagrantfile, `ports` will have a\n  list with the following variables:\n\n  * `ports.*.*.guest` - the port on the guest VM\n  * `ports.*.*.host` - the host port forwarded to the guest VM\n\nNote that `machine_names`, `ssh_config`, and `ports` are guaranteed to be in\nthe same order (ie, `ssh_config[0]` is the corresponding config for the machine\nnamed `machine_names[0]`), but the order is undefined (ie, don't count on\n`machine_names[0]` being the first machine defined in the Vagrantfile).\n\n## Forcing an Update\nThe easiest way to force an update is to set, or change the value of, some\nenvironment variable. This will signal to terraform that the vagrant_vm\nresource needs to update.\n\nFor example, if you want to force updates when your Vagrantfile changes, try\nsomething like this:\n\n```hcl\nresource \"vagrant_vm\" \"my_vagrant_vm\" {\n  vagrantfile_dir = \"path/to/dir\"\n  env = {\n    VAGRANTFILE_HASH = md5(file(\"path/to/dir/Vagrantfile\")),\n  }\n}\n```\n\nWhen the file changes, the hash will change, and terraform will ask for an\nupdate.\n\n### Really Forcing an Update\nChanging an environment variable, as suggested above, essentially runs `vagrant\nreload`. Sometimes this isn't enough. If the resource's `name` changes, it will\nsignal to terraform that it needs to completely destroy the resource and\nrecreate it.\n\n## Removing Machines\nSadly, due to some limitations in vagrant, it's not possible to automatically\nremove a portion of machines from a Vagrantfile. In other words, if your\nVagrantfile defines 5 machines and you remove 2 of them from the Vagrantfile,\nthey will be left running in your vagrant provider (ie, virtualbox or whatever)\nwith no way of removing them via vagrant (or terraform).\n\nIf you intend of removing some machines, you should manually run `vagrant\ndestroy MACHINE_NAME` on those machines you wish to remove *before* editing the\nVagrantfile. Then update your Vagrantfile and allow terraform to do the rest.\n\nIf you forget, you can manually cleanup these old VMs by launching your vagrant\nprovider's UI and deleting the machines. Then run `vagrant global-status\n--prune` to cleanup vagrant's cache of these machines.\n\n## Debugging\nIf terrafrom is failing on the vagrant step, you can get additional output by\nrunning terraform with logging output enabled. Try something like:\n\n```bash\nenv TF_LOG=TRACE terraform apply ...\n```\n\nAnd, of course, you can always run vagrant on your Vagrantfile directly.\n\n## Local Development\nThe example in `examples/resources/vagrant_vm` is fully functioning, but you'll\nneed to compile this provider and put it in a place terraform can find it:\n\n```bash\ngo build\nmkdir -p examples/resources/vagrant_vm/terraform.d/plugins/registry.terraform.io/bmatcuk/vagrant/4.0.0/darwin_amd64\nmv terraform-provider-vagrant examples/resources/vagrant_vm/terraform.d/plugins/registry.terraform.io/bmatcuk/vagrant/4.0.0/darwin_amd64/\ncd examples/resources/vagrant_vm\nterraform init\nterraform apply\n```\n\nAdjust `darwin_amd64` to match your system.\n\n[required_providers]: https://www.terraform.io/docs/language/providers/requirements.html#requiring-providers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmatcuk%2Fterraform-provider-vagrant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmatcuk%2Fterraform-provider-vagrant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmatcuk%2Fterraform-provider-vagrant/lists"}