acutally i am setting up a new openhab instance.
For automatic deployment of configuration files i want to use my gitlab instance.
Until now i triggered a ansible-playbook (also with rsync task) but now i want to handle the sync process completely in the gitlab-ci.yml
The sync of the files is working fine, but file updates aren’t recognized by openhab - i have to restart the openhab service to take effect of changes.
My “old” ansible playbook:
---
- name: Deploy openhab config
hosts: openhab.home.domain.de
gather_facts: false
tasks:
- name: Clone openhab config from gitlab repo
ansible.builtin.git:
repo: git@gitlab.home.domain.de:homelab/openhab.git # noqa: latest
dest: /tmp/openhab-config
clone: true
update: true
delegate_to: localhost
run_once: true
- name: Synchronize and delete files in dest on the remote host that are not found in src of localhost.
ansible.posix.synchronize:
src: /tmp/openhab-config/
dest: /etc/openhab
# rsync_opts:
# - "--chmod=F755"
delete: true
recursive: true
- name: Recursively remove directory
ansible.builtin.file:
path: /tmp/openhab-config
state: absent
delegate_to: localhost
run_once: true
Unless you installed openhab in its own way from root account this is not going to fly. As far I remember openHAB rpm/deb/apt package uses its own user - openhab. Make sure these files are readable by user account used by openhab process.
this was my first thought, too.
its correct, that the files/folders after installation had “openhab” as owner and group.
but the files are readable for openhab, because after a restart of the service they are recognized.
Even when i upload a file as root user the update works.
So i think there has to be another reason why the config isnt updated immediately…
If permissions are fine maybe file modified/changed time is not amended? I think that file monitoring works based on modified time, so if your script keeps all attributes intact, but changes contents, monitors will be blind for updated content until restart.
The timestamp of the files change, too. Its really strange.
In the logs of Openhab i get sometimes this error - but i am not quite sure if its related to the file updates?
java.lang.NullPointerException: null
at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011) ~[?:?]
at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006) ~[?:?]
at org.openhab.core.internal.service.WatchServiceImpl.notifyListeners(WatchServiceImpl.java:256) ~[?:?]
at org.openhab.core.internal.service.WatchServiceImpl.lambda$4(WatchServiceImpl.java:231) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
I am not sure what that means for me.
Because its working on the “manual” way, i think there has to be a difference on the “automated” way, but i can’t figure out what the difference is…