---
- hosts: all
  roles:
    - role: common
    - role: local_tests
    - role: thruk_developer
    - role: site_git
  tasks:
  - name: "omd config change"
    shell: "omd config demo change"
    args:
      stdin: |
        APACHE_MODE=own
        LIVESTATUS_TCP=on
        LIVESTATUS_TCP_PORT=7001

  - name: create symlink to agents plugin
    shell: "ln -sfn /thruk/plugins/plugins-available/agents /opt/omd/sites/demo/etc/thruk/plugins-enabled/agents"

  - name: add labs testing repository
    shell: rpm -Uvh "https://labs.consol.de/repo/testing/rhel9/i386/labs-consol-testing.rhel9.noarch.rpm"
    args:
      creates: "/etc/yum.repos.d/labs-consol-testing.repo"
  - name: "yum install snclient"
    include_role:
      name: yum_apt_retry
    vars:
      package:
        - snclient
  - copy:
      src: "/root/snclient_local.ini"
      dest: "/etc/snclient/snclient_local.ini"
  - shell: "snclient &"
  - name: make snclient.ini readable
    file:
      path: /etc/snclient/snclient.ini
      mode: "0644"

  - name: add user macro
    lineinfile:
      path: /omd/sites/demo/etc/naemon/resource.cfg
      regexp: '^\$USER5\$='
      line: $USER5$=test

  - copy:
      src: "/root/agents.cfg"
      dest: "/omd/sites/demo/etc/thruk/thruk_local.d/agents.cfg"
      owner: "demo"
      group: "demo"

  # copy again
  - name: Create a directory if it does not exist
    file:
      path: "/omd/sites/demo/etc/thruk/thruk_local.d/agents.d/"
      state: directory
      mode: '0755'
      owner: "demo"
      group: "demo"
  - copy:
      src: "/root/agents.cfg"
      dest: "/omd/sites/demo/etc/thruk/thruk_local.d/agents.d/test.cfg"
      owner: "demo"
      group: "demo"

  - shell: sudo su - demo -c "git add . && git commit -m 'setup complete'"