This repository contains all of the code to manage all things smart home.
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
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.
To install docker on the remote server, follow the instructions from the Docker documentation
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.
The Makefile
contains all of the commands required.
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
.
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.