--- - name: Install necessary packages become: yes become_method: su become_user: root apt: name: "{{ packages_all }}" state: present cache_valid_time: 3600 - name: Install ubuntu specific packages become: yes become_method: su become_user: root when: ansible_distribution == "Ubuntu" apt: name: "{{ packages_ubuntu }}" state: present cache_valid_time: 3600 - name: Install debian specific packages become: yes become_method: su become_user: root when: ansible_distribution == "Debian" apt: name: "{{ packages_debian }}" state: present cache_valid_time: 3600