Initial Ansible automation for hobbs.farm infrastructure
Complete IaC covering: - 14 roles: common, docker, traefik, vaultwarden, monitoring, media, matrix, home_assistant, frigate, adguard, gitea, semaphore, openclaw, security, backup - Inventory for all hosts (Peggy, Bart, Yoda, NAS, Firewalla) - Stack playbooks: core-infrastructure, monitoring, media, communication, automation, smarthome, security-hardening - Maintenance playbooks: update-containers, backup, health-check - Production Docker Compose templates with Traefik labels - Security hardening (sysctl, auditd, UFW, fail2ban) - Automated backups with retention policy
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
---
|
||||
smarthome_compose_dir: "{{ docker_compose_base }}/smarthome"
|
||||
ha_data_dir: /data/homeassistant
|
||||
esphome_data_dir: /data/esphome
|
||||
mosquitto_data_dir: /data/mosquitto
|
||||
|
||||
ha_image: "ghcr.io/home-assistant/home-assistant:stable"
|
||||
esphome_image: "ghcr.io/esphome/esphome:latest"
|
||||
mosquitto_image: "eclipse-mosquitto:latest"
|
||||
|
||||
ha_host: "ha.{{ domain }}"
|
||||
esphome_host: "esphome.{{ domain }}"
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
- name: Create smart home directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: glyptic
|
||||
group: docker
|
||||
mode: "0755"
|
||||
loop:
|
||||
- "{{ smarthome_compose_dir }}"
|
||||
- "{{ ha_data_dir }}"
|
||||
- "{{ esphome_data_dir }}"
|
||||
- "{{ mosquitto_data_dir }}"
|
||||
- "{{ mosquitto_data_dir }}/config"
|
||||
- "{{ mosquitto_data_dir }}/data"
|
||||
- "{{ mosquitto_data_dir }}/log"
|
||||
tags: [smarthome, homeassistant]
|
||||
|
||||
- name: Deploy smart home compose file
|
||||
ansible.builtin.template:
|
||||
src: docker-compose.yml.j2
|
||||
dest: "{{ smarthome_compose_dir }}/docker-compose.yml"
|
||||
owner: glyptic
|
||||
group: docker
|
||||
mode: "0644"
|
||||
tags: [smarthome, homeassistant]
|
||||
|
||||
- name: Start smart home stack
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ smarthome_compose_dir }}"
|
||||
state: present
|
||||
tags: [smarthome, homeassistant]
|
||||
@@ -0,0 +1,52 @@
|
||||
services:
|
||||
homeassistant:
|
||||
image: {{ ha_image }}
|
||||
container_name: homeassistant
|
||||
restart: unless-stopped
|
||||
privileged: true
|
||||
environment:
|
||||
TZ: {{ timezone }}
|
||||
volumes:
|
||||
- {{ ha_data_dir }}:/config
|
||||
labels:
|
||||
traefik.enable: "true"
|
||||
traefik.http.routers.ha.rule: "Host(`{{ ha_host }}`)"
|
||||
traefik.http.routers.ha.entrypoints: websecure
|
||||
traefik.http.routers.ha.tls.certresolver: cloudflare
|
||||
traefik.http.services.ha.loadbalancer.server.port: "8123"
|
||||
networks:
|
||||
- {{ docker_network_name }}
|
||||
|
||||
esphome:
|
||||
image: {{ esphome_image }}
|
||||
container_name: esphome
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
TZ: {{ timezone }}
|
||||
volumes:
|
||||
- {{ esphome_data_dir }}:/config
|
||||
labels:
|
||||
traefik.enable: "true"
|
||||
traefik.http.routers.esphome.rule: "Host(`{{ esphome_host }}`)"
|
||||
traefik.http.routers.esphome.entrypoints: websecure
|
||||
traefik.http.routers.esphome.tls.certresolver: cloudflare
|
||||
traefik.http.services.esphome.loadbalancer.server.port: "6052"
|
||||
networks:
|
||||
- {{ docker_network_name }}
|
||||
|
||||
mosquitto:
|
||||
image: {{ mosquitto_image }}
|
||||
container_name: mosquitto
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- {{ mosquitto_data_dir }}/config:/mosquitto/config
|
||||
- {{ mosquitto_data_dir }}/data:/mosquitto/data
|
||||
- {{ mosquitto_data_dir }}/log:/mosquitto/log
|
||||
networks:
|
||||
- {{ docker_network_name }}
|
||||
|
||||
networks:
|
||||
{{ docker_network_name }}:
|
||||
external: true
|
||||
Reference in New Issue
Block a user