---
- name: install system dependencies
  yum: name={{ item }} state=installed
  with_items:
    - openssl-devel
    - openldap-devel
    - python-pip
    - git
    - python-virtualenv
  become: true
  become_user: root
  when: ansible_os_family == "RedHat"

- name: install system dependencies
  apt: name={{ item }} state=installed
  with_items:
    - libssl-dev
    - libldap2-dev
  become: true
  become_user: root
  when: ansible_os_family == "Debian"

- name: create install dir
  file: name={{ item }} state=directory owner={{ ansible_user }}
  with_items:
   - "/usr/local/hpcsystem"
   - "/usr/local/hpcsystem_config"
   - "/usr/local/virtualenvs/mercpytools"
  become: true
  become_user: root

- name: upgrade pip
  pip:
    virtualenv: "/usr/local/virtualenvs/mercpytools"
    name: "pip"
    extra_args: "--upgrade"

- name: install mercpytools
  pip:
    virtualenv: "/usr/local/virtualenvs/mercpytools"
    name: "git+https://gitlab.erc.monash.edu.au/hpc-team/mercpytools.git#egg=mercpytools"
    extra_args: "--upgrade"

- name: install hpcsystem
  git: 
    repo: git@gitlab.erc.monash.edu.au:hpc-team/hpcsystem.git
    dest: /usr/local/hpcsystem
    accept_hostkey: True

- name: install hpcsystem_config
  git: 
    repo: git@gitlab.erc.monash.edu.au:hpc-team/m3_hpcsystem_config.git
    dest: /usr/local/hpcsystem_config
    accept_hostkey: True

- name: cron job to check quotas
  cron:
    name: "Naggy quota cron job"
    value: '/usr/local/hpcsystem/naggy_quota.sh'
    hour: 16
    minute: 23
  become: true
  become_user: root
