2
0
mirror of https://github.com/schnidrig/openhab-ansible synced 2026-01-11 16:38:47 +01:00

upgrade to openhab 2.4; debian stretch

This commit is contained in:
Christian Schnidrig
2019-01-03 15:42:07 +01:00
parent 9231e75be7
commit d4dcdc7c0d
15 changed files with 119 additions and 36 deletions

View File

@@ -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
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
Edit the file `/etc/dhcpcd.conf` and add the following lines (according to your network) and reboot.
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 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.
- 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

View File

@@ -1,6 +1,8 @@
[controller]
192.168.1.7 ansible_ssh_user=pi
192.168.1.12 ansible_ssh_user=pi
[raspis]
#192.168.1.5 ansible_ssh_user=pi
192.168.1.7 ansible_ssh_user=pi
192.168.1.12 ansible_ssh_user=pi

View File

@@ -9,38 +9,39 @@
- git:
repo: "https://github.com/jpmens/mqttwarn.git"
dest: "/opt/mqttwarn"
version: "0c030a94a7e3590ea3485f460be555cee027d8a8"
version: "0.10.4"
#version: "0c030a94a7e3590ea3485f460be555cee027d8a8"
tags:
- mqttwarn
- name: install config file
template:
src: mqttwarn.ini
dest: "/opt/mqttwarn/mqttwarn.ini"
owner: root
group: root
mode: "u=rw,g=r,o=r"
src: mqttwarn.ini
dest: "/opt/mqttwarn/mqttwarn.ini"
owner: root
group: root
mode: "u=rw,g=r,o=r"
notify: restart mqttwarn
tags:
- mqttwarn
- mqttwarnconfig
- name: create log file
- name: create log dir
file:
state: touch
path: "/opt/mqttwarn/mqttwarn.log"
owner: pi
group: pi
dest: "/var/log/mqttwarn"
state: directory
owner: pi
group: pi
tags:
- mqttwarn
- name: install service file
template:
src: mqttwarn.service
dest: "/etc/systemd/system/mqttwarn.service"
owner: root
group: root
mode: "u=rw,g=r,o=r"
src: mqttwarn.service
dest: "/etc/systemd/system/mqttwarn.service"
owner: root
group: root
mode: "u=rw,g=r,o=r"
tags:
- mqttwarn

View File

@@ -1,16 +1,14 @@
[defaults]
hostname = 'localhost'
port = 1883
clientid = 'mqttwarn'
clientid = 'mqttwarn'
; logging
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
;loglevel = DEBUG
loglevel = ERROR
loglevel = INFO
; name the service providers you will be using.
launch = file, log, carbon
@@ -48,4 +46,4 @@ targets = {
targets = 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/#`

View File

@@ -1,5 +1,6 @@
[Unit]
Description=MQTTwarn
After=mosquitto.service
[Service]
Type=simple

View File

@@ -9,3 +9,13 @@
mode: "u=rwx,g=r,o=r"
tags:
- dynv6
- name: Cron file for dynv6
cron:
name: dynv6 update
user: root
job: "/root/dynv6.sh"
cron_file: dynv6
tags:
- dynv6

View File

@@ -22,6 +22,8 @@
hour: "5"
day: "11"
job: '/root/certbot-auto -n certonly --nginx --agree-tos --email {{letsencrypt_email}} -d {{fqdn}}'
cron_file: letsencrypt
user: root
tags:
- letsencrypt
- letsencrypt_cron

View File

@@ -10,6 +10,7 @@
- include: nginx.yml
- include: dynv6.yml
- include: letsencrypt.yml
- include: scripts.yml

View File

@@ -10,6 +10,7 @@
- python-mysqldb
tags:
- mysql
- packages
- name: Create openhab database
mysql_db:

View File

@@ -18,3 +18,40 @@
tags:
- 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

View File

@@ -13,8 +13,8 @@
- sysstat
- nginx
- python-passlib
- jython
- jython-doc
#- jython
#- jython-doc
tags:
- packages
- openhab2

View 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

View File

@@ -1,11 +1,11 @@
# stop openhab instance (here: systemd service)
sudo systemctl stop openhab2.service
#sudo systemctl stop openhab2.service
# backup current installation with settings
TIMESTAMP=`date +%Y%m%d_%H%M%S`;
mkdir ~/openhab2-backup-$TIMESTAMP
cp -arv /etc/openhab2 ~/openhab2-backup-$TIMESTAMP/conf
cp -arv /var/lib/openhab2 ~/openhab2-backup-$TIMESTAMP/userdata
TIMESTAMP=`date +%Y%m%d`;
tar -C / -czf /tmp/openhab2-backup-$TIMESTAMP.tgz etc/openhab2 var/lib/openhab2
# restart openhab instance
sudo systemctl start openhab2.service
echo "Now save the file /tmp/openhab2-backup-$TIMESTAMP.tgz"
# start openhab instance
#sudo systemctl start openhab2.service

View File

@@ -0,0 +1 @@
ssh -p 8101 openhab@localhost

View File

@@ -1,5 +1,9 @@
server {
listen 80;
listen [::]:80;
server_name {{fqdn}};
return 301 https://$server_name$request_uri;
}
server {
listen [::]:443 ssl;
server_name {{fqdn}};