Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed Apr 4, 2021
1 parent e335c24 commit 04e9999
Show file tree
Hide file tree
Showing 13 changed files with 294 additions and 14 deletions.
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
![Release](https://img.shields.io/github/release/bmatcuk/terraform-provider-vagrant.svg?branch=master)
[![Build Status](https://travis-ci.com/bmatcuk/terraform-provider-vagrant.svg?branch=master)](https://travis-ci.com/bmatcuk/terraform-provider-vagrant)
[![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)
[![Go Report Card](https://goreportcard.com/badge/github.com/bmatcuk/terraform-provider-vagrant)](https://goreportcard.com/report/github.com/bmatcuk/terraform-provider-vagrant)

# terraform-provider-vagrant
A Vagrant provider for terraform.

A note about lippertmarkus/vagrant in the registry: when I originally wrote
this provider, the terraform registry didn't exist. My terraform needs waned
and I didn't hear about the registry until some time later. lippertmarkus
forked my provider and published to the registry as a convenience. Thanks! But,
it's just an older version of this exact same codebase. So, I recommend you use
bmatcuk/vagrant to get the latest updates instead.

## Installation
Download [the latest release] for your appropriate OS and architecture and
extract the archive. Then copy the binary to [the terraform plugin directory].
Add bmatcuk/vagrant to [required_providers]:

```hcl
terraform {
required_providers {
vagrant = {
source = "bmatcuk/vagrant"
version = "~> 3.0.0"
}
}
}
```

## Usage
```hcl
Expand Down Expand Up @@ -96,5 +113,4 @@ env TF_LOG=TRACE terraform apply ...

And, of course, you can always run vagrant on your Vagrantfile directly.

[the latest release]: https://github.com/bmatcuk/terraform-provider-vagrant/releases/latest
[the terraform plugin directory]: https://www.terraform.io/docs/configuration/providers.html#third-party-plugins
[required_providers]: https://www.terraform.io/docs/language/providers/requirements.html#requiring-providers
50 changes: 50 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
page_title: "Provider: Vagrant"
description: |-
Integrate vagrant into terraform.
---

# Vagrant Provider
A Vagrant provider for terraform.

A note about lippertmarkus/vagrant in the registry: when I originally wrote
this provider, the terraform registry didn't exist. My terraform needs waned
and I didn't hear about the registry until some time later. lippertmarkus
forked my provider and published to the registry as a convenience. Thanks! But,
it's just an older version of this exact same codebase. So, I recommend you use
bmatcuk/vagrant to get the latest updates instead.

## Installation
Add bmatcuk/vagrant to [required_providers](https://www.terraform.io/docs/language/providers/requirements.html#requiring-providers):

```terraform
terraform {
required_providers {
vagrant = {
source = "bmatcuk/vagrant"
version = "~> 3.0.0"
}
}
}
```

## Example Usage

```terraform
provider "vagrant" {
# no config
}
```

<!-- schema generated by tfplugindocs -->
## Schema

## Debugging
If terrafrom is failing on the vagrant step, you can get additional output by
running terraform with logging output enabled. Try something like:

```bash
env TF_LOG=TRACE terraform apply ...
```

And, of course, you can always run vagrant on your Vagrantfile directly.
54 changes: 54 additions & 0 deletions docs/resources/vm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
page_title: "vagrant_vm Resource - terraform-provider-vagrant"
description: |-
Integrate vagrant into terraform.
---

# vagrant_vm (Resource)

## Forcing an Update
The easiest way to force an update is to set, or change the value of, some
environment variable. This will signal to terraform that the vagrant_vm
resource needs to update.

In the example below, a environment variable, `VAGRANTFILE_HASH`, is set to
the md5 hash of the Vagrantfile. When the file changes, the hash will change,
and terraform will ask for an update.

## Example Usage

```terraform
resource "vagrant_vm" "my_vagrant_vm" {
env = {
# force terraform to re-run vagrant if the Vagrantfile changes
VAGRANTFILE_HASH = "${md5(file("path/to/Vagrantfile"))}",
}
# see schema for additional options
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- **env** (Map of String) Environment variables to pass to the Vagrantfile.
- **id** (String) The ID of this resource.
- **vagrantfile_dir** (String) Path to the directory where the Vagrantfile can be found. Defaults to the current directory.

### Read-Only

- **machine_names** (List of String) Names of the vagrant machines from the Vagrantfile. Names are in the same order as ssh_config.
- **ssh_config** (List of Object) SSH connection information. (see [below for nested schema](#nestedatt--ssh_config))

<a id="nestedatt--ssh_config"></a>
### Nested Schema for `ssh_config`

Read-Only:

- **agent** (String)
- **host** (String)
- **port** (String)
- **private_key** (String)
- **type** (String)
- **user** (String)
5 changes: 0 additions & 5 deletions example.tf

This file was deleted.

3 changes: 3 additions & 0 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "vagrant" {
# no config
}
File renamed without changes.
7 changes: 7 additions & 0 deletions examples/resources/vagrant_vm/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "vagrant_vm" "my_vagrant_vm" {
env = {
# force terraform to re-run vagrant if the Vagrantfile changes
VAGRANTFILE_HASH = "${md5(file("path/to/Vagrantfile"))}",
}
# see schema for additional options
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/bmatcuk/terraform-provider-vagrant
require (
github.com/bmatcuk/go-vagrant v1.4.2
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce // indirect
github.com/hashicorp/terraform-plugin-docs v0.4.0 // indirect
github.com/hashicorp/terraform-plugin-sdk v1.0.0
)

Expand Down
Loading

0 comments on commit 04e9999

Please sign in to comment.