---
# Pakete installieren
- name: notwendige pakete installieren
  apt:
    name: "{{ packages }}"
    update_cache: yes
    state: present
  vars:
    packages:
      - python3
      - python3-mysqldb
      - openjdk-11-jre-headless

# Get secrets 
- include_tasks: ../functions/get_secret.yml
  with_items:
    - { path: /srv/mysql/mysql_user_pw, length: 12 }
   
# Create jameica directories 
# Assume jameica is downloaded and extracted to /srv/jameica
- name: creating config directory 
  file:
    path: "{{item}}"
    state: directory
    owner: vorstand
    group: vorstand
    recurse: yes 
  with_items:
    - /srv/jameica
    - /srv/jameica/cfg
    - /srv/data-jameica

# create config files 
- name: creating config files 
  template:
    src: "{{ item }}"
    dest: "/srv/jameica/cfg/{{ item }}"
  with_items:
    - de.jost_net.JVerein.rmi.JVereinDBService.properties
    - de.willuhn.jameica.hbci.rmi.HBCIDBService.properties

# create batch files 
- name: creating modified start script  
  template:
    src: jameica.sh
    dest: /srv/jameica/jameica.sh
    mode: "u=rwx"

- name: creating symlink for start script 
  file:
    src: /srv/jameica/jameica.sh
    dest: /usr/bin/jameica
    state: link


