While installing pkgs Ansible fails, because there is a need to accept licensing terms.
How to auto accept terms through ansible-playbook?
ansible-playbook
There is no universal method for "packages".
For Oracle Java add a task before calling apt:
apt
- debconf: name: oracle-java8-installer question: shared/accepted-oracle-license-v1-1 value: true vtype: select