#!/usr/bin/env ansible-playbook
---

- name: UPGRADE SERVERS
  hosts: all
  tasks:

    - name: apt-get dist-upgrade
      when: ansible_os_family == "Debian"
      apt:
        force_apt_get: true
        install_recommends: false
        cache_valid_time: 3600
        upgrade: dist
      register: apt_status
      retries: 60
      until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)

    - name: yum upgrade
      when: ansible_os_family == "RedHat"
      yum:
        name: "*"
        state: latest

...
