Skip to content
Snippets Groups Projects
main.yml 1.90 KiB
---

- include: ../functions/get_secret.yml
  with_items:
   - { path: /srv/openhab/openweathermap_apikey, length: -1 }
   - { path: /srv/openhab/influxdb_password, length: 1 }


- name: pakete installieren
  apt:
    state: present
    name:
      - logrotate

- name: openhab LogRotate config erstellen 
  template: 
    src: logrotate 
    dest: /etc/logrotate.d/openhab

- name: Get a timestamp
  command: "date +%Y%m%d%H%M%S"
  register: timestamp

- name: create folder struct for openhab
  file: 
    path: "{{ item }}"
    state: "directory"
  with_items:
    - /srv/openhab/
    - /srv/openhab/addons/
    - /srv/openhab/conf/
    - /srv/openhab/conf/items/
    - /srv/openhab/conf/services/
    - /srv/openhab/conf/persistence/
    - /srv/openhab/conf/rules/
    - /srv/openhab/conf/things/
    - /srv/openhab/userdata/
    - /srv/openhab/influxdb-data/
    - /srv/openhab/influxdb-conf/

- name: Docker-Konfig-Dateien erstellen
  template:
    src: "{{ item }}"
    dest: "/srv/openhab/{{ item }}"
  with_items:
    - docker-compose.yml
  register: docker_config_files

- name: Openhab-Konfig-Dateien erstellen
  template:
    src: "{{ item }}"
    dest: "/srv/openhab/{{ item }}"
  with_items:
    - conf/items/groups.items
    - conf/items/mqtt.items
    - conf/items/network.items
    - conf/items/other.items
    - conf/items/weather.items
    - conf/persistence/influxdb.persist
    - conf/persistence/rrd4j.persist
    - conf/services/addons.cfg
    - conf/services/influxdb.cfg
    - conf/services/mqtt.cfg
    - conf/services/network.cfg
    - conf/services/runtime.cfg
    - conf/things/astro.things
    - conf/things/mqtt.things
    - conf/things/network.things
    - conf/things/weather.things
- name: stop openhab docker
  docker_compose:
    project_src: /srv/openhab/
    state: absent
  when: docker_config_files.changed 

- name: start openhab docker
  docker_compose:
    project_src: /srv/openhab/
    state: present