---
- hosts: all
  roles:
    - role: common
    - role: thruk_developer
  tasks:
  - name: "omd config change"
    shell: "omd config demo change"
    args:
      stdin: |
        APACHE_MODE=own
        APACHE_TCP_ADDR=0.0.0.0
        PNP4NAGIOS=off
        LIVESTATUS_TCP=on
        THRUK_COOKIE_AUTH=off
  - name: copy naemon example.cfg
    copy:
      src: /omd/sites/demo/share/doc/naemon/example.cfg
      dest: /omd/sites/demo/etc/naemon/conf.d/example.cfg
      owner: demo
      group: demo
  - name: copy naemon test.cfg
    copy:
      src: /root/test.cfg
      dest: /omd/sites/demo/etc/naemon/conf.d/test.cfg
      owner: demo
      group: demo
  - 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
  - copy:
      src: /root/1.rpt
      dest: /omd/sites/demo/var/thruk/reports/
      owner: demo
      group: demo
  - copy:
      src: /root/1.tab
      dest: /omd/sites/demo/etc/thruk/panorama/
      owner: demo
      group: demo
  - copy:
      src: /root/1.tsk
      dest: /omd/sites/demo/var/thruk/downtimes/
      owner: demo
      group: demo
  - name: add example business process
    copy:
      src: /root/1.tbp
      dest: /omd/sites/demo/etc/thruk/bp/1.tbp
      owner: demo
      group: demo
  - shell: sudo su - demo -c "htpasswd -b etc/htpasswd pentest pentest"
  - lineinfile:
      path: /omd/sites/demo/etc/thruk/cgi.cfg
      regexp: '^{{ item }}='
      line: '{{ item }}=pentest'
    with_items: ['authorized_for_system_information', 'authorized_for_configuration_information', 'authorized_for_all_services', 'authorized_for_all_hosts', 'authorized_for_all_service_commands', 'authorized_for_all_host_commands', 'authorized_for_broadcasts', 'authorized_for_business_processes']
  - shell: sudo su - demo -c "sed -e 's/^#use_/use_/' -i etc/thruk/thruk_local.d/lmd.conf"
