---
- hosts: all
  roles:
    - role: common
    - role: thruk_developer
  tasks:
  - name: "yum install ldap apache module"
    include_role:
      name: yum_apt_retry
    vars:
      package:
        - mod_ldap
        - openldap-clients

  - shell: omd config demo set APACHE_MODE own
  - shell: omd config demo set LIVESTATUS_TCP on
  - shell: rm /omd/sites/demo/etc/naemon/conf.d/*.cfg
  - shell: ln -s /thruk/support/thruk_templates.cfg /omd/sites/demo/etc/naemon/conf.d/thruk_templates.cfg
  - copy:
      src: /root/test.cfg
      dest: /omd/sites/demo/etc/naemon/conf.d/test.cfg
      owner: demo
      group: demo
  - copy:
      src: /root/auth_ldap.conf
      dest: /omd/sites/demo/etc/apache/conf.d/auth.conf
      owner: demo
      group: demo
  - lineinfile:
     path: /omd/sites/demo/etc/thruk/thruk_local.conf
     state: present
     regexp: '^cookie_auth_login_hook'
     line: 'cookie_auth_login_hook = date >> /omd/sites/demo/tmp/hook.log'
  - name: "install Net::LDAP::Server"
    shell: "sudo su - {{ site }} -c 'cpanm -n Net::LDAP::Server'"
    args:
      creates: "/omd/sites/{{ site }}/local/lib/perl5/lib/perl5/Net/LDAP/Server.pm"
  - name: "run mock LDAP server"
    shell: sudo su - demo -c "( /scenario/omd/ldap_server.pl >>var/log/ldap_server.log 2>&1 & )"
