---
- name: Repository and packages, deb/ubuntu
  block:
  - name: Install the repository 
    apt: pkg={{ zabbix_agent_ubuntu_repo }} state=present
    register: update_apt_cache

  - name: Update the apt cache if we just installed the repository
    apt: update_cache=yes
    when: update_apt_cache is changed

  - name: Install the Zabbix agent package
    apt: pkg=zabbix-agent state=latest  cache_valid_time=1800

  tags: [ 'zabbix', 'zabbix_agent' ]