Hass.io on Vagrant/VirtualBox for testing & add-on development

Project Stage Maintenance GitHub Release

In the past few days, I’ve created a VirtualBox/Vagrant virtual machine for running Hass.io, released the source code onto GitHub and sharing it with the community forums as well. I’m wondering if you guys like it, find it useful or maybe got some tips/suggestions on improving it.

About

This Vagrant virtual machine allows you to test and play with Hass.io and Home Assistant, and is a great environment for add-on developers. A simple vagrant up command would give you a fully installed Hass.io system, in a couple of minutes.

This setup comes preloaded with netdata and Portainer to provide you, even more, insight to what is happing under the hood.

Portainer

Portainer is a lightweight Docker management UI which allows you to easily manage your Docker/Hass.io host.

It allows add-on developers to look at the logs of their add-on, or even get a console into their running add-on to allow for easy debugging issues.

netdata

netdata allow you to monitor your Docker containers (of which Hass.io consists). Simple. Effective. Awesome!

Unparalleled insights, in real-time, of everything happening on your systems, applications, and add-ons with stunning, interactive web dashboards and powerful performance and health alarms.

This gives add-on developers detailed information about the performance and resource usage of their add-ons.

System requirements

This setup does not require a lot. Sure it does cost some CPU & memory, but to be honest, Google Chrome eats more memory these days. This setup is tested on MacOS but should work fine on Linux as well. Windows might work, but is not tested (please let us know!).

When following the installation instructions of the tools in the following chapter, please be sure to check the system requirements of each of those tools.

Getting started

Before launching your Hass.io environment, you must install VirtualBox 5.1 or higher, as well as Vagrant 1.9.0 or higher. These software packages provide easy-to-use visual installers for all popular operating systems and are open source.

Once VirtualBox and Vagrant have been installed, you install hassio-vagrant by simply cloning this repository. Consider cloning the repository into a folder within your “home” directory.

# Goto your home directory
cd ~

# Clone this repository into a folder called `hassio`
git clone https://github.com/hassio-addons/hassio-vagrant.git hassio

You should check out a tagged version of hassio-vagrant since the master branch may not always be stable. You can find the latest stable version on the GitHub Release Page:

# Change the directory to `hassio`
cd hassio

# Checkout the desired release
git checkout v0.1.0

Once you have cloned the hassio-vagrant repository, you can use the following command to start Hass.io:

vagrant up hassio

After 10 minutes or so, the process would finish and the following messages will appear on your screen:

==> hassio: [INFO] Start services
==> hassio: =====================================================================
==> hassio:  Community Hass.io Add-ons: Vagrant
==> hassio:
==> hassio:  Hass.io is installed & started! It may take a couple of minutes
==> hassio:  before it is actually responding/available.
==> hassio:
==> hassio:  Home Assitant is running on the following links:
==> hassio:   - http://172.28.128.11:8123
==> hassio:   - http://192.168.1.2:8123
==> hassio:
==> hassio:  Portainer is running on the following links:
==> hassio:   - http://172.28.128.11:9000
==> hassio:   - http://192.168.1.2:9000
==> hassio:
==> hassio:  Netdata is providing awesome stats on these links:
==> hassio:   - http://172.28.128.11:19999
==> hassio:   - http://192.168.1.2:19999
==> hassio: =====================================================================
==> hassio:
==> hassio: Machine 'hassio' has a post `vagrant up` message. This is a message
==> hassio: from the creator of the Vagrantfile, and not from Vagrant itself:
==> hassio:
==> hassio: Hass.io starting... wait a couple of minutes!

:tada: Congratulations! Happy testing/developing :smile:

Note: The links and IP addresses are examples, yours may differ and change each time you run this virtual machine

Managing the virtual machine

If you followed the above procedure, you have got Hass.io up and running. But there may be a time where you need to shut it down, start up again or maybe start over again.

Shutting down the virtual machine:

vagrant halt hassio

Starting/Resuming the virtual machine again:

vagrant up hassio

Destroying/Deleting the virtual machine:

vagrant destroy hassio

After you’ve destroyed your Hass.io virtual machine, you can use the start command to create a fresh one.

Note: Please, be aware! Destroying the machine would make you lose your configuration of Home Assistant!

You can also use SSH into the virtual machine, giving you direct access to the Docker host:

vagrant ssh hassio

Shared folders

After starting the Hass.io virtual machine, some folders on your harddrive will be made available. These are shared folders with your Hass.io virtual machine. As files within these folders are changed, they will be kept in sync between your local machine and the Hass.io virtual environment.

The following folders are provided within the location where you have cloned this repository to:

  • addons - May contain local add-on (e.g. for development).
  • backup - May contain snapshots made with Hass.io.
  • config - Contains the Home Assistant configuration.
  • share - Cross add-on shared folder.
  • ssl - May contain SSL certificate files.

Note: When destroying the Hass.io virtual machine, the contents of the config folder WILL BE DELETED. All other folders are left untouched.

Contributing


This is an active open-source project. We are always open to people who want to use the code or contribute to it. We’ve set up a separate document for our contribution guidelines.

Thank you for being involved! :heart_eyes:

We are also looking for maintainers!
Please send Franck Nijhof a message when you are interested in becoming one.

Support


You can always get support here at the Home Assistant community forums, join the conversation!

You have several options to get them answered:

We will do our best to help you out!

