forked from notthebee/infra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Huge update once again. Hope I didn't leak any API tokens or whatever
- Loading branch information
Showing
74 changed files
with
662 additions
and
319 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
--- | ||
container_name: deconz | ||
|
||
dashboard_url: "http://deconz.{{ host_local }}/" | ||
url: "deconz.{{ host_local }}" | ||
|
||
ip_address: "{{ swag_base }}.25" | ||
|
||
homer_category: smarthome | ||
|
||
dashboard_name: "Phoscon-GW" | ||
dashboard_name: "deCONZ" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- name: Reboot pi | ||
reboot: | ||
msg: Rebooting due to a kernel update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- name: Check if the ZigBee device exists | ||
find: | ||
paths: | ||
- "/dev" | ||
patterns: | ||
- "ttyAMA*" | ||
file_type: | ||
any | ||
register: zigbee_dev | ||
|
||
- name: Make sure the {{ container_name }} container is created and running | ||
docker_container: | ||
name: "{{ container_name }}" | ||
image: "deconzcommunity/deconz:stable" | ||
networks: | ||
- name: swag_internal_macvlan | ||
ipv4_address: "{{ ip_address }}" | ||
pull: yes | ||
state: 'started' | ||
env: | ||
"TZ": "{{ timezone }}" | ||
"DECONZ_VNC_MODE": "1" | ||
volumes: | ||
- "{{ docker_dir }}/{{ container_name }}:/opt/deCONZ" | ||
devices: | ||
- /dev/ttyAMA0 | ||
restart_policy: unless-stopped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,4 @@ | ||
--- | ||
- name: Check if the ZigBee device exists | ||
find: | ||
paths: | ||
- "/dev" | ||
patterns: | ||
- "ttyACM*" | ||
file_type: | ||
any | ||
register: zigbee_dev | ||
- include_tasks: raspbee.yml | ||
when: ansible_facts['distribution'] == 'Debian' | ||
|
||
- name: Make sure the {{ container_name }} container is created and running if there's a Zigbee device | ||
docker_container: | ||
name: "{{ container_name }}" | ||
image: "deconzcommunity/deconz:stable" | ||
pull: yes | ||
networks: | ||
- name: swag_internal_macvlan | ||
ipv4_address: 10.0.0.6 | ||
state: 'started' | ||
labels: | ||
"flame.type": "application" | ||
"flame.name": "{{ dashboard_name }}" | ||
"flame.url": "{{ dashboard_url }}" | ||
"flame.icon": "custom" | ||
volumes: | ||
- "{{ docker_dir }}/{{ container_name }}:/opt/deCONZ" | ||
devices: | ||
- "{{ zigbee_dev.files[0].path }}" | ||
env: | ||
"TZ": "{{ timezone }}" | ||
"DECONZ_WEB_PORT": "8085" | ||
"DECONZ_WS_PORT": "4043" | ||
"DEBUG_INFO": "1" | ||
"DEBUG_APS": "0" | ||
"DEBUG_ZCL": "0" | ||
"DEBUG_ZDP": "0" | ||
"DEBUG_OTAU": "0" | ||
restart_policy: unless-stopped | ||
when: zigbee_dev.files | length > 0 | ||
- include_tasks: docker.yml |
125 changes: 125 additions & 0 deletions
125
roles/containers/homeautomation/deconz/tasks/raspbee.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
- name: Install build packages | ||
apt: | ||
name: | ||
- i2c-tools | ||
- build-essential | ||
- raspberrypi-kernel-headers | ||
- curl | ||
state: present | ||
|
||
- name: Check if RTC kernel module is installed | ||
stat: | ||
path: "/lib/modules/{{ ansible_kernel }}/extra/rtc-pcf85063.ko" | ||
get_attributes: no | ||
get_checksum: no | ||
get_mime: no | ||
register: kernel_module | ||
|
||
- block: | ||
- name: Download master.zip | ||
get_url: | ||
url: https://github.com/dresden-elektronik/raspbee2-rtc/archive/master.zip | ||
dest: /home/pi/master.zip | ||
owner: pi | ||
group: pi | ||
mode: 0440 | ||
register: download_master | ||
|
||
|
||
- name: Unpack master.zip | ||
unarchive: | ||
src: /home/pi/master.zip | ||
dest: /home/pi | ||
remote_src: yes | ||
owner: pi | ||
group: pi | ||
mode: 0770 | ||
creates: /home/pi/raspbee2-rtc-master | ||
|
||
|
||
- name: Build kernel module | ||
shell: cd /home/pi/raspbee2-rtc-master && make | ||
|
||
|
||
- name: Install kernel module | ||
shell: cd /home/pi/raspbee2-rtc-master && make install | ||
notify: | ||
- Reboot pi | ||
|
||
when: kernel_module.stat.exists != True | ||
|
||
|
||
- name: Remove source file for kernel module | ||
file: | ||
path: /home/pi/master.zip | ||
state: absent | ||
|
||
|
||
- name: Remove build files for kernel module | ||
file: | ||
path: /home/pi/raspbee2-rtc-master | ||
state: absent | ||
|
||
|
||
- name: Retrieve /boot/cmdline.txt | ||
slurp: | ||
src: "/boot/cmdline.txt" | ||
register: boot_cmdline_txt_retrieve | ||
|
||
|
||
- name: Extract /boot/cmdline.txt | ||
set_fact: | ||
boot_cmdline_txt: "{{ boot_cmdline_txt_retrieve.content | b64decode }}" | ||
|
||
|
||
- name: Enable hardware serial port | ||
command: | ||
cmd: raspi-config nonint do_serial 2 | ||
notify: | ||
- Reboot pi | ||
when: boot_cmdline_txt is search("console=serial0") or boot_cmdline_txt is search("console=console=ttyAMA0") | ||
|
||
|
||
- name: Stop hciuart | ||
systemd: | ||
name: hciuart | ||
state: stopped | ||
enabled: no | ||
ignore_errors: True | ||
|
||
- name: Stop bluetooth.service | ||
systemd: | ||
name: bluetooth.service | ||
state: stopped | ||
enabled: no | ||
ignore_errors: True | ||
|
||
|
||
|
||
- name: Remove Bluetooth packages | ||
apt: | ||
name: | ||
- pi-bluetooth | ||
- bluez | ||
state: absent | ||
purge: yes | ||
|
||
|
||
- name: Update /boot/config.txt | ||
lineinfile: | ||
dest: /boot/config.txt | ||
regexp: "{{ item.regexp }}" | ||
line: "{{ item.line }}" | ||
mode: 0644 | ||
owner: root | ||
group: root | ||
state: "{{ item.state }}" | ||
create: yes | ||
with_items: | ||
- { regexp: '^#? *dtoverlay=pi3-disable-bt', line: 'dtoverlay=pi3-disable-bt', state: present } | ||
notify: | ||
- Reboot pi | ||
|
||
|
||
- name: Reboot Raspberry Pi | ||
meta: flush_handlers |
6 changes: 3 additions & 3 deletions
6
roles/containers/homeautomation/homeassistant/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
--- | ||
container_name: homeassistant | ||
|
||
dashboard_url: "https://homeassistant.{{ host_local }}" | ||
url: "homeassistant.{{ host_local }}" | ||
|
||
ip_address: "{{ iot_base }}.168" | ||
|
||
homer_category: smarthome | ||
|
||
dashboard_name: "Home Assistant" | ||
|
||
health_url: "http://{{ lan_address }}:3000/http://homeassistant.{{ host_local }}" |
30 changes: 2 additions & 28 deletions
30
roles/containers/homeautomation/homeassistant/tasks/docker.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- name: Create an internal macvlan network | ||
when: enable_homeassistant | default(False) | ||
docker_network: | ||
name: iot_macvlan | ||
driver: macvlan | ||
driver_options: | ||
parent: "{{ iot_interface }}" | ||
ipam_config: | ||
- subnet: "{{ iot_network }}" | ||
gateway: "{{ iot_gateway }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
--- | ||
container_name: mqtt | ||
|
||
ip_address: "{{ swag_base }}.13" |
Oops, something went wrong.