mirror of
https://github.com/schnidrig/openhab-ansible
synced 2026-01-12 00:48:46 +01:00
upgrade to openhab 2.4; debian stretch
This commit is contained in:
13
README.md
13
README.md
@@ -13,18 +13,17 @@ e.g on a mac with sdcard reader that would be:
|
|||||||
|
|
||||||
sudo dd bs=1m if=2016-09-23-raspbian-jessie-lite.img of=/dev/rdiskXYZ
|
sudo dd bs=1m if=2016-09-23-raspbian-jessie-lite.img of=/dev/rdiskXYZ
|
||||||
|
|
||||||
Insert sdcard into rasberry pi and boot.
|
|
||||||
|
|
||||||
### Enable sshd
|
mount sdcard and create an empty file `ssh` at the top level directory.
|
||||||
|
|
||||||
sudo systemctl enable ssh
|
Eject card and then insert sdcard into rasberry pi and boot.
|
||||||
|
|
||||||
### Configure fixed ip address
|
### Configure fixed ip address
|
||||||
|
|
||||||
Edit the file `/etc/dhcpcd.conf` and add the following lines (according to your network) and reboot.
|
Edit the file `/etc/dhcpcd.conf` and add the following lines (according to your network) and reboot.
|
||||||
|
|
||||||
interface eth0
|
interface eth0
|
||||||
static ip_address=192.168.1.5/24
|
static ip_address=192.168.1.7/24
|
||||||
static routers=192.168.1.1
|
static routers=192.168.1.1
|
||||||
static domain_name_servers=192.168.1.1
|
static domain_name_servers=192.168.1.1
|
||||||
|
|
||||||
@@ -33,6 +32,12 @@ Edit the file `/etc/dhcpcd.conf` and add the following lines (according to your
|
|||||||
- Change password of user pi.
|
- Change password of user pi.
|
||||||
- Install ssh public key for user pi
|
- Install ssh public key for user pi
|
||||||
|
|
||||||
|
## memory split
|
||||||
|
|
||||||
|
sudo raspi-config
|
||||||
|
|
||||||
|
Then from the advanced menu, change the memory split for the GPU to "16"
|
||||||
|
restart.
|
||||||
|
|
||||||
## Run ansible playbook
|
## Run ansible playbook
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
[controller]
|
[controller]
|
||||||
192.168.1.7 ansible_ssh_user=pi
|
192.168.1.7 ansible_ssh_user=pi
|
||||||
|
192.168.1.12 ansible_ssh_user=pi
|
||||||
|
|
||||||
[raspis]
|
[raspis]
|
||||||
#192.168.1.5 ansible_ssh_user=pi
|
#192.168.1.5 ansible_ssh_user=pi
|
||||||
192.168.1.7 ansible_ssh_user=pi
|
192.168.1.7 ansible_ssh_user=pi
|
||||||
|
192.168.1.12 ansible_ssh_user=pi
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
- git:
|
- git:
|
||||||
repo: "https://github.com/jpmens/mqttwarn.git"
|
repo: "https://github.com/jpmens/mqttwarn.git"
|
||||||
dest: "/opt/mqttwarn"
|
dest: "/opt/mqttwarn"
|
||||||
version: "0c030a94a7e3590ea3485f460be555cee027d8a8"
|
version: "0.10.4"
|
||||||
|
#version: "0c030a94a7e3590ea3485f460be555cee027d8a8"
|
||||||
tags:
|
tags:
|
||||||
- mqttwarn
|
- mqttwarn
|
||||||
|
|
||||||
@@ -25,10 +26,10 @@
|
|||||||
- mqttwarn
|
- mqttwarn
|
||||||
- mqttwarnconfig
|
- mqttwarnconfig
|
||||||
|
|
||||||
- name: create log file
|
- name: create log dir
|
||||||
file:
|
file:
|
||||||
state: touch
|
dest: "/var/log/mqttwarn"
|
||||||
path: "/opt/mqttwarn/mqttwarn.log"
|
state: directory
|
||||||
owner: pi
|
owner: pi
|
||||||
group: pi
|
group: pi
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ hostname = 'localhost'
|
|||||||
port = 1883
|
port = 1883
|
||||||
clientid = 'mqttwarn'
|
clientid = 'mqttwarn'
|
||||||
|
|
||||||
|
|
||||||
; logging
|
; logging
|
||||||
logformat = '%(asctime)-15s %(levelname)-5s [%(module)s] %(message)s'
|
logformat = '%(asctime)-15s %(levelname)-5s [%(module)s] %(message)s'
|
||||||
logfile = 'mqttwarn.log'
|
logfile = '/var/log/mqttwarn/mqttwarn.log'
|
||||||
|
|
||||||
; one of: CRITICAL, DEBUG, ERROR, INFO, WARN
|
; one of: CRITICAL, DEBUG, ERROR, INFO, WARN
|
||||||
;loglevel = DEBUG
|
loglevel = INFO
|
||||||
loglevel = ERROR
|
|
||||||
|
|
||||||
; name the service providers you will be using.
|
; name the service providers you will be using.
|
||||||
launch = file, log, carbon
|
launch = file, log, carbon
|
||||||
@@ -48,4 +46,4 @@ targets = {
|
|||||||
targets = carbon:openhab
|
targets = carbon:openhab
|
||||||
;targets = log:info, file:f01, carbon:openhab
|
;targets = log:info, file:f01, carbon:openhab
|
||||||
|
|
||||||
# instead of logging run `mosquitto_sub -t openhab/graphite/#`
|
# instead of logging run `mosquitto_sub -t /openhab/graphite/#`
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=MQTTwarn
|
Description=MQTTwarn
|
||||||
|
After=mosquitto.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
|
|||||||
@@ -9,3 +9,13 @@
|
|||||||
mode: "u=rwx,g=r,o=r"
|
mode: "u=rwx,g=r,o=r"
|
||||||
tags:
|
tags:
|
||||||
- dynv6
|
- dynv6
|
||||||
|
|
||||||
|
- name: Cron file for dynv6
|
||||||
|
cron:
|
||||||
|
name: dynv6 update
|
||||||
|
user: root
|
||||||
|
job: "/root/dynv6.sh"
|
||||||
|
cron_file: dynv6
|
||||||
|
tags:
|
||||||
|
- dynv6
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
hour: "5"
|
hour: "5"
|
||||||
day: "11"
|
day: "11"
|
||||||
job: '/root/certbot-auto -n certonly --nginx --agree-tos --email {{letsencrypt_email}} -d {{fqdn}}'
|
job: '/root/certbot-auto -n certonly --nginx --agree-tos --email {{letsencrypt_email}} -d {{fqdn}}'
|
||||||
|
cron_file: letsencrypt
|
||||||
|
user: root
|
||||||
tags:
|
tags:
|
||||||
- letsencrypt
|
- letsencrypt
|
||||||
- letsencrypt_cron
|
- letsencrypt_cron
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
- include: nginx.yml
|
- include: nginx.yml
|
||||||
- include: dynv6.yml
|
- include: dynv6.yml
|
||||||
- include: letsencrypt.yml
|
- include: letsencrypt.yml
|
||||||
|
- include: scripts.yml
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
- python-mysqldb
|
- python-mysqldb
|
||||||
tags:
|
tags:
|
||||||
- mysql
|
- mysql
|
||||||
|
- packages
|
||||||
|
|
||||||
- name: Create openhab database
|
- name: Create openhab database
|
||||||
mysql_db:
|
mysql_db:
|
||||||
|
|||||||
@@ -18,3 +18,40 @@
|
|||||||
tags:
|
tags:
|
||||||
- openhab2
|
- openhab2
|
||||||
|
|
||||||
|
- name: Download Rollershutters dependencies
|
||||||
|
get_url:
|
||||||
|
url: "{{ item.src }}"
|
||||||
|
dest: "/usr/share/openhab2/runtime/lib/boot/{{ item.name }}"
|
||||||
|
loop:
|
||||||
|
- { name: "jython-standalone-2.7.0.jar", src: "http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar" }
|
||||||
|
- { name: "snakeyaml-1.18.jar", src: "http://central.maven.org/maven2/org/yaml/snakeyaml/1.18/snakeyaml-1.18.jar" }
|
||||||
|
tags:
|
||||||
|
- openhab2
|
||||||
|
- jython
|
||||||
|
|
||||||
|
|
||||||
|
- name: cron job
|
||||||
|
cron:
|
||||||
|
name: "restart openhab"
|
||||||
|
minute: "10"
|
||||||
|
hour: "5"
|
||||||
|
weekday: "0"
|
||||||
|
job: 'systemctl restart nginx.service'
|
||||||
|
cron_file: openhab
|
||||||
|
user: root
|
||||||
|
tags:
|
||||||
|
- openhab2
|
||||||
|
- openhab_cron
|
||||||
|
|
||||||
|
- name: cron job
|
||||||
|
cron:
|
||||||
|
name: "touch shutters"
|
||||||
|
minute: "20"
|
||||||
|
hour: "5"
|
||||||
|
weekday: "0"
|
||||||
|
job: 'touch /etc/openhab2/automation/jsr223/shutters.py'
|
||||||
|
cron_file: openhab
|
||||||
|
user: root
|
||||||
|
tags:
|
||||||
|
- openhab2
|
||||||
|
- openhab_cron
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
- sysstat
|
- sysstat
|
||||||
- nginx
|
- nginx
|
||||||
- python-passlib
|
- python-passlib
|
||||||
- jython
|
#- jython
|
||||||
- jython-doc
|
#- jython-doc
|
||||||
tags:
|
tags:
|
||||||
- packages
|
- packages
|
||||||
- openhab2
|
- openhab2
|
||||||
|
|||||||
20
roles/openhab2/tasks/scripts.yml
Normal file
20
roles/openhab2/tasks/scripts.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: create scripts dir
|
||||||
|
file:
|
||||||
|
dest: /root/bin
|
||||||
|
state: directory
|
||||||
|
tags:
|
||||||
|
- scripts
|
||||||
|
|
||||||
|
- name: create scripts
|
||||||
|
template:
|
||||||
|
src: "{{ item }}"
|
||||||
|
dest: "/root/bin/{{ item }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "u=rwx,g=r,o=r"
|
||||||
|
loop:
|
||||||
|
- karaf.sh
|
||||||
|
tags:
|
||||||
|
- scripts
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
# stop openhab instance (here: systemd service)
|
# stop openhab instance (here: systemd service)
|
||||||
sudo systemctl stop openhab2.service
|
#sudo systemctl stop openhab2.service
|
||||||
|
|
||||||
# backup current installation with settings
|
# backup current installation with settings
|
||||||
TIMESTAMP=`date +%Y%m%d_%H%M%S`;
|
TIMESTAMP=`date +%Y%m%d`;
|
||||||
mkdir ~/openhab2-backup-$TIMESTAMP
|
tar -C / -czf /tmp/openhab2-backup-$TIMESTAMP.tgz etc/openhab2 var/lib/openhab2
|
||||||
cp -arv /etc/openhab2 ~/openhab2-backup-$TIMESTAMP/conf
|
|
||||||
cp -arv /var/lib/openhab2 ~/openhab2-backup-$TIMESTAMP/userdata
|
|
||||||
|
|
||||||
# restart openhab instance
|
echo "Now save the file /tmp/openhab2-backup-$TIMESTAMP.tgz"
|
||||||
sudo systemctl start openhab2.service
|
|
||||||
|
# start openhab instance
|
||||||
|
#sudo systemctl start openhab2.service
|
||||||
|
|||||||
1
roles/openhab2/templates/karaf.sh
Normal file
1
roles/openhab2/templates/karaf.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ssh -p 8101 openhab@localhost
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen [::]:80;
|
||||||
|
server_name {{fqdn}};
|
||||||
|
return 301 https://$server_name$request_uri;
|
||||||
|
}
|
||||||
|
server {
|
||||||
listen [::]:443 ssl;
|
listen [::]:443 ssl;
|
||||||
server_name {{fqdn}};
|
server_name {{fqdn}};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user