Browse Source

Get home automation related roles working on Raspbian.

master
Dan Helfman 1 month ago
parent
commit
6ef149c1d0
7 changed files with 41 additions and 47 deletions
  1. +1
    -0
      ansible.cfg
  2. +11
    -0
      roles/common/tasks/main.yml
  3. +10
    -1
      roles/docker/tasks/debian.yml
  4. +8
    -2
      roles/home_automation/tasks/main.yml
  5. +1
    -21
      roles/wireless/tasks/main.yml
  6. +0
    -23
      roles/wireless/templates/system-connection.j2
  7. +10
    -0
      roles/wireless/templates/wpa_supplicant.conf.j2

+ 1
- 0
ansible.cfg View File

@ -1,3 +1,4 @@
[defaults]
nocows = 1
vault_password_file = $HOME/.vault_pass.txt
interpreter_python = /usr/bin/python3

+ 11
- 0
roles/common/tasks/main.yml View File

@ -8,6 +8,12 @@
tags:
- common
- name: install locales on Debian
apt: name=locales
when: ansible_distribution == "Debian"
tags:
- common
- name: make UTF-8 locale available
lineinfile:
dest: /etc/locale.gen
@ -205,3 +211,8 @@
command: hostnamectl set-hostname "{{ inventory_hostname }}"
tags:
- common
- name: enable SSH on boot (Raspberry Pi)
file: path=/boot/ssh state=touch mode=0600
tags:
- wireless

+ 10
- 1
roles/docker/tasks/debian.yml View File

@ -15,10 +15,19 @@
tags:
- docker
- name: add Docker repository
- name: add Docker repository (amd64)
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/debian buster stable"
state: present
when: ansible_architecture == "x86_64"
tags:
- docker
- name: add Docker repository (armhf)
apt_repository:
repo: "deb [arch=armhf] https://download.docker.com/linux/debian buster stable"
state: present
when: ansible_architecture == "armv7l"
tags:
- docker


+ 8
- 2
roles/home_automation/tasks/main.yml View File

@ -52,6 +52,12 @@
tags:
- home_automation
- name: install download dependencies on Debian
apt: name=unzip
when: ansible_distribution == "Debian"
tags:
- home_automation
- name: install download dependencies on Manjaro
pacman: name=unzip
when: ansible_distribution in ["Manjaro", "Archlinux"]
@ -95,14 +101,14 @@
- 1883:1883
- 8883:8883
home-assistant:
image: homeassistant/raspberrypi3-64-homeassistant:{{ home_assistant_version }}
image: homeassistant/raspberrypi3-homeassistant:{{ home_assistant_version }}
restart: always
volumes:
- /etc/home-assistant:/config
- /etc/localtime:/etc/localtime:ro
# For WYZE sense.
devices:
- /dev/hidraw0
- /dev/hidraw1
network_mode: host
depends_on:
- mosquitto


+ 1
- 21
roles/wireless/tasks/main.yml View File

@ -1,24 +1,4 @@
- name: install NetworkManager on Manjaro
pacman: name=networkmanager
when: ansible_distribution in ["Manjaro", "Archlinux"]
register: install_result
tags:
- wireless
- name: configure wireless network
template: src=system-connection.j2 dest=/etc/NetworkManager/system-connections/{{ wireless_essid }} mode=0600
register: configure_result
tags:
- wireless
- name: reload NetworkManager
service: name=NetworkManager enabled=yes state=reloaded
when: install_result.changed or configure_result.changed
tags:
- wireless
- name: connect to wireless network
command: nmcli connection up {{ wireless_essid }}
when: install_result.changed or configure_result.changed
template: src=wpa_supplicant.conf.j2 dest=/boot/wpa_supplicant.conf mode=0600
tags:
- wireless

+ 0
- 23
roles/wireless/templates/system-connection.j2 View File

@ -1,23 +0,0 @@
[connection]
id={{ wireless_essid }}
uuid={{ wireless_essid | to_uuid }}
type=wifi
[wifi]
mode=infrastructure
ssid={{ wireless_essid }}
seen-bssids=EE:08:6B:F9:C4:EE
hidden=true
[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk={{ wireless_password }}
[ipv4]
method=auto
[ipv6]
addr-gen-mode=stable-privacy
method=auto

+ 10
- 0
roles/wireless/templates/wpa_supplicant.conf.j2 View File

@ -0,0 +1,10 @@
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="{{ wireless_essid }}"
scan_ssid=1
key_mgmt=WPA-PSK
psk="{{ wireless_password }}"
}

Loading…
Cancel
Save