[ansible][attitude-adjuster] put home-assistant on the host network

pull/28/head
Alpha Chen 5 years ago
parent 4f39381cbe
commit d7e4e8e7af

@ -49,94 +49,3 @@
- docker-compose
- python-docker
- name: docker compose
docker_compose:
project_name: attitude-adjuster
definition:
version: '2'
services:
ddclient:
image: kejadlen/ddclient
container_name: ddclient
environment:
TZ: America/Los_Angeles
volumes:
- /etc/ddclient:/etc/ddclient
networks:
- bridge
restart: always
home_assistant:
container_name: home-assistant
image: homeassistant/raspberrypi3-homeassistant
ports:
- 5353:5353/udp
- 51827:51827/tcp
environment:
TZ: America/Los_Angeles
volumes:
- /etc/homeassistant:/config
networks:
- bridge
restart: always
labels:
- traefik.enable=true
- traefik.frontend.rule=Host:{{ home_assistant.host }}
- traefik.basic.port=8123
- traefik.basic.protocol=http
pihole:
container_name: pihole
image: pihole/pihole:latest
ports:
- 53:53/tcp
- 53:53/udp
environment:
ServerIP: 192.168.1.101
TZ: America/Los_Angeles
VIRTUAL_HOST: "{{ pihole.host }}"
WEBPASSWORD: "{{ pihole.password }}"
volumes:
- /etc/pihole:/etc/pihole
- /etc/dnsmasq.d:/etc/dnsmasq.d
dns:
- 127.0.0.1
- 1.1.1.1
cap_add:
- NET_ADMIN
networks:
- bridge
restart: always
labels:
- traefik.enable=true
- traefik.frontend.rule=Host:{{ pihole.host }}
- traefik.basic.port=80
- traefik.basic.protocol=http
traefik:
container_name: traefik
image: traefik
command: --api --docker
ports:
- 80:80
- 8080:8080
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /opt/traefik/traefik.toml:/traefik.toml
- /opt/traefik/acme.json:/acme.json
networks:
- bridge
restart: always
labels:
- traefik.enable=true
- traefik.frontend.rule=Host:{{ traefik.host }}
- traefik.frontend.auth.basic.users=alpha:{{ traefik.password | password_hash('md5') | replace('$', '$$') }}
- traefik.basic.port=8080
- traefik.basic.protocol=http
networks:
bridge:
state: present
pull: yes

@ -12,8 +12,96 @@
- import_playbook: security.yml
- import_playbook: docker.yml
- import_playbook: ddclient.yml
- import_playbook: home-assistant.yml
- import_playbook: pihole.yml
- import_playbook: traefik.yml
- import_playbook: docker.yml
- hosts: attitude-adjuster
vars_files:
- vars.yml.private
tasks:
- name: docker compose
docker_compose:
project_name: attitude-adjuster
definition:
version: '2'
services:
ddclient:
image: kejadlen/ddclient
container_name: ddclient
environment:
TZ: America/Los_Angeles
volumes:
- /etc/ddclient:/etc/ddclient
networks:
- bridge
restart: always
home_assistant:
container_name: home-assistant
image: homeassistant/raspberrypi3-homeassistant
environment:
TZ: America/Los_Angeles
volumes:
- /etc/homeassistant:/config
network_mode: host
restart: always
pihole:
container_name: pihole
image: pihole/pihole:latest
ports:
- 53:53/tcp
- 53:53/udp
environment:
ServerIP: 192.168.1.101
TZ: America/Los_Angeles
VIRTUAL_HOST: "{{ pihole.host }}"
WEBPASSWORD: "{{ pihole.password }}"
volumes:
- /etc/pihole:/etc/pihole
- /etc/dnsmasq.d:/etc/dnsmasq.d
dns:
- 127.0.0.1
- 1.1.1.1
cap_add:
- NET_ADMIN
networks:
- bridge
restart: always
labels:
- traefik.enable=true
- traefik.frontend.rule=Host:{{ pihole.host }}
- traefik.basic.port=80
- traefik.basic.protocol=http
traefik:
container_name: traefik
image: traefik
command: --api --docker
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /opt/traefik/traefik.toml:/traefik.toml
- /opt/traefik/acme.json:/acme.json
networks:
- bridge
restart: always
labels:
- traefik.enable=true
- traefik.frontend.rule=Host:{{ traefik.host }}
- traefik.frontend.auth.basic.users=alpha:{{ traefik.password | password_hash('md5') | replace('$', '$$') }}
- traefik.basic.port=8080
- traefik.basic.protocol=http
networks:
bridge:
state: present
pull: yes

@ -6,13 +6,17 @@
become: yes
tasks:
- name: get docker ip
shell: ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+'
register: docker_ip
- name: traefik.toml
copy:
content: |
debug = false
insecureSkipVerify = true
logLevel = "ERROR"
logLevel = "INFO" # "ERROR"
defaultEntryPoints = ["https","http"]
[entryPoints]
@ -26,6 +30,19 @@
[retry]
[file]
[frontends]
[frontends.homeassistant]
backend = "homeassistant"
[frontends.homeassistant.routes.test_1]
rule = "Host:{{ home_assistant.host }}"
[backends]
[backends.homeassistant]
[backends.homeassistant.servers.server1]
url = "http://{{ docker_ip.stdout | trim }}:8123"
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "{{ traefik.domain }}"
@ -41,9 +58,19 @@
[acme.httpChallenge]
entryPoint = "http"
dest: /opt/traefik/traefik.toml
notify: restart traefik
- name: acme.json
file:
name: /opt/traefik/acme.json
mode: 0600
state: touch
handlers:
- name: restart traefik
docker_container:
name: traefik
restart: yes
ignore_errors: yes

Loading…
Cancel
Save