--- - name: apt update packages to their latest version and autoclean become: true apt: upgrade: yes autoclean: yes autoremove: yes update_cache: yes when: ansible_os_family == "Debian" and apt_update_packages register: result - name: List installed and updated packages become: true shell: cmd: 'grep -E "^$(date +%Y-%m-%d).+ (install|upgrade) " /var/log/dpkg.log | cut -d " " -f 3-5' register: result - name: Show Output debug: msg: "{{ result.stdout_lines }}" - name: install common tools become: true ansible.builtin.apt: name: "{{ item }}" with_items: "{{ apt_packages }}" when: ansible_os_family == "Debian" and apt_install_packages