---

- block:
  - include_vars:
      file: vars/chrony.yml

  - name: Install system tools packages from apt
    apt:
      name:
        - "adjtimex"
        - "aptitude"
        - "cgroup-bin"
        - "cgroup-lite"
        - "clusterssh"
        - "cpufrequtils"
        - "dpkg"
        - "gnupg-curl"
        - "hddtemp"
        - "htop"
        - "ifstat"
        - "iftop"
        - "iotop"
        - "kexec-tools"
        - "libapr1"
        - "libaprutil1"
        - "libzzip-0-13"
        - "lm-sensors"
        - "ncdu"
        - "numactl"
        - "openssh-client"
        - "openssh-server"
        - "pps-tools"
        - "python-qt4"
        - "python-qt4-dev"
        - "python-pyside"
        - "smartmontools"
        - "snmp"
        - "sshpass"
        # Dependencies for chrony
        - "libtomcrypt0"
        - "timelimit"
        - "install-info"
      install_recommends: no
      cache_valid_time: "{{ apt_cache_valid_time }}"

  - name: Install Chrony
    # Chrony built from https://git.zooxlabs.com/zooxco/chrony , following the directions in that repository
    http_deb:
      name: chrony
      version: "{{ chrony_version }}"
      url: "{{ chrony_download_url }}"
      checksum: "sha256:{{ chrony_sha }}"

  - name: Allow perf recording without root
    sysctl:
      name: "{{ item.name }}"
      value: "{{ item.value }}"
      sysctl_set: yes
      state: present
      reload: no
    with_items: "{{ perf_without_root_sysctl }}"

    # RSI-809, Ubuntu 14.04's coreutils was v8.21 : this version contained a bug where overlay
    # fileystems were not recognized by "tail -f". Replacing tail with 8.25 coreutils tail
  - name: Write improved tail tool
    get_url:
      url: "https://artifactory.zooxlabs.com/artifactory/RSI/imaging/coreutils_8_25_tail"
      dest: "/usr/bin/tail"
      checksum: "sha1:274622ce1f7fcb8b63ec6bf035225cfeafb83626"
      force: yes
      mode: '755'
      owner: root
      group: root

  - name: Install ipmitool
    apt:
      name: ipmitool
      cache_valid_time: "{{ apt_cache_valid_time }}"
    notify: Load ipmi module

  become: yes
