- name: Update packages
  yum: 
    name: '*'
    state: latest
    update_cache: yes
    update_only: yes
  retries: 3
  delay: 10  

- name: Remove packates not needed anymore
  yum:
    autoremove: yes   
  retries: 3
  delay: 10

- name: Install required packages
  yum: 
    state: latest 
    update_cache: yes
    pkg: "{{ item }}"
  with_items:  "{{ required_packages }}" 
  retries: 3
  delay: 10    