# install perfact measure
# only if sofware contains measure


# first make shure software exists at all:
- name: install and configure perfact-measure
  when: hosts[inventory_hostname]['software'] is defined and "'measure' in software"
  tags: perfact-measure
  become: yes
  block:
    # dependency of perfact-measure
    - name: create group logview
      group:
        name: logview
        system: true
        state: present

    # dependency of perfact-measure
    - name: create user syslog
      tags: perfact-measure
      become: yes
      user:
        name: syslog
        system: true
        state: present

    - name: install perfact-measure
      # Do not use "latest" here. This will update packages, whenever you
      # run playbooks.
      # Do not use package here. It will install about 630MB of software
      # because of recommends: unoconv (Umwandlungsprogramm für
      # LibreOffice-Dokumentformate)
      # better use apt with install_recommends: false
      ansible.builtin.apt:
        name: perfact-measure
        state: present
        install_recommends: false

    - name: perfact-measure copy custom config
      template:
        src: custom.py.j2
        dest: "/etc/perfact/measure/custom.py"
      when: "'measure' in software"
      notify: restart perfact-measure
