---

- name: install bench-server packages
  apt:
    force_apt_get: true
    name: "{{ bench_server_packages }}"
    state: latest
    update_cache: yes

- name: ensure configuration directory exists
  file:
    path: /etc/mediaserver
    state: directory

- name: benchmark configuration settings
  copy:
    dest: /etc/mediaserver/bench-conf.json
    content: |
      {
      "LOCUST_HOST":"{{ bench_server }}",
      "MS_HOST":"{{ bench_host }}",
      "MS_USERNAME":"{{ bench_user }}",
      "MS_PASSWORD":"{{ bench_password }}",
      "MEDIA_OID":"{{ bench_oid }}",
      "TIME_STATS":{{ bench_time_stat }}
      }

- name: reload systemd daemon
  systemd:
    daemon_reload: true

- name: restart bench-server
  systemd:
    name: bench-server
    state: restarted

- name: streaming configuration settings
  template:
    src: bench-streaming.conf.j2
    dest: /etc/mediaserver/bench-streaming.conf

- name: clone ms-testing-suite repository
  git:
    repo: "{{ bench_stream_repo }}"
    version: stable
    dest: /usr/share/ms-testing-suite
    update: yes
    force: yes

- name: copy configuration for docker instance
  copy:
    src: /etc/mediaserver/bench-streaming.conf
    dest: /usr/share/ms-testing-suite/config.json
    remote_src: yes

- name: add docker key
  apt_key:
    url: https://download.docker.com/linux/debian/gpg
    state: present

- name: add docker debian repository
  apt_repository:
    repo: "deb https://download.docker.com/linux/debian buster stable"
    state: present
    update_cache: yes

- name: install docker
  apt:
    name: docker-ce
    state: latest
    update_cache: yes

- name: generate docker image
  command: 
    cmd: make build_docker_img
    chdir: /usr/share/ms-testing-suite
  run_once: yes

...
