Turnkey raspberry pi deployment with Fabric


Github Files

Easily deploy a complete Home-Assistant server, complete with Websocket MQTT and Z-Wave support out of the box using Fabric!

Start with a fresh Raspbian Jessie/Jessie-Lite or Debian 8 install, and the fabric script will do the following automatically:

  • Create all needed directories
  • Create needed service accounts
  • Install OS and Python dependencies
  • Setup a virtualenv to run Home-Assistant and components inside.
  • Run as a service account
  • Install Home-Assistant in a virtualenv
  • Build and install Mosquitto from source with websocket support
  • Build and Install Python-openzwave in the Home-Assistant virtualenv
  • Add both Home-Assistant and Mosquitto to systemd services to start at boot

What is Fabric?
The official README says:

“Fabric is a Python (2.5-2.7) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.”



Simply install fabric locally:
pip3 install fabric3

Ensure you’re able to SSH into the target server.

Clone the repo : git clone https://github.com/jbags81/fabric-home-assistant.git on your local host.
The repo contains a pre-configured default mosquitto.conf file. The only addition is an added listener for websockets listening on 9001. It also contains preconfigured systemd service profiles. For the fabric script to run successfully, it has to be ran from the root of the cloned repo.

Edit fabfile.py and add the host info for the target host.


Run the “deploy” job to build a new home-assistant server: fab deploy , then reboot.
Everything will start at boot, and Home-Assistant is accessible now from http://your_server_ip:8123

The Home-Assistant configs are located in: /home/hass The virtualenv path, along with where all python packages will install is located at: /srv/hass/hass_venv

Fabric allows any of the underlying functions to be ran individually as well. Run fab -l to see a list of all callable jobs.

Future support for non-virtualenv based servers will be added, along with the ability to auto upload existing or backup .yaml Home-Assistant configs. I’m also working on a turn-key devlopment script to make testing and development environments one click setups… More to come!

Tested with Raspbian Jessie, Jessie-Lite, and Debian 8 (username and path modifications needed)


Very cool! A useful enhancement would be if it also automated the build of openzwave control panel.


Good Idea! I’ll get it baked in

So new Raspbian image installed to the SD card. Set the fixed IP address. Rebooted. Followed Fabric install (not sure how to edit the ip.add.re.ss = “”.

The fabric install generated a bunch of errors and then was unable to perform the fab deploy command.

Trying the basic method now but not sure what I did wrong?


Have you confirmed you can SSH into the pi?

I’m at that point on Windows 10 too. Cannot run fab command as the install of Fabric3 does not appear to happen. Full log here. Running Python 3.5 64bit in C:\Python35-64 with environment variables deployed.

I’ve cleaned up the installer. Head over to my repo. The updated instructions are there. All that’s needed now is to ssh on to pi, and execute command found on repo page. Will run from pi, and take care of everything.

SO I was running this directly from the raspberry pi but today I SSH in and got…

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python3.4/dist-packages/pip/commands/install.py", line 317, in run
  File "/usr/local/lib/python3.4/dist-packages/pip/req/req_set.py", line 742, in install
  File "/usr/local/lib/python3.4/dist-packages/pip/req/req_install.py", line 831, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python3.4/dist-packages/pip/req/req_install.py", line 1032, in move_wheel_files
  File "/usr/local/lib/python3.4/dist-packages/pip/wheel.py", line 346, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python3.4/dist-packages/pip/wheel.py", line 317, in clobber
  File "/usr/local/lib/python3.4/dist-packages/pip/utils/__init__.py", line 83, in ensure_dir
  File "/usr/lib/python3.4/os.py", line 237, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.4/dist-packages/Crypto'

I’ve been able to get the basics running but still want to try your method.


What did you issue to receive those errors? You’re getting them because it’s trying to install the python module “pycrypto” globally. You either need to have run whatever you ran as root (which is ill advised) or run everything in a virtualenv, which fixes the permissions/root issue.

So this was a result of running the “pip3 install fabric” command from the command prompt.

Perhaps I’m not following the requirements before installation correctly.

I have a Pi 2b with fresh Raspbian install.
I can SSH into the Ras (but I tried to install locally first).
I am not sure about the 3rd requirement, “You have a computer with Python 3 and git installed.”, what is the need for this? The Pi has the Python right?

Sorry for being a bit slow on the uptake here…


Awesome. I’ve followed your instructions here with a clean install of Jessie Lite and it worked flawlessly. Thank you. All I did was expand the filesystem, set my region to Pacific/Auckland and answered the one question about 15 minutes into the install (virtual or not). The process took about 2hrs with my Pi2 plugged into my Gigabit LAN on Fibre so be patient if you are using WiFi and standard DSL.

One question though. What port is the openzwave-control-panel running on?

Awesome! Glad it helped :slight_smile: you pick the port for openzwave-control-panel. Given the nature of the tool, I opted to not run it automatically. You cd /srv/hass/src/open-zwave-control-panel and run ./ozwcp -p 8888 (or whatever port you want. can also use -d for debug output).

Thanks! Will try that when my Z-wave stick arrives.

One more question if I may. Now that HA is in a VM, what’s the update process when there is a new version of HA?

Hmm. Tried to edit yaml file through SCP and logging in with pi:raspberry wont allow it. scp: /home/hass/configuration.yaml: Permission denied.

yes, the home-assistant config’s, process, and etc are owned by “hass”. You should use sudo -u or similar…

Thanks, but how do you login with WinSCP to change the yaml file? Is it possible to enable Samba to make accessing and editing the yaml file easier?

Sorted. Modify the SCP/Shell page for your saved configuration and change it to sudo su - as shown here. You can also add Samba and create a new user by following the excellent instructions at BRUH Automation on YouTube here. My smb.conf file dedicated to this instance is here.

Ooh, and what port is Mosquitto running on, 1883?

Oh, I just got the same…

Lightbulb moment. I am logged in as pi, so…
sudo pip3 install fabric
Aha, it works

I’ve been able to successfully use the Raspberry PI All-in-one installer (the GitHub page appears to be updated before the web page on home-assistant.io is).

I’m not on a real fast connection and this was a painful process. I had to re-image & restart this process 4 times as I had some problem downloading the openwave software repeatedly. (perhaps an image file on a torrent site may be faster?)

I also had to switch from putty to WinSCP (the portable apps version works well).

Thanks for the help up to this point! I’m sure I’ll need more.