---

- include_tasks: ../functions/get_secret.yml
  with_items:
  - { path: "{{ basedir }}/wlan_pass", length: -1 }

- name: "create folder struct for {{ servicename }}"
  file: 
    path: "{{ item }}"
    state: "directory"
  with_items:
    - "{{ basedir }}/"
    - "{{ basedir }}/config/"
    - "{{ basedir }}/config/components/"
    - "{{ basedir }}/config/components/frekvens_panel/"

- name: "copy  files for {{ servicename }}"
  copy: 
    src: "{{ item }}" 
    dest: "{{ basedir }}/{{ item }}"
  with_items: 
    - config/04B03.ttf
    - config/C64_Pro_Mono-STYLE.ttf
    - config/tall-pixel-8x3.ttf
    - config/tall-pixel-edit.ttf
    - config/frekvens-dot.ttf
  register: config

- name: "create config files for {{ servicename }}"
  template: 
    src: "{{ item }}" 
    dest: "{{ basedir }}/{{ item }}"
  with_items: 
    - docker-compose.yml
    - compile.sh
  register: config

- name: "stop {{ servicename }} docker"
  community.docker.docker_compose_v2:
    project_src: "{{ basedir }}"
    state: absent
  when: config.changed

- name: "start {{ servicename }} docker"
  community.docker.docker_compose_v2:
    project_src: "{{ basedir }}"
    state: present
