---
- hosts: all
  roles:
    - role: common
    - role: local_tests
    - role: thruk_developer
  tasks:
  - name: "install tesseract"
    include_role:
      name: yum_apt_retry
    vars:
      package:
        - tesseract
  - name: "omd config change"
    shell: "omd config demo change"
    args:
      stdin: |
        APACHE_MODE=own
        GRAFANA=on
        NAGFLUX=on
        INFLUXDB=on
        PNP4NAGIOS=off
#  - lineinfile:
#      path: /opt/omd/sites/demo/etc/nagflux/config.gcfg
#      regexp: '^\s*MinSeverity\s*='
#      line: '        MinSeverity = "TRACE"'
#  - lineinfile:
#      path: /opt/omd/sites/demo/etc/naemon/naemon.cfg
#      regexp: 'debug_level='
#      line: 'debug_level=-1'
#  - lineinfile:
#      path: /opt/omd/sites/demo/etc/naemon/naemon.cfg
#      regexp: 'debug_verbosity='
#      line: 'debug_verbosity=2'
#  - lineinfile:
#      path: /opt/omd/sites/demo/etc/naemon/naemon.cfg
#      regexp: 'max_debug_file_size='
#      line: 'max_debug_file_size=100000000'
  - copy:
      src: "/root/thruk_local.conf"
      dest: "/omd/sites/demo/etc/thruk/thruk_local.conf"
      owner: "demo"
      group: "demo"
  - copy:
      src: "/root/objects.cfg"
      dest: "/omd/sites/demo/etc/naemon/conf.d/objects.cfg"
      owner: "demo"
      group: "demo"
  - copy:
      src: "/root/cgi.cfg"
      dest: "/omd/sites/demo/etc/thruk/cgi.cfg"
      owner: "demo"
      group: "demo"
  - copy:
      src: "/root/menu_local.conf"
      dest: "/omd/sites/demo/etc/thruk/menu_local.conf"
      owner: "demo"
      group: "demo"
  - shell: sudo su - demo -c "htpasswd -b etc/htpasswd admin admin"
  - shell: sudo su - demo -c "htpasswd -b etc/htpasswd confinfo confinfo"
  - shell: sudo su - demo -c "htpasswd -b etc/htpasswd test test"
  - shell: echo "testkey" > /omd/sites/demo/var/thruk/secret.key
  - file:
      path: /omd/sites/demo/var/thruk/secret.key
      mode: 0600
      owner: demo
      group: demo
  - name: create reports folder
    file:
      path: /omd/sites/demo/var/thruk/reports
      state: directory
      owner: demo
      group: demo
      mode: 0770
  - name: add example report
    copy:
      src: /root/1.rpt
      dest: /omd/sites/demo/var/thruk/reports/1.rpt
      owner: demo
      group: demo