Repository on GitHub


8 Likes

:tada: Released: v0.0.2

Full Changelog

Fixed

  • Vagrant plugin vagrant-triggers not installed automatically #1 (mihalski)

:tada: Released: v0.0.3

Full Changelog

Added

  • D-Bus to host system
  • Avahi to host system

Hey Frenck,
would it be possible to try if this works on windows?
Right now this is what I’m seeing as an error:

It appears your machine doesn’t support NFS, or there is not an
adapter to enable NFS on this machine for Vagrant. Please verify
that nfsd is installed on your machine, and try again. If you’re
on Windows, NFS isn’t supported. If the problem persists, please
contact Vagrant support.

I’ve looked around a little but and found that the vagrant-winnfsd plugin might help, but it does not.
Now I’m trying to install vagrant + virtualbox on an Ubuntu that runs in a VirtualBox that runs on my Windows 10 to run this… which of course does not work… :frowning:

Thanks!
B

I should be possible to get this running on a Windows machine.
In the “code” I’ve tried to remain Windows compatible, apparently, I’ve failed :cry:

I don’t own any hardware running Windows, so I’m unable to debug it.

The following line should have switched from NFS to smb on windows machines:

Hi!
Did some investigation on this topic:
First I was trying to use the Ubuntu under Windows, the Linux subsystem on Windows 10. That is apparently not doable since you will not be able to manage the VirtualBox installed under Windows from the subsystem’s bash shell (you need to be root in the subsys, but root will not have access to the VBoxManage.exe in Program Files (Added to the path of the /etc/environment, but not helping).
After realizing this installed Vagrant under windows as well.
Now the problem is that since my Windows install is part of a managed enterprise Active Directory Domain and since Vagrant will ask for my Windows username and password and will not handle the Domain username ‘smb’ share will not work either.

So the solution was to run Vagrant straight from Windows and not through the Linux subsystem and set the share_type to ‘rsync’.

I’ve practically commented out the line that you’ve mentioned and changed it this way:

# Determines the type of filesharing. SMB for windows, else NFS.

def share_type
‘rsync’
#RbConfig::CONFIG[‘host_os’] =~ /mswin|mingw|cygwin/ ? ‘smb’ : ‘nfs’
end

@frenck I don’t need Portainer nor Netdata to get Hass up and running, right?

So i have installed VirtualBox and Vagrant.
I have also installed https://git-scm.com/download/win to run those git command prompt.
I have clone your repository both ways, gitHub and git clone https://github.com/hassio-a
Also did the git checkout v0.0.1.
Also install Vagrant trigger as it was missing.
Then I do Vagrant up hassio.
You said to wait 10 minutes but i think something wrong with mine, it’s been more than 10 minutes. It’s as if and looks doing something but it seems to be stucked.

Trying on Windows 7.

I’m going to leave it running for 6 hours as am going to bed, i’ll see if it does anything by 6 hours++ time lol

6 hours has passed and it does nothing.

Just like the documentation stated, I might run on Windows, but I personally do not own a Windows machine.

So if it doesn’t run, I’m sorry.

Until someone debugs it properly and puts up a change/PR on GitHub I’m kinda powerless.

1 Like

As of current state, it definitely does not work in Windows 7. I thought I put it here so that folks do not need to attempt.

@frenck
Can this be used for permanent installations?
Not like this https://home-assistant.io/docs/installation/vagrant/

The first video I created for my youtube channel the other day was actually putting hass.io on a VirtualBox VM
Install HASS.io on an existing system

In some ways the vagrant option is better but I do feel that my way is quite usable as a permanent system.

John

@gieljnssns It could… I guess… Somehow, my mind finds it troublesome to recommend it.

this is fantastic frenk, thank you for your work and share ,
i have it up and running on mac , what i still don’t get is how to access the shared folders , i have installed samba , but it seams it can’t get into the vm , is it something missing that it may be obvious but i skipped?,

i need to copy a snapshot , and even when i see the hassio folder for backup, i can’t get pass.io to see it .

i have restarted , and i think the folders were synced ,
it is working now …
on going learning , on how this setup works …

i see that restarting , from within hassio does not work , so i stop hassio from the terminal , and then restart again from terminal , right ?

couldn’t make the core configurator add on to work , i think there is something missing on my configuration , ssh keys probably ?

i have installed your shinobi add-on for testing in this environment , i made it to work with two cameras , at this moment i received frequent warnings : ipv4 udp home assistant errors , and video is still not fluent , probably i still don’t have the correct parameters set .

Both cameras work fine for about 30 secs, then both get frozen , and i see the warning note appear . eep receive buffer errors., then back to normal , and continue cycling this way .

is there a way i could increase ram for the VM , even when ram indicates 35% , free ram is only 100k , could this be generating the errors?

:tada: Release v0.1.0

Full Changelog

Added

  • Adds new OS dependencies for next-generation Supervisor
  • Adds Probot configuration

Fixed

  • Fixes Markdownlint warning in License

Changed

  • Updates README in multiple places
  • Replaces Changelog with GitHub releases

:tada: Release 1.0.0

Full Changelog

Fixed

  • Disables shares folder symlink create (#16)

Changed

  • Rewrites onto Vagrant’s native triggers (#15)
  • Upgrades base box to Ubuntu 18.04 (Bionic)
  • Sorts APT requirements
  • Updates version number in the README