---


  - name: install add-apt-repository binary for Ansible to work
    apt: name=python-software-properties state=present update_cache=yes

  - name: Install Threasure Data repository key
    apt_key: url=https://packages.treasuredata.com/GPG-KEY-td-agent state=present
    when: ansible_distribution == "Debian" 

  - name: Install treasuredata repository
    apt_repository: repo='deb http://packages.treasuredata.com/2/{{ ansible_distribution|lower }}/{{ ansible_distribution_release|lower }}/ {{ ansible_distribution_release|lower }} contrib' state=present

  - name: Install packages using apt
    apt: name=td-agent state=latest update_cache=yes cache_valid_time=3600
    when: ansible_os_family == "Debian"

  - name: start service
    service: name=td-agent state=started enabled=yes

