---
- hosts: all
  roles:
    - role: common
    - role: thruk_developer
    - role: service_sshd
    - role: ssh_site_login
  tasks:
  - shell: "chown demo: /mnt/shared/"
  - shell: sudo su - demo -c "cp -rp .ssh /mnt/shared/"
  - shell: "cp -p /omd/sites/demo/.ssh/config /mnt/shared/.ssh"
  - shell: "chown -R demo: /mnt/shared/"
  - name: "omd config change"
    shell: "omd config demo change"
    args:
      stdin: |
        CORE=none
        APACHE_MODE=own
        GRAFANA=on
        INFLUXDB_HTTP_TCP_PORT=backend:8086
  - file:
      src: /omd/sites/demo/etc/influxdb/grafana_datasources.yml
      dest: /opt/omd/sites/demo/etc/grafana/provisioning/datasources/backend_influxdb.yml
      owner: demo
      group: demo
      state: link
  - copy:
      src: "/root/thruk_local.conf"
      dest: "/omd/sites/demo/etc/thruk/thruk_local.conf"
      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
  - shell: sudo su - demo -c "sed -e 's/^#use_/use_/' -i etc/thruk/thruk_local.d/lmd.conf"
  - name: wait for omd livestatus to become available
    wait_for:
      host: backend
      port: 6557
