Skip to content
/ home Public

Ansible playbooks and Terraform scripts I use for home automation

Notifications You must be signed in to change notification settings

charlietw/home

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi Home Automaton

This repository contains all of the code to manage all things smart home.

Setup

Secrets

There are two files you need to create locally:

secrets.yaml - containing:

  • NETWORK_KEY for the zigbee2mqtt config.
  • INFLUXDB_KEY so Grafana can connect to InfluxDB

There is also the ansible/aws_secrets.yaml file which is automatically generated by Terraform.

infrastructure/secrets.tfvars - containing the secrets required for Terraform, i.e.:

  • key = Key of the state file
  • bucket = Bucket containing the terraform state file
  • region = Region where the state file is kept

SSH

If you need to change the SSH key or create one from scratch, you can use ssh-keygen, then specify a filepath in the subsequent prompt.

Within the remote host you will then need to ensure that you have a user set up, using the following commands if necessary:

getent passwd # will list all users, so...
getent passwd | grep <<USER>> # will tell us if user exists

sudo useradd -m <<USER>> -s /bin/bash # -m flag adds home dir, -s ensures default shell is bash
sudo passwd <<USER>> # to set password

sudo visudo # to allow ansible to sudo without a password

Append <<USER>> ALL=(ALL) NOPASSWD:ALL to the end of the text file opened with the final command.

Once you have the user set up, you can run ssh-copy-id -i <<FILEPATH>> <<USER>>@ubuntu-rpi

The -i switch specifies where the key file is.

Docker

To install docker on the remote server, follow the instructions from the Docker documentation

AWS

You will need access to an IAM user with MFA enabled, as documented in this issue. This user will then create another user which Ansible will use.

Usage

The Makefile contains all of the commands required.

Zigbee2mqtt

The configuration.yaml.j2 file is copied to the remote server upon make ansible call, but it is templated to insert secrets such as the network_key.

USB port

The physical USB stick may change port if there is a power cycle. It will most likely be in /dev/ttyUSB0, but this is worth checking, and can be verified by following the instructions here.

About

Ansible playbooks and Terraform scripts I use for home automation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published