https://github.com/koding/vagrantutil
A toolset to manage Vagrant boxes in Go
https://github.com/koding/vagrantutil
Last synced: 8 months ago
JSON representation
A toolset to manage Vagrant boxes in Go
- Host: GitHub
- URL: https://github.com/koding/vagrantutil
- Owner: koding
- License: bsd-3-clause
- Created: 2015-08-21T09:27:09.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-01-27T03:12:24.000Z (almost 5 years ago)
- Last Synced: 2024-06-18T20:24:21.498Z (over 1 year ago)
- Language: Go
- Size: 39.1 KB
- Stars: 43
- Watchers: 6
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Vagrantutil [](http://godoc.org/github.com/koding/vagrantutil)
Vagrantutil is a toolset for managing Vagrant boxes via an idiomatic Go
(Golang) API. The package is work in progress, so please vendor it. Checkout
the examples below for the usage.
## Install
```bash
go get github.com/koding/vagrantutil
```
## Usage and Examples
```go
package main
import (
"log"
"github.com/koding/vagrantutil"
)
func main() {
vagrant, _ := vagrantutil.NewVagrant("myfolder")
vagrant.Create(`# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "vagrant"
config.vm.provider "virtualbox" do |vb|
# Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "2048", "--cpus", "2"]
end
end
`)
status, _ := vagrant.Status() // prints "NotCreated"
// starts the box
output, _ := vagrant.Up()
// print the output
for line := range output {
log.Println(line)
}
// stop/halt the box
vagrant.Halt()
// destroy the box
vagrant.Destroy()
}
```